23#include <wx/filename.h>
65 std::unique_ptr<KI_TEST::SCOPED_TEMP_DIR>
m_ruleDir;
68 void setRule(
const std::string& aConstraint,
const std::string& aCondition =
"",
69 const std::string& aSeverity =
"" )
71 m_ruleDir = std::make_unique<KI_TEST::SCOPED_TEMP_DIR>(
"microvia_rule" );
73 wxFileName rulePath(
m_ruleDir->PathStr(),
"test.kicad_dru" );
76 std::ofstream dru( rulePath.GetFullPath().ToStdString() );
77 dru <<
"(version 1)\n"
78 <<
"(rule \"via stack limits\"\n";
80 if( !aCondition.empty() )
81 dru <<
" (condition \"" << aCondition <<
"\")\n";
83 if( !aSeverity.empty() )
84 dru <<
" (severity " << aSeverity <<
")\n";
86 dru <<
" (constraint " << aConstraint <<
")\n"
103 const std::string boardName = boost::unit_test::framework::current_test_case().p_name.get();
131 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
134 switch( aItem->GetErrorCode() )
156 via->SetLayerPair( aTop, aBottom );
159 via->SetPosition( aPos );
160 via->Padstack().Drill().is_filled = aFilled;
171 via->SetViaType( aType );
172 via->SetLayerPair( aTop, aBottom );
174 via->SetDrill( aDrill );
175 via->SetPosition( aPos );
186 aBoard->
Add( footprint );
191 pad->SetPosition( aPos );
195 pad->SetDrillSize( aDrill );
208 aBoard->
Add( stack );
219 m_board = std::make_unique<BOARD>();
220 m_board->SetCopperLayerCount( 4 );
227 setRule(
"hole_aspect_ratio (max 1.0)" );
234 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
266 m_board = std::make_unique<BOARD>();
267 m_board->SetCopperLayerCount( 4 );
301 setRule(
"microvia_stack_depth (max 1)" );
324 setRule(
"microvia_stack_depth (max 2)" );
337 setRule(
"microvia_stack_depth (max 1)" );
408 m_board = std::make_unique<BOARD>();
409 m_board->SetCopperLayerCount( 6 );
416 setRule(
"hole_aspect_ratio (max 1.0)" );
429 m_board = std::make_unique<BOARD>();
430 m_board->SetCopperLayerCount( 6 );
447 setRule(
"hole_aspect_ratio (max 1.0)" );
459 m_board = std::make_unique<BOARD>();
460 m_board->SetCopperLayerCount( 6 );
467 setRule(
"hole_aspect_ratio (max 1.0)" );
481 m_board = std::make_unique<BOARD>();
482 m_board->SetCopperLayerCount( 4 );
485 BOOST_REQUIRE( m_board->GetDesignSettings().GetStackupDescriptor().GetList().empty() );
487 setRule(
"hole_aspect_ratio (max 0.5)" );
502 setRule(
"microvia_stack_depth (max 2)" );
508 setRule(
"microvia_stack_depth (max 4)" );
516 setRule(
"microvia_stack_depth (max 2)",
"A.isStackedVia()" );
519 BOOST_CHECK_MESSAGE( m_depth == 1,
"the rule condition did not select the stack" );
525 m_board = std::make_unique<BOARD>();
526 m_board->SetCopperLayerCount( 4 );
533 setRule(
"microvia_stack_depth (max 1)",
"",
"ignore" );
543 m_board = std::make_unique<BOARD>();
544 m_board->SetCopperLayerCount( 4 );
553 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
558 setRule(
"hole_aspect_ratio (max 0.1)",
"",
"ignore" );
575 BOOST_CHECK_MESSAGE( m_notFilled == 0,
"3 vias produced " << m_notFilled <<
" violations" );
582 m_board = std::make_unique<BOARD>();
583 m_board->SetCopperLayerCount( 6 );
597 item->AddDielectricPrms( 1 );
598 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ), 0 );
599 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ), 1 );
604 setRule(
"hole_aspect_ratio (max 1.2)" );
610 BOOST_CHECK_MESSAGE( m_aspect == 1,
"both sublayers must count toward the via depth" );
617 m_board = std::make_unique<BOARD>();
618 m_board->SetCopperLayerCount( 6 );
634 bool outer = item->GetBrdLayerId() ==
F_Cu || item->GetBrdLayerId() ==
B_Cu;
635 item->SetThickness(
pcbIUScale.mmToIU( outer ? 0.035 : 0.0175 ) );
638 for(
int i = (
int) stack.size() - 1; i >= 0; --i )
642 stack[i]->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
649 setRule(
"hole_aspect_ratio (max 1.25)" );
657 BOOST_CHECK_MESSAGE( m_aspect == 1,
"a back-side microvia must be measured through the B.Cu foil" );
668 BOOST_CHECK_MESSAGE( m_notFilled == 0,
"board default is filled, but got " << m_notFilled <<
" not-filled errors" );
699 m_board = std::make_unique<BOARD>();
700 m_board->SetCopperLayerCount( 6 );
715 for(
size_t i = 0; i < stack.size(); ++i )
719 lastCopper = stack[i]->GetBrdLayerId();
728 for(
size_t j = i + 1; j < stack.size(); ++j )
732 below = stack[j]->GetBrdLayerId();
739 coreTop = lastCopper;
744 pregTop = lastCopper;
755 makeMicrovia( m_board.get(), overCore, coreTop, coreBot,
true );
756 makeMicrovia( m_board.get(), overPrepreg, pregTop, pregBot,
true );
780 m_board = std::make_unique<BOARD>();
781 m_board->SetCopperLayerCount( 6 );
790 setRule(
"hole_aspect_ratio (max 0.1)" );
796 for(
size_t i = 0; i < stack.size(); ++i )
800 lastCopper = stack[i]->GetBrdLayerId();
807 coreTop = lastCopper;
809 for(
size_t j = i + 1; j < stack.size(); ++j )
813 coreBot = stack[j]->GetBrdLayerId();
828 BOOST_CHECK_MESSAGE( m_crossesCore == 2,
"the walk stopped early, only " << m_crossesCore <<
" reported" );
843 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
848 item->SetThickness(
pcbIUScale.mmToIU( 0.035 ) );
856 m_board = std::make_unique<BOARD>();
857 m_board->SetCopperLayerCount( 4 );
861 setRule(
"hole_aspect_ratio (max 6.0)" );
876 m_board = std::make_unique<BOARD>();
877 m_board->SetCopperLayerCount( 4 );
881 setRule(
"hole_aspect_ratio (max 6.0)" );
894 m_board = std::make_unique<BOARD>();
895 m_board->SetCopperLayerCount( 4 );
899 setRule(
"hole_aspect_ratio (max 6.0)" );
916 m_board = std::make_unique<BOARD>();
917 m_board->SetCopperLayerCount( 4 );
921 setRule(
"hole_aspect_ratio (max 1.0)",
"A.Via_Type == 'Micro'" );
936 m_board = std::make_unique<BOARD>();
937 m_board->SetCopperLayerCount( 4 );
941 setRule(
"hole_aspect_ratio (max 3.0)" );
954 m_board = std::make_unique<BOARD>();
955 m_board->SetCopperLayerCount( 4 );
959 setRule(
"hole_aspect_ratio (max 6.0)" );
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
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.
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
std::unique_ptr< KI_TEST::SCOPED_TEMP_DIR > m_ruleDir
BOOST_FIXTURE_TEST_CASE(ServerStartsAndResponds, API_SERVER_E2E_FIXTURE)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
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 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_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I