62 for(
RULE_AREA& ra : aTool->GetData()->m_areas )
64 if( ra.m_ruleName.Contains( ( aName ) ) )
75 if( ra.m_zone && ra.m_zone->GetPlacementAreaSource() == aGroupName )
88 if( zone == aRuleArea.
m_zone )
91 if( zone->GetZoneName() != aZoneName )
106 std::vector<wxString> tests = {
"vme-wren" };
108 for(
const wxString& relPath : tests )
115 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
124 auto ruleData = mtTool->
GetData();
127 static_cast<int>( ruleData->m_areas.size() ) ) );
133 ruleData->m_replaceExisting =
true;
138 || ra.
m_sheetName == wxT(
"pp_driver_2x.kicad_sch" ) )
152 int n_areas_io = 0, n_areas_pp = 0, n_areas_other = 0;
155 static_cast<int>(ruleData->m_areas.size() ) ) );
157 for(
const RULE_AREA& ra : ruleData->m_areas )
161 if( ra.
m_ruleName.Contains( wxT(
"io_drivers_fp" ) ) )
166 else if( ra.
m_ruleName.Contains( wxT(
"io_drivers_pp" ) ) )
178 n_areas_io, n_areas_pp, n_areas_other ) );
184 const std::vector<wxString> rulesToTest = { wxT(
"io_drivers_fp" ),
185 wxT(
"io_drivers_pp" ) };
187 for(
const wxString& ruleName : rulesToTest )
189 for(
const RULE_AREA& refArea : ruleData->m_areas )
191 if( !refArea.
m_ruleName.Contains( ruleName ) )
196 for(
const RULE_AREA& targetArea : ruleData->m_areas )
201 if( !targetArea.
m_ruleName.Contains( ruleName ) )
204 auto cgRef = CONNECTION_GRAPH::BuildFromFootprintSet( refArea.
m_components,
207 CONNECTION_GRAPH::BuildFromFootprintSet( targetArea.
m_components,
212 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
213 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details );
216 "topo match: '%s' [%d] -> '%s' [%d] result %d", refArea.
m_ruleName.c_str().AsChar(),
218 static_cast<int>( targetArea.
m_components.size() ), status ? 1 : 0 ) );
220 for(
const auto& iter :
result )
223 iter.second->GetReference(),
224 iter.first->GetReference() ) );
227 BOOST_CHECK( status );
228 BOOST_CHECK( details.empty() );
235 BOOST_ASSERT( refArea );
237 const std::vector<wxString> targetAreaNames( { wxT(
"io_drivers_fp/bank2/io78/" ),
238 wxT(
"io_drivers_fp/bank1/io78/" ),
239 wxT(
"io_drivers_fp/bank0/io01/" ) } );
241 for(
const wxString& targetRaName : targetAreaNames )
245 BOOST_ASSERT( targetRA !=
nullptr );
249 ruleData->m_compatMap[targetRA].m_doCopy =
true;
254 BOOST_ASSERT(
result >= 0 );
270 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
277 auto ruleData = mtTool->
GetData();
280 static_cast<int>( ruleData->m_areas.size() ) ) );
282 BOOST_CHECK( ruleData->m_areas.size() >= 2 );
284 if( ruleData->m_areas.size() < 2 )
292 if( ra.
m_ruleName.Contains( wxT(
"Untitled Sheet/" ) ) )
294 else if( ra.
m_ruleName.Contains( wxT(
"Untitled Sheet1/" ) ) )
298 if( !refArea || !targetArea )
300 BOOST_TEST_MESSAGE(
"Could not find Untitled Sheet and Untitled Sheet1 rule areas, skipping test" );
328 if( !refFP || !targetFP )
330 BOOST_TEST_MESSAGE(
"Could not find matching footprints in the rule areas, skipping test" );
335 bool refValueVisible = refValueField ? refValueField->
IsVisible() :
true;
337 std::vector<FP_3DMODEL> refModels = refFP->
Models();
341 ruleData->m_compatMap[targetArea].m_doCopy =
true;
342 ruleData->m_options.m_copyPlacement =
true;
346 BOOST_CHECK(
result >= 0 );
350 if( targetValueField && refValueField )
354 refValueVisible, targetValueField->
IsVisible() ) );
359 if( !refModels.empty() )
362 static_cast<int>( refModels.size() ),
363 static_cast<int>( targetFP->
Models().size() ) ) );
382 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
389 auto ruleData = mtTool->
GetData();
392 static_cast<int>( ruleData->m_areas.size() ) ) );
396 if( ruleData->m_areas.size() < 2 )
413 int refViaCountBefore = 0;
415 for(
PCB_TRACK* track : m_board->Tracks() )
427 BOOST_TEST_MESSAGE( wxString::Format(
"Reference area vias before repeat: %d", refViaCountBefore ) );
428 BOOST_CHECK( refViaCountBefore > 0 );
432 ruleData->m_compatMap[targetArea].m_doCopy =
true;
433 ruleData->m_options.m_copyPlacement =
true;
434 ruleData->m_options.m_copyRouting =
true;
438 BOOST_CHECK(
result >= 0 );
440 int refViaCountAfter = 0;
442 for(
PCB_TRACK* track : m_board->Tracks() )
454 BOOST_TEST_MESSAGE( wxString::Format(
"Reference area vias after repeat: %d", refViaCountAfter ) );
471 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
534 auto cgRef = std::make_unique<CONNECTION_GRAPH>();
535 auto cgTarget = std::make_unique<CONNECTION_GRAPH>();
538 LIB_ID fpid( wxT(
"Package_SO" ), wxT(
"SOIC-8_3.9x4.9mm_P1.27mm" ) );
550 PAD padRef1( &fpRef );
553 fpRef.
Add( &padRef1 );
555 PAD padRef2( &fpRef );
558 fpRef.
Add( &padRef2 );
560 PAD padTarget1( &fpTarget );
563 fpTarget.
Add( &padTarget1 );
565 PAD padTarget2( &fpTarget );
568 fpTarget.
Add( &padTarget2 );
571 cgRef->AddFootprint( &fpRef,
VECTOR2I( 0, 0 ) );
572 cgTarget->AddFootprint( &fpTarget,
VECTOR2I( 0, 0 ) );
574 cgRef->BuildConnectivity();
575 cgTarget->BuildConnectivity();
581 COMPONENT* cmpRef = cgRef->Components()[0];
582 COMPONENT* cmpTarget = cgTarget->Components()[0];
584 bool sameKind = cmpRef->IsSameKind( *cmpTarget );
586 BOOST_TEST_MESSAGE( wxString::Format(
"TRIM_1.1 and TRIM_2.1 IsSameKind: %d", sameKind ? 1 : 0 ) );
587 BOOST_CHECK( sameKind );
591 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
592 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details );
594 BOOST_TEST_MESSAGE( wxString::Format(
"Topology match result: %d", status ? 1 : 0 ) );
596 if( !status && !details.empty() )
598 for(
const auto& reason : details )
601 reason.m_reference, reason.m_candidate, reason.m_reason ) );
605 BOOST_CHECK( status );
606 BOOST_CHECK( details.empty() );
609 fpRef.
Pads().clear();
610 fpTarget.
Pads().clear();
629 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
636 auto ruleData = mtTool->
GetData();
644 if( ra.
m_sheetPath == wxT(
"/io_drivers_fp/bank0/io01/" ) )
646 else if( ra.
m_sheetPath == wxT(
"/io_drivers_fp/bank0/" ) )
648 else if( ra.
m_sheetPath == wxT(
"/io_drivers_fp/" ) )
656 BOOST_TEST_MESSAGE( wxString::Format(
"Leaf /io_drivers_fp/bank0/io01/ components: %d",
695 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
702 auto ruleData = mtTool->
GetData();
708 if( ra.
m_sheetName == wxT(
"io_driver.kicad_sch" ) )
722 auto cgRef = CONNECTION_GRAPH::BuildFromFootprintSet( refArea->
m_components,
724 auto cgTarget = CONNECTION_GRAPH::BuildFromFootprintSet( targetArea->
m_components,
729 std::atomic<bool> cancelled(
true );
730 std::atomic<int> matched( 0 );
731 std::atomic<int> total( 0 );
739 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
741 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details, params );
743 BOOST_CHECK( !status );
744 BOOST_CHECK(
result.empty() );
751 std::atomic<bool> cancelled(
false );
752 std::atomic<int> matched( 0 );
753 std::atomic<int> total( 0 );
761 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
763 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details, params );
765 BOOST_CHECK( status );
767 int finalMatched = matched.load();
768 int finalTotal = total.load();
770 BOOST_TEST_MESSAGE( wxString::Format(
"Progress: matched=%d, total=%d", finalMatched, finalTotal ) );
772 BOOST_CHECK( finalTotal > 0 );
779 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
781 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details );
783 BOOST_CHECK( status );
784 BOOST_CHECK( !
result.empty() );
810 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
817 auto ruleData = mtTool->
GetData();
820 static_cast<int>( ruleData->m_areas.size() ) ) );
834 if( source == wxT(
"/i2c_thingy_ch0/" ) )
836 else if( source == wxT(
"/i2c_thingy_ch1/" ) )
840 BOOST_REQUIRE_MESSAGE( ch0Area !=
nullptr,
"Could not find i2c_thingy_ch0 rule area" );
841 BOOST_REQUIRE_MESSAGE( ch1Area !=
nullptr,
"Could not find i2c_thingy_ch1 rule area" );
849 auto cgRef = CONNECTION_GRAPH::BuildFromFootprintSet( ch0Area->
m_components,
851 auto cgTarget = CONNECTION_GRAPH::BuildFromFootprintSet( ch1Area->
m_components,
855 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
856 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details );
860 for(
const auto& reason : details )
863 reason.m_reference, reason.m_candidate,
868 BOOST_CHECK_MESSAGE( status,
869 "Topology match failed for channels with hierarchical pins "
870 "tied to global nets (issue 21739)" );
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
Information pertinent to a Pcbnew printed circuit board.
const ZONES & Zones() const
Store all of the related component information found in a netlist.
virtual bool IsVisible() const
A logical library item identifier and consists of various portions much like a URI.
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
Handle a list of polygons defining a copper zone.
wxString GetPlacementAreaSource() const
SHAPE_POLY_SET * Outline()
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
std::map< FOOTPRINT *, FOOTPRINT * > COMPONENT_MATCHES
MULTICHANNEL_TEST_FIXTURE()
SETTINGS_MANAGER m_settingsManager
std::unique_ptr< BOARD > m_board
bool m_includeLockedItems
std::vector< RULE_AREA > m_areas
std::set< FOOTPRINT * > m_components
std::atomic< bool > * m_cancelled
std::atomic< int > * m_matchedComponents
std::atomic< int > * m_totalComponents
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
RULE_AREA * findRuleAreaByPartialName(MULTICHANNEL_TOOL *aTool, const wxString &aName)
BOOST_FIXTURE_TEST_CASE(MultichannelToolRegressions, MULTICHANNEL_TEST_FIXTURE)
int countZonesByNameInRuleArea(BOARD *aBoard, const wxString &aZoneName, const RULE_AREA &aRuleArea)
RULE_AREA * findRuleAreaByPlacementGroup(MULTICHANNEL_TOOL *aTool, const wxString &aGroupName)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
VECTOR2< int32_t > VECTOR2I