50 {
"TMS1mmX19",
"TMS1mmX19.pcb",
"TMS1mmX19.asc",
false },
51 {
"MC4_PLUS_CSHAPE",
"MC4_PLUS_CSHAPE.pcb",
"MC4_PLUS_CSHAPE.asc",
false },
52 {
"MC2_PLUS_REV1",
"MC2_PLUS_REV1.pcb",
"MC2_PLUS_REV1.asc",
true },
53 {
"Ems4_Rev2",
"Ems4_Rev2.pcb",
"Ems4_Rev2.asc",
false },
54 {
"LCORE_4",
"LCORE_4.pcb",
"LCORE_4.asc",
false },
55 {
"LCORE_2",
"LCORE_2.pcb",
"LCORE_2.asc",
false },
56 {
"Dexter_MotorCtrl",
"Dexter_MotorCtrl.pcb",
"Dexter_MotorCtrl.asc",
true },
57 {
"MAIS_FC",
"MAIS_FC.pcb",
"MAIS_FC.asc",
true },
84 aBoard.
dir <<
" binary should be readable by PCB_IO_PADS_BINARY" );
86 std::unique_ptr<BOARD> board;
90 board.reset( plugin.
LoadBoard( filename,
nullptr,
nullptr,
nullptr ) );
92 catch(
const std::exception& e )
94 BOOST_WARN_MESSAGE(
false,
95 aBoard.
dir <<
" binary threw exception during load: " << e.what() );
109 std::unique_ptr<BOARD> board;
113 board.reset( plugin.
LoadBoard( filename,
nullptr,
nullptr,
nullptr ) );
115 catch(
const std::exception& e )
117 BOOST_FAIL( aBoard.
dir <<
" ASC threw exception during load: " << e.what() );
121 BOOST_REQUIRE_MESSAGE( board !=
nullptr, aBoard.
dir <<
" ASC failed to load" );
149 size_t aAscCount,
bool aDifferentRevision )
151 if( aDifferentRevision )
153 BOOST_WARN_MESSAGE( aBinaryCount == aAscCount,
154 aLabel <<
" binary=" << aBinaryCount
155 <<
" asc=" << aAscCount <<
" (different revision)" );
159 if( aBinaryCount == aAscCount )
165 size_t maxCount = std::max( aBinaryCount, aAscCount );
166 size_t diff = ( aBinaryCount > aAscCount ) ? aBinaryCount - aAscCount
167 : aAscCount - aBinaryCount;
169 bool withinTolerance = ( diff <= 2 ) || ( diff * 100 / maxCount <= 5 );
172 aLabel <<
" counts differ beyond tolerance: binary=" << aBinaryCount
173 <<
" asc=" << aAscCount );
175 BOOST_WARN_MESSAGE( aBinaryCount == aAscCount,
176 aLabel <<
" exact count mismatch: binary=" << aBinaryCount
177 <<
" asc=" << aAscCount );
186 const BOARD* aBinaryBoard )
188 BOOST_WARN_MESSAGE( aBinaryBoard->
Tracks().size() > 0,
189 aBoard.
dir <<
" binary has no tracks (v0x2021 not yet supported)" );
191 std::set<std::pair<int, int>> viaPositions;
192 bool hasDuplicate =
false;
201 auto key = std::make_pair(
via->GetPosition().x,
via->GetPosition().y );
203 if( viaPositions.count( key ) )
209 viaPositions.insert( key );
213 aBoard.
dir <<
" binary should have no duplicate through-hole vias" );
220 aBoard.
dir <<
" binary track on non-copper layer "
221 << trk->GetLayer() );
227 for(
PAD*
pad : fp->Pads() )
231 aBoard.
dir <<
" " << fp->GetReference() <<
" pad has zero size" );
250 board.dir <<
" binary should be recognized by PCB_IO_PADS_BINARY" );
253 board.dir <<
" binary should NOT be recognized by PCB_IO_PADS" );
267 board.dir <<
" ASCII should NOT be recognized by PCB_IO_PADS_BINARY" );
272#define BINARY_LOAD_TEST( name, idx ) \
273 BOOST_AUTO_TEST_CASE( BasicLoad_##name ) \
275 auto board = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
278 BOOST_CHECK( board->Footprints().size() > 0 ); \
291#define FOOTPRINT_COUNT_TEST( name, idx ) \
292 BOOST_AUTO_TEST_CASE( FootprintCount_##name ) \
294 auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
299 auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
301 CheckCountWithTolerance( #name " footprints", bin->Footprints().size(), \
302 asc->Footprints().size(), \
303 PADS_BINARY_BOARDS[idx].differentRevision ); \
316#define NET_COUNT_TEST( name, idx ) \
317 BOOST_AUTO_TEST_CASE( NetCount_##name ) \
319 auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
324 auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
326 CheckCountWithTolerance( #name " nets", bin->GetNetCount(), asc->GetNetCount(), \
327 PADS_BINARY_BOARDS[idx].differentRevision ); \
340#define TRACK_COUNT_TEST( name, idx ) \
341 BOOST_AUTO_TEST_CASE( TrackCount_##name ) \
343 auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
348 auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
350 BOOST_WARN_MESSAGE( bin->Tracks().size() > 0, \
351 #name " binary track parsing not supported for v0x2021" ); \
353 BOOST_WARN_EQUAL( bin->Tracks().size(), asc->Tracks().size() ); \
372 "LCORE_4 binary should have board outline shapes" );
384 "LCORE_2 binary should have board outline shapes" );
390 int indices[] = { 0, 1, 2, 3, 6, 7 };
392 for(
int i : indices )
401 <<
" binary outline parsing not yet complete" );
406#define STRUCTURAL_INTEGRITY_TEST( name, idx ) \
407 BOOST_AUTO_TEST_CASE( StructuralIntegrity_##name ) \
409 auto board = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
414 RunStructuralChecks( PADS_BINARY_BOARDS[idx], board.get() ); \
General utilities for PCB file IO for QA programs.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const DRAWINGS & Drawings() const
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
PCB I/O plugin for importing PADS binary .pcb files.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
static int CountEdgeCutsShapes(const BOARD *aBoard)
static std::unique_ptr< BOARD > LoadAsc(const PADS_BINARY_BOARD_INFO &aBoard)
#define TRACK_COUNT_TEST(name, idx)
static std::unique_ptr< BOARD > LoadBinary(const PADS_BINARY_BOARD_INFO &aBoard)
Load a binary .pcb file.
BOOST_AUTO_TEST_CASE(BinaryFileDetection)
#define BINARY_LOAD_TEST(name, idx)
#define FOOTPRINT_COUNT_TEST(name, idx)
#define STRUCTURAL_INTEGRITY_TEST(name, idx)
static wxString GetAscPath(const PADS_BINARY_BOARD_INFO &aBoard)
#define NET_COUNT_TEST(name, idx)
static void CheckCountWithTolerance(const std::string &aLabel, size_t aBinaryCount, size_t aAscCount, bool aDifferentRevision)
Compare counts with tolerance for binary/ASC differences.
static const PADS_BINARY_BOARD_INFO PADS_BINARY_BOARDS[]
static wxString GetBinaryPath(const PADS_BINARY_BOARD_INFO &aBoard)
static void RunStructuralChecks(const PADS_BINARY_BOARD_INFO &aBoard, const BOARD *aBinaryBoard)
Structural integrity checks.
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)