54 {
"TMS1mmX19",
"TMS1mmX19.pcb",
"TMS1mmX19.asc",
false },
55 {
"MC4_PLUS_CSHAPE",
"MC4_PLUS_CSHAPE.pcb",
"MC4_PLUS_CSHAPE.asc",
false },
56 {
"MC2_PLUS_REV1",
"MC2_PLUS_REV1.pcb",
"MC2_PLUS_REV1.asc",
true },
57 {
"Ems4_Rev2",
"Ems4_Rev2.pcb",
"Ems4_Rev2.asc",
false },
58 {
"LCORE_4",
"LCORE_4.pcb",
"LCORE_4.asc",
false },
59 {
"LCORE_2",
"LCORE_2.pcb",
"LCORE_2.asc",
false },
60 {
"Dexter_MotorCtrl",
"Dexter_MotorCtrl.pcb",
"Dexter_MotorCtrl.asc",
true },
61 {
"MAIS_FC",
"MAIS_FC.pcb",
"MAIS_FC.asc",
true },
88 aBoard.
dir <<
" binary should be readable by PCB_IO_PADS_BINARY" );
90 std::unique_ptr<BOARD> board;
94 board.reset( plugin.
LoadBoard( filename,
nullptr,
nullptr,
nullptr ) );
96 catch(
const std::exception& e )
98 BOOST_WARN_MESSAGE(
false,
99 aBoard.
dir <<
" binary threw exception during load: " << e.what() );
103 BOOST_CHECK_MESSAGE( board !=
nullptr, aBoard.
dir <<
" binary failed to load" );
113 std::unique_ptr<BOARD> board;
117 board.reset( plugin.
LoadBoard( filename,
nullptr,
nullptr,
nullptr ) );
119 catch(
const std::exception& e )
121 BOOST_FAIL( aBoard.
dir <<
" ASC threw exception during load: " << e.what() );
125 BOOST_REQUIRE_MESSAGE( board !=
nullptr, aBoard.
dir <<
" ASC failed to load" );
153 size_t aAscCount,
bool aDifferentRevision )
155 if( aDifferentRevision )
157 BOOST_WARN_MESSAGE( aBinaryCount == aAscCount,
158 aLabel <<
" binary=" << aBinaryCount
159 <<
" asc=" << aAscCount <<
" (different revision)" );
163 if( aBinaryCount == aAscCount )
165 BOOST_CHECK_MESSAGE(
true, aLabel <<
" counts match: " << aBinaryCount );
169 size_t maxCount = std::max( aBinaryCount, aAscCount );
170 size_t diff = ( aBinaryCount > aAscCount ) ? aBinaryCount - aAscCount
171 : aAscCount - aBinaryCount;
173 bool withinTolerance = ( diff <= 2 ) || ( diff * 100 / maxCount <= 5 );
175 BOOST_CHECK_MESSAGE( withinTolerance,
176 aLabel <<
" counts differ beyond tolerance: binary=" << aBinaryCount
177 <<
" asc=" << aAscCount );
179 BOOST_WARN_MESSAGE( aBinaryCount == aAscCount,
180 aLabel <<
" exact count mismatch: binary=" << aBinaryCount
181 <<
" asc=" << aAscCount );
190 const BOARD* aBinaryBoard )
192 BOOST_WARN_MESSAGE( aBinaryBoard->
Tracks().size() > 0,
193 aBoard.
dir <<
" binary has no tracks (v0x2021 not yet supported)" );
195 std::set<std::pair<int, int>> viaPositions;
196 bool hasDuplicate =
false;
205 auto key = std::make_pair(
via->GetPosition().x,
via->GetPosition().y );
207 if( viaPositions.count( key ) )
213 viaPositions.insert( key );
216 BOOST_CHECK_MESSAGE( !hasDuplicate,
217 aBoard.
dir <<
" binary should have no duplicate through-hole vias" );
224 aBoard.
dir <<
" binary track on non-copper layer "
225 << trk->GetLayer() );
231 for(
PAD*
pad : fp->Pads() )
235 aBoard.
dir <<
" " << fp->GetReference() <<
" pad has zero size" );
253 BOOST_CHECK_MESSAGE( binaryPlugin.
CanReadBoard( binaryPath ),
254 board.dir <<
" binary should be recognized by PCB_IO_PADS_BINARY" );
256 BOOST_CHECK_MESSAGE( !ascPlugin.
CanReadBoard( binaryPath ),
257 board.dir <<
" binary should NOT be recognized by PCB_IO_PADS" );
270 BOOST_CHECK_MESSAGE( !binaryPlugin.
CanReadBoard( ascPath ),
271 board.dir <<
" ASCII should NOT be recognized by PCB_IO_PADS_BINARY" );
276#define BINARY_LOAD_TEST( name, idx ) \
277 BOOST_AUTO_TEST_CASE( BasicLoad_##name ) \
279 auto board = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
282 BOOST_CHECK( board->Footprints().size() > 0 ); \
295#define FOOTPRINT_COUNT_TEST( name, idx ) \
296 BOOST_AUTO_TEST_CASE( FootprintCount_##name ) \
298 auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
303 auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
305 CheckCountWithTolerance( #name " footprints", bin->Footprints().size(), \
306 asc->Footprints().size(), \
307 PADS_BINARY_BOARDS[idx].differentRevision ); \
320#define NET_COUNT_TEST( name, idx ) \
321 BOOST_AUTO_TEST_CASE( NetCount_##name ) \
323 auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
328 auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
330 CheckCountWithTolerance( #name " nets", bin->GetNetCount(), asc->GetNetCount(), \
331 PADS_BINARY_BOARDS[idx].differentRevision ); \
344#define TRACK_COUNT_TEST( name, idx ) \
345 BOOST_AUTO_TEST_CASE( TrackCount_##name ) \
347 auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
352 auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
354 BOOST_WARN_MESSAGE( bin->Tracks().size() > 0, \
355 #name " binary track parsing not supported for v0x2021" ); \
357 BOOST_WARN_EQUAL( bin->Tracks().size(), asc->Tracks().size() ); \
376 "LCORE_4 binary should have board outline shapes" );
388 "LCORE_2 binary should have board outline shapes" );
394 int indices[] = { 0, 1, 2, 3, 6, 7 };
396 for(
int i : indices )
405 <<
" binary outline parsing not yet complete" );
410#define STRUCTURAL_INTEGRITY_TEST( name, idx ) \
411 BOOST_AUTO_TEST_CASE( StructuralIntegrity_##name ) \
413 auto board = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
418 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.
@ 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)