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 =
"",
67 const std::string& aSeverity =
"" )
69 m_ruleDir = std::make_unique<KI_TEST::SCOPED_TEMP_DIR>(
"microvia_rule" );
71 wxFileName rulePath(
m_ruleDir->PathStr(),
"test.kicad_dru" );
74 std::ofstream dru( rulePath.GetFullPath().ToStdString() );
75 dru <<
"(version 1)\n"
76 <<
"(rule \"via stack limits\"\n";
78 if( !aCondition.empty() )
79 dru <<
" (condition \"" << aCondition <<
"\")\n";
81 if( !aSeverity.empty() )
82 dru <<
" (severity " << aSeverity <<
")\n";
84 dru <<
" (constraint " << aConstraint <<
")\n"
103 + boost::unit_test::framework::current_test_case().p_name.get()
132 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
135 switch( aItem->GetErrorCode() )
157 via->SetLayerPair( aTop, aBottom );
160 via->SetPosition( aPos );
161 via->Padstack().Drill().is_filled = aFilled;
174 aBoard->
Add( stack );
185 m_board = std::make_unique<BOARD>();
186 m_board->SetCopperLayerCount( 4 );
192 setRule(
"microvia_aspect_ratio (max 1.0)" );
199 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
231 m_board = std::make_unique<BOARD>();
232 m_board->SetCopperLayerCount( 4 );
266 setRule(
"microvia_stack_depth (max 1)" );
289 setRule(
"microvia_stack_depth (max 2)" );
302 setRule(
"microvia_stack_depth (max 1)" );
373 m_board = std::make_unique<BOARD>();
374 m_board->SetCopperLayerCount( 6 );
380 setRule(
"microvia_aspect_ratio (max 1.0)" );
393 m_board = std::make_unique<BOARD>();
394 m_board->SetCopperLayerCount( 6 );
410 setRule(
"microvia_aspect_ratio (max 1.0)" );
422 m_board = std::make_unique<BOARD>();
423 m_board->SetCopperLayerCount( 6 );
429 setRule(
"microvia_aspect_ratio (max 1.0)" );
445 m_board = std::make_unique<BOARD>();
446 m_board->SetCopperLayerCount( 4 );
450 setRule(
"microvia_aspect_ratio (max 0.5)" );
464 BOOST_CHECK_MESSAGE( m_aspect == 1,
"with thicknesses present the limit must apply" );
472 setRule(
"microvia_stack_depth (max 2)" );
478 setRule(
"microvia_stack_depth (max 4)" );
486 setRule(
"microvia_stack_depth (max 2)",
"A.isStackedVia()" );
489 BOOST_CHECK_MESSAGE( m_depth == 1,
"the rule condition did not select the stack" );
495 m_board = std::make_unique<BOARD>();
496 m_board->SetCopperLayerCount( 4 );
503 setRule(
"microvia_stack_depth (max 1)",
"",
"ignore" );
513 m_board = std::make_unique<BOARD>();
514 m_board->SetCopperLayerCount( 4 );
523 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
528 setRule(
"microvia_aspect_ratio (max 0.1)",
"",
"ignore" );
545 BOOST_CHECK_MESSAGE( m_notFilled == 0,
"3 vias produced " << m_notFilled <<
" violations" );
552 m_board = std::make_unique<BOARD>();
553 m_board->SetCopperLayerCount( 6 );
566 item->AddDielectricPrms( 1 );
567 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ), 0 );
568 item->SetThickness(
pcbIUScale.mmToIU( 0.1 ), 1 );
573 setRule(
"microvia_aspect_ratio (max 1.2)" );
579 BOOST_CHECK_MESSAGE( m_aspect == 1,
"both sublayers must count toward the via depth" );
586 m_board = std::make_unique<BOARD>();
587 m_board->SetCopperLayerCount( 6 );
602 bool outer = item->GetBrdLayerId() ==
F_Cu || item->GetBrdLayerId() ==
B_Cu;
603 item->SetThickness(
pcbIUScale.mmToIU( outer ? 0.035 : 0.0175 ) );
606 for(
int i = (
int) stack.size() - 1; i >= 0; --i )
610 stack[i]->SetThickness(
pcbIUScale.mmToIU( 0.1 ) );
617 setRule(
"microvia_aspect_ratio (max 1.25)" );
625 BOOST_CHECK_MESSAGE( m_aspect == 1,
"a back-side microvia must be measured through the B.Cu foil" );
636 BOOST_CHECK_MESSAGE( m_notFilled == 0,
"board default is filled, but got " << m_notFilled <<
" not-filled errors" );
667 m_board = std::make_unique<BOARD>();
668 m_board->SetCopperLayerCount( 6 );
682 for(
size_t i = 0; i < stack.size(); ++i )
686 lastCopper = stack[i]->GetBrdLayerId();
695 for(
size_t j = i + 1; j < stack.size(); ++j )
699 below = stack[j]->GetBrdLayerId();
706 coreTop = lastCopper;
711 pregTop = lastCopper;
722 makeMicrovia( m_board.get(), overCore, coreTop, coreBot,
true );
723 makeMicrovia( m_board.get(), overPrepreg, pregTop, pregBot,
true );
747 m_board = std::make_unique<BOARD>();
748 m_board->SetCopperLayerCount( 6 );
756 setRule(
"microvia_aspect_ratio (max 0.1)" );
762 for(
size_t i = 0; i < stack.size(); ++i )
766 lastCopper = stack[i]->GetBrdLayerId();
773 coreTop = lastCopper;
775 for(
size_t j = i + 1; j < stack.size(); ++j )
779 coreBot = stack[j]->GetBrdLayerId();
794 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.
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
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
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)
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