KiCad PCB EDA Suite
test_tracks_cleaner.cpp File Reference

Go to the source code of this file.

Classes

struct  TRACK_CLEANER_TEST_FIXTURE
 
struct  TEST_DESCRIPTION
 

Functions

 BOOST_FIXTURE_TEST_CASE (FailedToCleanRegressionTests, TRACK_CLEANER_TEST_FIXTURE)
 
 BOOST_FIXTURE_TEST_CASE (TrackCleanerRegressionTests, TRACK_CLEANER_TEST_FIXTURE)
 

Function Documentation

◆ BOOST_FIXTURE_TEST_CASE() [1/2]

BOOST_FIXTURE_TEST_CASE ( FailedToCleanRegressionTests  ,
TRACK_CLEANER_TEST_FIXTURE   
)

Definition at line 60 of file test_tracks_cleaner.cpp.

61{
62 /*
63 * This one ensures that certain cleanup items are indeed found and marked for cleanup.
64 */
65 std::vector<TEST_DESCRIPTION> tests =
66 {
67 // short redundant redundant dangling tracks dangling
68 // circuits vias tracks tracks in pads vias expected
69 { "issue2904", false, false, false, true, false, false, 9 },
70 { "issue5093", false, false, false, false, true, false, 118 },
71 { "issue7004", false, true, false, false, false, true, 25 },
72 { "issue8883", true, true, true, true, false, true, 80 },
73 { "issue10916", false, false, true, false, false, false, 0 }
74 };
75
76 for( const TEST_DESCRIPTION& entry : tests )
77 {
78 KI_TEST::LoadBoard( m_settingsManager, entry.m_File, m_board );
79 KI_TEST::FillZones( m_board.get() );
80 m_board->GetConnectivity()->RecalculateRatsnest();
81 m_board->UpdateRatsnestExclusions();
82
83 TOOL_MANAGER toolMgr;
84 toolMgr.SetEnvironment( m_board.get(), nullptr, nullptr, nullptr, nullptr );
85
86 BOARD_COMMIT commit( &toolMgr );
87 TRACKS_CLEANER cleaner( m_board.get(), commit );
88 std::vector< std::shared_ptr<CLEANUP_ITEM> > dryRunItems;
89 std::vector< std::shared_ptr<CLEANUP_ITEM> > realRunItems;
90
91 cleaner.CleanupBoard( true, &dryRunItems, entry.m_Shorts,
92 entry.m_RedundantVias,
93 entry.m_RedundantTracks,
94 entry.m_DanglingTracks,
95 entry.m_TracksInPads,
96 entry.m_DanglingVias );
97
98 cleaner.CleanupBoard( true, &realRunItems, entry.m_Shorts,
99 entry.m_RedundantVias,
100 entry.m_RedundantTracks,
101 entry.m_DanglingTracks,
102 entry.m_TracksInPads,
103 entry.m_DanglingVias );
104
105 if( dryRunItems.size() == entry.m_Expected && realRunItems.size() == entry.m_Expected )
106 {
107 BOOST_CHECK_EQUAL( 1, 1 ); // quiet "did not check any assertions" warning
108 BOOST_TEST_MESSAGE( wxString::Format( "Track cleaner regression: %s, passed",
109 entry.m_File ) );
110 }
111 else
112 {
113 BOOST_CHECK_EQUAL( dryRunItems.size(), entry.m_Expected );
114 BOOST_CHECK_EQUAL( realRunItems.size(), entry.m_Expected );
115
117
118 std::map<KIID, EDA_ITEM*> itemMap;
119 m_board->FillItemMap( itemMap );
120
121 for( const std::shared_ptr<CLEANUP_ITEM>& item : realRunItems )
122 {
123 BOOST_TEST_MESSAGE( item->ShowReport( &unitsProvider, RPT_SEVERITY_ERROR,
124 itemMap ) );
125 }
126
127 BOOST_ERROR( wxString::Format( "Track cleaner regression: %s, failed",
128 entry.m_File ) );
129 }
130 }
131}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
Master controller class:
Definition: tool_manager.h:55
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
void FillZones(BOARD *m_board)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ RPT_SEVERITY_ERROR

References TRACKS_CLEANER::CleanupBoard(), KI_TEST::FillZones(), Format(), INCHES, KI_TEST::LoadBoard(), pcbIUScale, RPT_SEVERITY_ERROR, and TOOL_MANAGER::SetEnvironment().

◆ BOOST_FIXTURE_TEST_CASE() [2/2]

BOOST_FIXTURE_TEST_CASE ( TrackCleanerRegressionTests  ,
TRACK_CLEANER_TEST_FIXTURE   
)

Definition at line 134 of file test_tracks_cleaner.cpp.

135{
136 /*
137 * This one just makes sure that the dry-run counts agree with the "real" counts, and that
138 * the cleaning doesn't produce any connectivity changes.
139 */
140 std::vector<wxString> tests = { "issue832",
141 "issue4257",
142 "issue8909"
143 };
144
145 for( const wxString& relPath : tests )
146 {
147 KI_TEST::LoadBoard( m_settingsManager, relPath, m_board );
148 KI_TEST::FillZones( m_board.get() );
149 m_board->GetConnectivity()->RecalculateRatsnest();
150 m_board->UpdateRatsnestExclusions();
151
152 TOOL_MANAGER toolMgr;
153 toolMgr.SetEnvironment( m_board.get(), nullptr, nullptr, nullptr, nullptr );
154
155 BOARD_COMMIT commit( &toolMgr );
156 TRACKS_CLEANER cleaner( m_board.get(), commit );
157 std::vector< std::shared_ptr<CLEANUP_ITEM> > dryRunItems;
158 std::vector< std::shared_ptr<CLEANUP_ITEM> > realRunItems;
159
160 cleaner.CleanupBoard( true, &dryRunItems, true, // short circuits
161 true, // redundant vias
162 true, // redundant tracks
163 true, // dangling tracks
164 true, // tracks in pads
165 true ); // dangling vias
166
167 cleaner.CleanupBoard( true, &realRunItems, true, // short circuits
168 true, // redundant vias
169 true, // redundant tracks
170 true, // dangling tracks
171 true, // tracks in pads
172 true ); // dangling vias
173
174 BOOST_CHECK_EQUAL( dryRunItems.size(), realRunItems.size() );
175
176 std::vector<DRC_ITEM> violations;
177 BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
178
179 // Disable some DRC tests not useful in this testcase
184
185 bds.m_DRCEngine->SetViolationHandler(
186 [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer )
187 {
188 if( aItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
189 violations.push_back( *aItem );
190 } );
191
192 bds.m_DRCEngine->RunTests( EDA_UNITS::MILLIMETRES, true, false );
193
194 if( violations.empty() )
195 {
196 BOOST_TEST_MESSAGE( wxString::Format( "Track cleaner regression: %s, passed",
197 relPath ) );
198 }
199 else
200 {
202
203 std::map<KIID, EDA_ITEM*> itemMap;
204 m_board->FillItemMap( itemMap );
205
206 for( const DRC_ITEM& item : violations )
207 {
208 BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, RPT_SEVERITY_ERROR,
209 itemMap ) );
210 }
211
212 BOOST_ERROR( wxString::Format( "Track cleaner regression: %s, failed",
213 relPath ) );
214 }
215 }
216}
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
@ DRCE_UNCONNECTED_ITEMS
Definition: drc_item.h:39
@ DRCE_LIB_FOOTPRINT_ISSUES
Definition: drc_item.h:76
@ DRCE_STARVED_THERMAL
Definition: drc_item.h:48
@ DRCE_COPPER_SLIVER
Definition: drc_item.h:84
@ DRCE_LIB_FOOTPRINT_MISMATCH
Definition: drc_item.h:77
@ RPT_SEVERITY_IGNORE

References TRACKS_CLEANER::CleanupBoard(), DRCE_COPPER_SLIVER, DRCE_LIB_FOOTPRINT_ISSUES, DRCE_LIB_FOOTPRINT_MISMATCH, DRCE_STARVED_THERMAL, DRCE_UNCONNECTED_ITEMS, KI_TEST::FillZones(), Format(), INCHES, KI_TEST::LoadBoard(), BOARD_DESIGN_SETTINGS::m_DRCEngine, BOARD_DESIGN_SETTINGS::m_DRCSeverities, MILLIMETRES, pcbIUScale, RPT_SEVERITY_ERROR, RPT_SEVERITY_IGNORE, and TOOL_MANAGER::SetEnvironment().