2021-07-30 20:15:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2022-03-09 16:18:54 +00:00
|
|
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-07-30 20:15:21 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <qa_utils/wx_utils/unit_test_utils.h>
|
2022-03-18 20:05:15 +00:00
|
|
|
#include <pcbnew_utils/board_test_utils.h>
|
2021-07-30 20:15:21 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <board_design_settings.h>
|
|
|
|
#include <pad.h>
|
|
|
|
#include <pcb_track.h>
|
2021-08-09 10:10:09 +00:00
|
|
|
#include <pcb_marker.h>
|
2021-07-30 20:15:21 +00:00
|
|
|
#include <footprint.h>
|
|
|
|
#include <drc/drc_item.h>
|
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
|
2021-08-03 13:32:49 +00:00
|
|
|
|
2021-07-30 20:15:21 +00:00
|
|
|
struct DRC_REGRESSION_TEST_FIXTURE
|
|
|
|
{
|
|
|
|
DRC_REGRESSION_TEST_FIXTURE() :
|
|
|
|
m_settingsManager( true /* headless */ )
|
2021-08-03 13:32:49 +00:00
|
|
|
{ }
|
2021-07-30 20:15:21 +00:00
|
|
|
|
2021-08-03 13:32:49 +00:00
|
|
|
SETTINGS_MANAGER m_settingsManager;
|
|
|
|
std::unique_ptr<BOARD> m_board;
|
2021-07-30 20:15:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-07-31 19:12:52 +00:00
|
|
|
BOOST_FIXTURE_TEST_CASE( DRCFalsePositiveRegressions, DRC_REGRESSION_TEST_FIXTURE )
|
2021-07-30 20:15:21 +00:00
|
|
|
{
|
2021-07-31 15:31:38 +00:00
|
|
|
// These documents at one time flagged DRC errors that they shouldn't have.
|
|
|
|
|
2022-06-15 09:55:25 +00:00
|
|
|
std::vector<wxString> tests =
|
|
|
|
{
|
|
|
|
"issue4139", // DRC fails wrongly with minimally-spaced pads at 45 degree
|
|
|
|
"issue4774", // Shape collisions missing SH_POLY_SET
|
|
|
|
"issue5978", // Hole clearance violation with non-copper pad
|
|
|
|
"issue5990", // DRC flags a board edge clearance violation although the clearance is respected
|
|
|
|
"issue6443", // Wrong DRC and rendering of THT pads with selective inner copper layers
|
|
|
|
"issue7567", // DRC constraint to disallow holes gets SMD pads also
|
|
|
|
"issue7975", // Differential pair gap out of range fault by DRC
|
|
|
|
"issue8407", // PCBNEW: Arc for diff pair has clearance DRC error
|
|
|
|
"issue10906", // Soldermask bridge for only one object
|
2022-10-09 22:31:26 +00:00
|
|
|
"issue11814", // Bad cache hit in isInsideArea
|
2023-03-25 11:13:12 +00:00
|
|
|
"issue12609", // Arc collison edge case
|
2023-08-04 14:37:23 +00:00
|
|
|
"issue14412", // Solder mask bridge between pads in a net-tie pad group
|
|
|
|
"issue15280" // Very wide spokes mis-counted as being single spoke
|
2022-06-15 09:55:25 +00:00
|
|
|
};
|
2021-07-31 15:31:38 +00:00
|
|
|
|
|
|
|
for( const wxString& relPath : tests )
|
2021-07-30 20:15:21 +00:00
|
|
|
{
|
2021-08-03 13:32:49 +00:00
|
|
|
KI_TEST::LoadBoard( m_settingsManager, relPath, m_board );
|
2023-07-07 18:03:09 +00:00
|
|
|
// Do not refill zones here because this is testing the DRC engine, not the zone filler
|
2021-07-30 20:15:21 +00:00
|
|
|
|
|
|
|
std::vector<DRC_ITEM> violations;
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
|
|
|
|
|
2022-01-12 14:57:41 +00:00
|
|
|
// Disable DRC tests not useful or not handled in this testcase
|
2021-07-31 15:31:38 +00:00
|
|
|
bds.m_DRCSeverities[ DRCE_INVALID_OUTLINE ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
bds.m_DRCSeverities[ DRCE_UNCONNECTED_ITEMS ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
2022-01-06 08:37:14 +00:00
|
|
|
bds.m_DRCSeverities[ DRCE_COPPER_SLIVER ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
bds.m_DRCSeverities[ DRCE_STARVED_THERMAL ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
2022-01-12 17:09:07 +00:00
|
|
|
// These DRC tests are not useful and do not work because they need a footprint library
|
|
|
|
// associated to the board
|
2022-01-12 14:57:41 +00:00
|
|
|
bds.m_DRCSeverities[ DRCE_LIB_FOOTPRINT_ISSUES ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
bds.m_DRCSeverities[ DRCE_LIB_FOOTPRINT_MISMATCH ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
2021-07-30 20:15:21 +00:00
|
|
|
|
2021-08-03 13:32:49 +00:00
|
|
|
bds.m_DRCEngine->SetViolationHandler(
|
2022-08-15 16:59:34 +00:00
|
|
|
[&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer )
|
2021-07-30 20:15:21 +00:00
|
|
|
{
|
|
|
|
if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR )
|
|
|
|
violations.push_back( *aItem );
|
|
|
|
} );
|
|
|
|
|
2021-08-03 13:32:49 +00:00
|
|
|
bds.m_DRCEngine->RunTests( EDA_UNITS::MILLIMETRES, true, false );
|
2021-07-30 20:15:21 +00:00
|
|
|
|
2021-07-31 15:31:38 +00:00
|
|
|
if( violations.empty() )
|
|
|
|
{
|
2021-08-03 13:32:49 +00:00
|
|
|
BOOST_CHECK_EQUAL( 1, 1 ); // quiet "did not check any assertions" warning
|
2021-07-31 15:31:38 +00:00
|
|
|
BOOST_TEST_MESSAGE( wxString::Format( "DRC regression: %s, passed", relPath ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-19 16:09:59 +00:00
|
|
|
UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES );
|
|
|
|
|
2021-07-31 15:31:38 +00:00
|
|
|
std::map<KIID, EDA_ITEM*> itemMap;
|
|
|
|
m_board->FillItemMap( itemMap );
|
2021-07-30 20:15:21 +00:00
|
|
|
|
2021-07-31 15:31:38 +00:00
|
|
|
for( const DRC_ITEM& item : violations )
|
|
|
|
{
|
2022-09-19 16:09:59 +00:00
|
|
|
BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, RPT_SEVERITY_ERROR,
|
2021-07-31 15:31:38 +00:00
|
|
|
itemMap ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_ERROR( wxString::Format( "DRC regression: %s, failed", relPath ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-31 19:12:52 +00:00
|
|
|
BOOST_FIXTURE_TEST_CASE( DRCFalseNegativeRegressions, DRC_REGRESSION_TEST_FIXTURE )
|
2021-07-31 15:31:38 +00:00
|
|
|
{
|
2023-07-07 18:03:09 +00:00
|
|
|
// These documents at one time failed to catch DRC errors that they should have
|
2021-07-31 15:31:38 +00:00
|
|
|
|
2022-06-15 09:55:25 +00:00
|
|
|
std::vector< std::pair<wxString, int> > tests =
|
|
|
|
{
|
2022-08-01 20:46:58 +00:00
|
|
|
{ "issue1358", 2 },
|
|
|
|
{ "issue2512", 5 },
|
|
|
|
{ "issue2528", 1 },
|
2023-07-21 18:09:18 +00:00
|
|
|
{ "issue5750", 2 }, // Shorting zone fills pass DRC in some cases
|
2022-08-01 20:46:58 +00:00
|
|
|
{ "issue5854", 3 },
|
2022-11-23 21:36:02 +00:00
|
|
|
{ "issue6879", 6 },
|
2022-08-01 20:46:58 +00:00
|
|
|
{ "issue6945", 2 },
|
|
|
|
{ "issue7241", 1 },
|
|
|
|
{ "issue7267", 4 },
|
2023-07-07 18:03:09 +00:00
|
|
|
{ "issue7325", 4 },
|
2022-08-01 20:46:58 +00:00
|
|
|
{ "issue8003", 2 },
|
|
|
|
{ "issue9081", 2 },
|
2023-07-07 18:03:09 +00:00
|
|
|
{ "issue12109", 8 }, // Pads fail annular width test
|
|
|
|
{ "issue14334", 2 }, // Thermal spoke to otherwise unconnected island
|
|
|
|
{ "reverse_via", 3 }, // Via/track ordering
|
2023-07-26 19:36:13 +00:00
|
|
|
{ "intersectingzones", 1 }, // zones are too close to each other
|
|
|
|
{ "fill_bad", 1 } // zone max BBox was too small
|
2023-07-07 02:23:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for( const std::pair<wxString, int>& entry : tests )
|
|
|
|
{
|
|
|
|
KI_TEST::LoadBoard( m_settingsManager, entry.first, m_board );
|
2023-07-07 18:03:09 +00:00
|
|
|
// Do not refill zones here because this is testing the DRC engine, not the zone filler
|
2023-07-07 02:23:28 +00:00
|
|
|
|
|
|
|
std::vector<DRC_ITEM> violations;
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
|
|
|
|
|
|
|
|
// Disable DRC tests not useful in this testcase
|
|
|
|
bds.m_DRCSeverities[ DRCE_COPPER_SLIVER ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
bds.m_DRCSeverities[ DRCE_LIB_FOOTPRINT_ISSUES ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
bds.m_DRCSeverities[ DRCE_LIB_FOOTPRINT_MISMATCH ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
|
2021-08-03 13:32:49 +00:00
|
|
|
bds.m_DRCEngine->SetViolationHandler(
|
2022-08-15 16:59:34 +00:00
|
|
|
[&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer )
|
2021-07-31 15:31:38 +00:00
|
|
|
{
|
2021-08-09 10:10:09 +00:00
|
|
|
PCB_MARKER temp( aItem, aPos );
|
|
|
|
|
|
|
|
if( bds.m_DrcExclusions.find( temp.Serialize() ) == bds.m_DrcExclusions.end() )
|
|
|
|
violations.push_back( *aItem );
|
2021-07-31 15:31:38 +00:00
|
|
|
} );
|
|
|
|
|
2021-08-03 13:32:49 +00:00
|
|
|
bds.m_DRCEngine->RunTests( EDA_UNITS::MILLIMETRES, true, false );
|
2021-07-31 15:31:38 +00:00
|
|
|
|
|
|
|
if( violations.size() == entry.second )
|
2021-07-30 20:15:21 +00:00
|
|
|
{
|
2021-08-03 13:32:49 +00:00
|
|
|
BOOST_CHECK_EQUAL( 1, 1 ); // quiet "did not check any assertions" warning
|
2021-07-31 15:31:38 +00:00
|
|
|
BOOST_TEST_MESSAGE( wxString::Format( "DRC regression: %s, passed", entry.first ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOST_CHECK_EQUAL( violations.size(), entry.second );
|
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES );
|
|
|
|
|
2021-07-30 20:15:21 +00:00
|
|
|
std::map<KIID, EDA_ITEM*> itemMap;
|
|
|
|
m_board->FillItemMap( itemMap );
|
|
|
|
|
|
|
|
for( const DRC_ITEM& item : violations )
|
2021-07-31 15:31:38 +00:00
|
|
|
{
|
2022-09-19 16:09:59 +00:00
|
|
|
BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, RPT_SEVERITY_ERROR,
|
2021-07-31 15:31:38 +00:00
|
|
|
itemMap ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_ERROR( wxString::Format( "DRC regression: %s, failed", entry.first ) );
|
2021-07-30 20:15:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|