KiCad PCB EDA Suite
test_drc_regressions.cpp File Reference
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <qa/pcbnew/board_test_utils.h>
#include <board.h>
#include <board_design_settings.h>
#include <pad.h>
#include <pcb_track.h>
#include <footprint.h>
#include <drc/drc_item.h>
#include <settings/settings_manager.h>

Go to the source code of this file.

Classes

struct  DRC_REGRESSION_TEST_FIXTURE
 

Functions

 BOOST_FIXTURE_TEST_CASE (DRCFalsePositiveRegressions, DRC_REGRESSION_TEST_FIXTURE)
 
 BOOST_FIXTURE_TEST_CASE (DRCFalseNegativeRegressions, DRC_REGRESSION_TEST_FIXTURE)
 

Function Documentation

◆ BOOST_FIXTURE_TEST_CASE() [1/2]

BOOST_FIXTURE_TEST_CASE ( DRCFalsePositiveRegressions  ,
DRC_REGRESSION_TEST_FIXTURE   
)

Definition at line 46 of file test_drc_regressions.cpp.

47 {
48  // These documents at one time flagged DRC errors that they shouldn't have.
49 
50  std::vector<wxString> tests = { "issue4139",
51  "issue4774",
52  "issue5978",
53  "issue5990",
54  "issue6443",
55  "issue7567",
56  "issue7975",
57  "issue8407" };
58 
59  for( const wxString& relPath : tests )
60  {
61  KI_TEST::LoadBoard( m_settingsManager, relPath, m_board );
62  KI_TEST::FillZones( m_board.get(), 6 );
63 
64  std::vector<DRC_ITEM> violations;
65  BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
66 
69 
70  bds.m_DRCEngine->SetViolationHandler(
71  [&]( const std::shared_ptr<DRC_ITEM>& aItem, wxPoint aPos )
72  {
73  if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR )
74  violations.push_back( *aItem );
75  } );
76 
77  bds.m_DRCEngine->RunTests( EDA_UNITS::MILLIMETRES, true, false );
78 
79  if( violations.empty() )
80  {
81  BOOST_CHECK_EQUAL( 1, 1 ); // quiet "did not check any assertions" warning
82  BOOST_TEST_MESSAGE( wxString::Format( "DRC regression: %s, passed", relPath ) );
83  }
84  else
85  {
86  std::map<KIID, EDA_ITEM*> itemMap;
87  m_board->FillItemMap( itemMap );
88 
89  for( const DRC_ITEM& item : violations )
90  {
91  BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR,
92  itemMap ) );
93  }
94 
95  BOOST_ERROR( wxString::Format( "DRC regression: %s, failed", relPath ) );
96  }
97  }
98 }
SEVERITY GetSeverity(int aDRCErrorCode)
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
std::map< int, SEVERITY > m_DRCSeverities
void FillZones(BOARD *m_board, int aFillVersion)
std::shared_ptr< DRC_ENGINE > m_DRCEngine
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
Container for design settings for a BOARD object.

References DRCE_INVALID_OUTLINE, DRCE_UNCONNECTED_ITEMS, KI_TEST::FillZones(), Format(), BOARD_DESIGN_SETTINGS::GetSeverity(), INCHES, KI_TEST::LoadBoard(), BOARD_DESIGN_SETTINGS::m_DRCEngine, BOARD_DESIGN_SETTINGS::m_DRCSeverities, MILLIMETRES, RPT_SEVERITY_ERROR, and RPT_SEVERITY_IGNORE.

◆ BOOST_FIXTURE_TEST_CASE() [2/2]

BOOST_FIXTURE_TEST_CASE ( DRCFalseNegativeRegressions  ,
DRC_REGRESSION_TEST_FIXTURE   
)

Definition at line 101 of file test_drc_regressions.cpp.

102 {
103  // These documents at one time failed to catch DRC errors that they should have.
104 
105  std::vector< std::pair<wxString, int> > tests = { { "issue1358", 2 },
106  { "issue2528", 1 },
107  { "issue5750", 4 },
108  { "issue5854", 3 },
109  { "issue6879", 6 },
110  { "issue6945", 2 },
111  { "issue7241", 1 },
112  { "issue7267", 4 },
113  { "issue7325", 2 },
114  { "issue8003", 2 },
115  { "issue9081", 2 } };
116 
117  for( const std::pair<wxString, int>& entry : tests )
118  {
119  KI_TEST::LoadBoard( m_settingsManager, entry.first, m_board );
120  KI_TEST::FillZones( m_board.get(), 6 );
121 
122  std::vector<DRC_ITEM> violations;
123  BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
124 
125  bds.m_DRCEngine->SetViolationHandler(
126  [&]( const std::shared_ptr<DRC_ITEM>& aItem, wxPoint aPos )
127  {
128  violations.push_back( *aItem );
129  } );
130 
131  bds.m_DRCEngine->RunTests( EDA_UNITS::MILLIMETRES, true, false );
132 
133  if( violations.size() == entry.second )
134  {
135  BOOST_CHECK_EQUAL( 1, 1 ); // quiet "did not check any assertions" warning
136  BOOST_TEST_MESSAGE( wxString::Format( "DRC regression: %s, passed", entry.first ) );
137  }
138  else
139  {
140  BOOST_CHECK_EQUAL( violations.size(), entry.second );
141 
142  std::map<KIID, EDA_ITEM*> itemMap;
143  m_board->FillItemMap( itemMap );
144 
145  for( const DRC_ITEM& item : violations )
146  {
147  BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR,
148  itemMap ) );
149  }
150 
151  BOOST_ERROR( wxString::Format( "DRC regression: %s, failed", entry.first ) );
152  }
153  }
154 }
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
void FillZones(BOARD *m_board, int aFillVersion)
std::shared_ptr< DRC_ENGINE > m_DRCEngine
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
Container for design settings for a BOARD object.

References KI_TEST::FillZones(), Format(), INCHES, KI_TEST::LoadBoard(), BOARD_DESIGN_SETTINGS::m_DRCEngine, MILLIMETRES, and RPT_SEVERITY_ERROR.