23#include <wx/filename.h>
68 std::unique_ptr<KI_TEST::SCOPED_TEMP_DIR>
m_ruleDir;
71 void setRule(
const std::string& aConstraint,
const std::string& aCondition =
"",
72 const std::string& aSeverity =
"" )
74 m_ruleDir = std::make_unique<KI_TEST::SCOPED_TEMP_DIR>(
"microvia_rule" );
76 wxFileName rulePath(
m_ruleDir->PathStr(),
"test.kicad_dru" );
79 std::ofstream dru( rulePath.GetFullPath().ToStdString() );
80 dru <<
"(version 1)\n"
81 <<
"(rule \"via stack limits\"\n";
83 if( !aCondition.empty() )
84 dru <<
" (condition \"" << aCondition <<
"\")\n";
86 if( !aSeverity.empty() )
87 dru <<
" (severity " << aSeverity <<
")\n";
89 dru <<
" (constraint " << aConstraint <<
")\n"
98 m_board = std::make_unique<BOARD>();
99 m_board->SetCopperLayerCount( aCopperLayers );
131 const std::string boardName = boost::unit_test::framework::current_test_case().p_name.get();
160 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
163 switch( aItem->GetErrorCode() )
192 via->SetLayerPair( aTop, aBottom );
195 via->SetPosition( aPos );
196 via->Padstack().Drill().is_filled = aFilled;
207 via->SetViaType( aType );
208 via->SetLayerPair( aTop, aBottom );
210 via->SetDrill( aDrill );
211 via->SetPosition( aPos );
222 aBoard->
Add( footprint );
227 pad->SetPosition( aPos );
231 pad->SetDrillSize( aDrill );
244 aBoard->
Add( stack );
255 m_board = std::make_unique<BOARD>();
256 m_board->SetCopperLayerCount( 4 );
263 setRule(
"hole_aspect_ratio (max 1.0)" );
270 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
302 m_board = std::make_unique<BOARD>();
303 m_board->SetCopperLayerCount( 4 );
337 setRule(
"microvia_stack_depth (max 1)" );
360 setRule(
"microvia_stack_depth (max 2)" );
373 setRule(
"microvia_stack_depth (max 1)" );
444 m_board = std::make_unique<BOARD>();
445 m_board->SetCopperLayerCount( 6 );
452 setRule(
"hole_aspect_ratio (max 1.0)" );
465 m_board = std::make_unique<BOARD>();
466 m_board->SetCopperLayerCount( 6 );
483 setRule(
"hole_aspect_ratio (max 1.0)" );
495 m_board = std::make_unique<BOARD>();
496 m_board->SetCopperLayerCount( 6 );
503 setRule(
"hole_aspect_ratio (max 1.0)" );
517 m_board = std::make_unique<BOARD>();
518 m_board->SetCopperLayerCount( 4 );
521 BOOST_REQUIRE( m_board->GetDesignSettings().GetStackupDescriptor().GetList().empty() );
523 setRule(
"hole_aspect_ratio (max 0.5)" );
538 setRule(
"microvia_stack_depth (max 2)" );
544 setRule(
"microvia_stack_depth (max 4)" );
552 setRule(
"microvia_stack_depth (max 2)",
"A.isStackedVia()" );
555 BOOST_CHECK_MESSAGE( m_depth == 1,
"the rule condition did not select the stack" );
561 m_board = std::make_unique<BOARD>();
562 m_board->SetCopperLayerCount( 4 );
569 setRule(
"microvia_stack_depth (max 1)",
"",
"ignore" );
579 m_board = std::make_unique<BOARD>();
580 m_board->SetCopperLayerCount( 4 );
589 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
594 setRule(
"hole_aspect_ratio (max 0.1)",
"",
"ignore" );
611 BOOST_CHECK_MESSAGE( m_notFilled == 0,
"3 vias produced " << m_notFilled <<
" violations" );
618 m_board = std::make_unique<BOARD>();
619 m_board->SetCopperLayerCount( 6 );
633 item->AddDielectricPrms( 1 );
634 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ), 0 );
635 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ), 1 );
640 setRule(
"hole_aspect_ratio (max 1.2)" );
646 BOOST_CHECK_MESSAGE( m_aspect == 1,
"both sublayers must count toward the via depth" );
653 m_board = std::make_unique<BOARD>();
654 m_board->SetCopperLayerCount( 6 );
670 bool outer = item->GetBrdLayerId() ==
F_Cu || item->GetBrdLayerId() ==
B_Cu;
671 item->SetThickness(
pcbIUScale.mmToIU( outer ? 0.035 : 0.0175 ) );
674 for(
int i = (
int) stack.size() - 1; i >= 0; --i )
678 stack[i]->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
685 setRule(
"hole_aspect_ratio (max 1.25)" );
693 BOOST_CHECK_MESSAGE( m_aspect == 1,
"a back-side microvia must be measured through the B.Cu foil" );
704 BOOST_CHECK_MESSAGE( m_notFilled == 0,
"board default is filled, but got " << m_notFilled <<
" not-filled errors" );
735 m_board = std::make_unique<BOARD>();
736 m_board->SetCopperLayerCount( 6 );
751 for(
size_t i = 0; i < stack.size(); ++i )
755 lastCopper = stack[i]->GetBrdLayerId();
764 for(
size_t j = i + 1; j < stack.size(); ++j )
768 below = stack[j]->GetBrdLayerId();
775 coreTop = lastCopper;
780 pregTop = lastCopper;
791 makeMicrovia( m_board.get(), overCore, coreTop, coreBot,
true );
792 makeMicrovia( m_board.get(), overPrepreg, pregTop, pregBot,
true );
816 m_board = std::make_unique<BOARD>();
817 m_board->SetCopperLayerCount( 6 );
826 setRule(
"hole_aspect_ratio (max 0.1)" );
832 for(
size_t i = 0; i < stack.size(); ++i )
836 lastCopper = stack[i]->GetBrdLayerId();
843 coreTop = lastCopper;
845 for(
size_t j = i + 1; j < stack.size(); ++j )
849 coreBot = stack[j]->GetBrdLayerId();
864 BOOST_CHECK_MESSAGE( m_crossesCore == 2,
"the walk stopped early, only " << m_crossesCore <<
" reported" );
879 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
884 item->SetThickness(
pcbIUScale.mmToIU( 0.035 ) );
892 m_board = std::make_unique<BOARD>();
893 m_board->SetCopperLayerCount( 4 );
897 setRule(
"hole_aspect_ratio (max 6.0)" );
912 m_board = std::make_unique<BOARD>();
913 m_board->SetCopperLayerCount( 4 );
917 setRule(
"hole_aspect_ratio (max 6.0)" );
930 m_board = std::make_unique<BOARD>();
931 m_board->SetCopperLayerCount( 4 );
935 setRule(
"hole_aspect_ratio (max 6.0)" );
952 m_board = std::make_unique<BOARD>();
953 m_board->SetCopperLayerCount( 4 );
957 setRule(
"hole_aspect_ratio (max 1.0)",
"A.Via_Type == 'Micro'" );
972 m_board = std::make_unique<BOARD>();
973 m_board->SetCopperLayerCount( 4 );
977 setRule(
"hole_aspect_ratio (max 3.0)" );
990 m_board = std::make_unique<BOARD>();
991 m_board->SetCopperLayerCount( 4 );
995 setRule(
"hole_aspect_ratio (max 6.0)" );
1012 makeBuildUpStackup();
1021 BOOST_CHECK( m_spanMessage.Contains( wxT(
"2 dielectrics" ) ) );
1032 makeBuildUpStackup();
1058 BOOST_CHECK( m_spanMessage.Contains( wxT(
"3 dielectrics" ) ) );
1098 makeBuildUpStackup();
1117 makeBuildUpStackup();
1126 BOOST_CHECK( m_spanMessage.Contains( wxT(
"2 dielectrics" ) ) );
1133 makeBuildUpStackup();
constexpr EDA_IU_SCALE pcbIUScale
General utilities for PCB file IO for QA programs.
@ BS_ITEM_TYPE_DIELECTRIC
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
BOARD_STACKUP & GetStackupDescriptor()
void SetCopperLayerCount(int aNewLayerCount)
Set the copper layer count to aNewLayerCount.
Manage one layer needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void RunTests(EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints, BOARD_COMMIT *aCommit=nullptr)
Run the DRC tests.
void SetViolationHandler(DRC_VIOLATION_HANDLER aHandler)
Set an optional DRC violation handler (receives DRC_ITEMs and positions).
void ClearViolationHandler()
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
void AddItem(EDA_ITEM *aItem)
Add item to group.
static const LSET & AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
static LSET PTHMask()
layer set for a through hole pad
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
void SetPosition(const VECTOR2I &aPos) override
A microvia stack: several single hop microvias, plus connecting traces for staggered stacks,...
void Regenerate(BOARD *aBoard, BOARD_COMMIT *aCommit)
Rebuild the member vias (and, for a staggered stack, the connecting traces) from the current stack se...
void SetStartLayer(PCB_LAYER_ID aLayer)
void SetViaSize(int aSize)
void SetViaDrill(int aDrill)
void SetStyle(VIA_STACK_STYLE aStyle)
void SetEndLayer(PCB_LAYER_ID aLayer)
@ DRCE_MICROVIA_STACK_DEPTH
@ DRCE_MICROVIA_CROSSES_CORE
@ DRCE_MALFORMED_MICROVIA_STACK_SPAN
@ DRCE_MICROVIA_STACK_NOT_FILLED
@ DRCE_MICROVIA_SPANS_DIELECTRICS
PCB_LAYER_ID
A quick note on layer IDs:
std::unique_ptr< BOARD > RequireBoardFromPcbnewQAData(const std::filesystem::path &aFilename)
Require a board from the path relative to the pcbnew QA data directory.
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ PTH
Plated through hole pad.
void buildBoard(int aCopperLayers)
std::unique_ptr< BOARD > m_board
SETTINGS_MANAGER m_settingsManager
void setRule(const std::string &aConstraint, const std::string &aCondition="", const std::string &aSeverity="")
std::vector< int > m_ignored
void makeBuildUpStackup()
std::unique_ptr< KI_TEST::SCOPED_TEMP_DIR > m_ruleDir
BOOST_FIXTURE_TEST_CASE(ServerStartsAndResponds, API_SERVER_E2E_FIXTURE)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
static PCB_VIA_STACK * makeStack(BOARD *aBoard, PCB_LAYER_ID aStart, PCB_LAYER_ID aEnd)
static PCB_VIA * makeMicrovia(BOARD *aBoard, const VECTOR2I &aPos, PCB_LAYER_ID aTop, PCB_LAYER_ID aBottom, bool aFilled)
static PCB_VIA * makeVia(BOARD *aBoard, const VECTOR2I &aPos, VIATYPE aType, PCB_LAYER_ID aTop, PCB_LAYER_ID aBottom, int aDrill)
static const VECTOR2I VIA_POS(pcbIUScale.mmToIU(10), pcbIUScale.mmToIU(10))
static PAD * makePthPad(BOARD *aBoard, const VECTOR2I &aPos, const VECTOR2I &aDrill)
BOOST_FIXTURE_TEST_CASE(GoodStackNoViolations, VIA_STACK_DRC_FIXTURE)
static void setUniformStackup(BOARD_DESIGN_SETTINGS &bds)
BOOST_AUTO_TEST_SUITE_END()
VECTOR2< int32_t > VECTOR2I