23#include <wx/filename.h>
63 std::unique_ptr<KI_TEST::SCOPED_TEMP_DIR>
m_ruleDir;
66 void setRule(
const std::string& aConstraint,
const std::string& aCondition =
"" )
68 m_ruleDir = std::make_unique<KI_TEST::SCOPED_TEMP_DIR>(
"microvia_rule" );
70 wxFileName rulePath(
m_ruleDir->PathStr(),
"test.kicad_dru" );
73 std::ofstream dru( rulePath.GetFullPath().ToStdString() );
74 dru <<
"(version 1)\n"
75 <<
"(rule \"via stack limits\"\n";
77 if( !aCondition.empty() )
78 dru <<
" (condition \"" << aCondition <<
"\")\n";
80 dru <<
" (constraint " << aConstraint <<
")\n"
99 + boost::unit_test::framework::current_test_case().p_name.get()
128 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
131 switch( aItem->GetErrorCode() )
153 via->SetLayerPair( aTop, aBottom );
156 via->SetPosition( aPos );
157 via->Padstack().Drill().is_filled = aFilled;
170 aBoard->
Add( stack );
181 m_board = std::make_unique<BOARD>();
182 m_board->SetCopperLayerCount( 4 );
188 setRule(
"microvia_aspect_ratio (max 1.0)" );
195 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
240 setRule(
"microvia_stack_depth (max 1)" );
263 setRule(
"microvia_stack_depth (max 2)" );
276 setRule(
"microvia_stack_depth (max 1)" );
347 m_board = std::make_unique<BOARD>();
348 m_board->SetCopperLayerCount( 6 );
354 setRule(
"microvia_aspect_ratio (max 1.0)" );
367 m_board = std::make_unique<BOARD>();
368 m_board->SetCopperLayerCount( 6 );
384 setRule(
"microvia_aspect_ratio (max 1.0)" );
396 m_board = std::make_unique<BOARD>();
397 m_board->SetCopperLayerCount( 6 );
403 setRule(
"microvia_aspect_ratio (max 1.0)" );
419 m_board = std::make_unique<BOARD>();
420 m_board->SetCopperLayerCount( 4 );
424 setRule(
"microvia_aspect_ratio (max 0.5)" );
438 BOOST_CHECK_MESSAGE( m_aspect == 1,
"with thicknesses present the limit must apply" );
446 setRule(
"microvia_stack_depth (max 2)" );
452 setRule(
"microvia_stack_depth (max 4)" );
460 setRule(
"microvia_stack_depth (max 2)",
"A.isStackedVia()" );
463 BOOST_CHECK_MESSAGE( m_depth == 1,
"the rule condition did not select the stack" );
476 BOOST_CHECK_MESSAGE( m_notFilled == 0,
"3 vias produced " << m_notFilled <<
" violations" );
483 m_board = std::make_unique<BOARD>();
484 m_board->SetCopperLayerCount( 6 );
497 item->AddDielectricPrms( 1 );
498 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ), 0 );
499 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ), 1 );
504 setRule(
"microvia_aspect_ratio (max 1.2)" );
510 BOOST_CHECK_MESSAGE( m_aspect == 1,
"both sublayers must count toward the via depth" );
517 m_board = std::make_unique<BOARD>();
518 m_board->SetCopperLayerCount( 6 );
533 bool outer = item->GetBrdLayerId() ==
F_Cu || item->GetBrdLayerId() ==
B_Cu;
534 item->SetThickness(
pcbIUScale.mmToIU( outer ? 0.035 : 0.0175 ) );
537 for(
int i = (
int) stack.size() - 1; i >= 0; --i )
541 stack[i]->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
548 setRule(
"microvia_aspect_ratio (max 1.25)" );
556 BOOST_CHECK_MESSAGE( m_aspect == 1,
"a back-side microvia must be measured through the B.Cu foil" );
567 BOOST_CHECK_MESSAGE( m_notFilled == 0,
"board default is filled, but got " << m_notFilled <<
" not-filled errors" );
598 m_board = std::make_unique<BOARD>();
599 m_board->SetCopperLayerCount( 6 );
613 for(
size_t i = 0; i < stack.size(); ++i )
617 lastCopper = stack[i]->GetBrdLayerId();
626 for(
size_t j = i + 1; j < stack.size(); ++j )
630 below = stack[j]->GetBrdLayerId();
637 coreTop = lastCopper;
642 pregTop = lastCopper;
653 makeMicrovia( m_board.get(), overCore, coreTop, coreBot,
true );
654 makeMicrovia( m_board.get(), overPrepreg, pregTop, pregBot,
true );
678 m_board = std::make_unique<BOARD>();
679 m_board->SetCopperLayerCount( 6 );
687 setRule(
"microvia_aspect_ratio (max 0.1)" );
693 for(
size_t i = 0; i < stack.size(); ++i )
697 lastCopper = stack[i]->GetBrdLayerId();
704 coreTop = lastCopper;
706 for(
size_t j = i + 1; j < stack.size(); ++j )
710 coreBot = stack[j]->GetBrdLayerId();
725 BOOST_CHECK_MESSAGE( m_crossesCore == 2,
"the walk stopped early, only " << m_crossesCore <<
" reported" );
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.
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
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_ASPECT_RATIO
@ DRCE_MICROVIA_STACK_NOT_FILLED
PCB_LAYER_ID
A quick note on layer IDs:
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
std::unique_ptr< BOARD > m_board
SETTINGS_MANAGER m_settingsManager
std::vector< int > m_ignored
void setRule(const std::string &aConstraint, const std::string &aCondition="")
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)
BOOST_FIXTURE_TEST_CASE(GoodStackNoViolations, VIA_STACK_DRC_FIXTURE)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I