|
KiCad PCB EDA Suite
|
#include <filesystem>#include <fstream>#include <memory>#include <sstream>#include <string>#include <pcbnew_utils/board_test_utils.h>#include <pcbnew_utils/board_file_utils.h>#include <qa_utils/wx_utils/unit_test_utils.h>#include <pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h>#include <board.h>#include <board_connected_item.h>#include <board_design_settings.h>#include <board_stackup_manager/board_stackup.h>#include <footprint.h>#include <netinfo.h>#include <pad.h>#include <pcb_shape.h>#include <zone.h>Go to the source code of this file.
Classes | |
| struct | KICAD_SEXPR_FIXTURE |
Functions | |
| BOOST_AUTO_TEST_CASE (Issue19775_ZoneLayerWildcards) | |
| Declares the struct as the Boost test fixture. | |
| BOOST_AUTO_TEST_CASE (Issue23125_EmptyZoneDiscarded) | |
| Verify that zones with no polygon outline are silently discarded during loading rather than being added to the board where they would cause crashes in GetPosition(). | |
| BOOST_AUTO_TEST_CASE (ScientificNotationLoading) | |
| Verify the parser still can read floating point values written in scientific notation. | |
| BOOST_AUTO_TEST_CASE (Issue23625_CorruptedStackupCapped) | |
| Verify that a corrupted file with thousands of stackup items does not crash KiCad. | |
| BOOST_AUTO_TEST_CASE (Issue23752_AppendBoardPreservesStackupAndGrowsToSixCopperLayers) | |
| Verify that append-board preserves the destination stackup while still growing it to match a source board with more copper layers. | |
| BOOST_AUTO_TEST_CASE (FootprintSave_OmitsNetsOnAllBoardConnectedItems) | |
| Regression for the footprint-save SIGSEGV observed in KiCad 10.0.0 (introduced by b335ce6e2c "Don't save netcodes to files", which switched PCB_SHAPE/PCB_TRACK/ZONE serialization from writing the netcode to writing the netname). | |
| BOOST_AUTO_TEST_CASE | ( | FootprintSave_OmitsNetsOnAllBoardConnectedItems | ) |
Regression for the footprint-save SIGSEGV observed in KiCad 10.0.0 (introduced by b335ce6e2c "Don't save netcodes to files", which switched PCB_SHAPE/PCB_TRACK/ZONE serialization from writing the netcode to writing the netname).
If a footprint's descendants carry m_netinfo pointers that belong to a different (possibly destroyed) board, the library serializer reads through those pointers and can SEGV inside BOARD_CONNECTED_ITEM::GetNetname().
The library-save path must (a) skip writing (net ...) tokens for pads/shapes/tracks/zones when CTL_OMIT_PAD_NETS is set (as it is under CTL_FOR_LIBRARY) and (b) orphan every BOARD_CONNECTED_ITEM descendant on the cloned footprint before serialization, so that any downstream code reading m_netinfo lands on the board-independent ORPHANED singleton.
This test exercises the library-save path with a footprint whose pad, copper shape and copper zone all reference a real net on a locally-built board. The emitted .kicad_mod must contain no "(net " tokens, and ClearAllNets() must orphan every connected item.
Definition at line 302 of file test_kicad_sexpr.cpp.
References FOOTPRINT::Add(), PADSTACK::ALL_LAYERS, BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), CIRCLE, FOOTPRINT::Clone(), F_Cu, FOOTPRINT, BOARD_CONNECTED_ITEM::GetNet(), NETINFO_LIST::OrphanedItem(), PAD, pad, PCB_PAD_T, PCB_SHAPE_T, PCB_ZONE_T, pcbIUScale, RECURSE, SEGMENT, EDA_SHAPE::SetEnd(), FOOTPRINT::SetFPID(), PCB_SHAPE::SetLayer(), ZONE::SetLayer(), BOARD_CONNECTED_ITEM::SetNet(), EDA_SHAPE::SetStart(), and EDA_ITEM::Type().
| BOOST_AUTO_TEST_CASE | ( | Issue19775_ZoneLayerWildcards | ) |
Declares the struct as the Boost test fixture.
Compare all footprints declared in a *.lbr file with their KiCad reference footprint
Definition at line 64 of file test_kicad_sexpr.cpp.
References B_Cu, BOOST_AUTO_TEST_CASE(), BOOST_TEST_CONTEXT(), LSET::Contains(), F_Cu, ZONE::GetFilledPolysList(), ZONE::GetLayerSet(), KI_TEST::GetPcbnewTestDataDir(), ZONE::LayerProperties(), and SHAPE_POLY_SET::TotalVertices().
| BOOST_AUTO_TEST_CASE | ( | Issue23125_EmptyZoneDiscarded | ) |
Verify that zones with no polygon outline are silently discarded during loading rather than being added to the board where they would cause crashes in GetPosition().
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23125
Definition at line 121 of file test_kicad_sexpr.cpp.
References BOOST_CHECK_EQUAL(), ZONE::GetNumCorners(), KI_TEST::GetPcbnewTestDataDir(), and ZONE::GetPosition().
| BOOST_AUTO_TEST_CASE | ( | Issue23625_CorruptedStackupCapped | ) |
Verify that a corrupted file with thousands of stackup items does not crash KiCad.
The parser should silently cap the stackup item count.
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23625
Definition at line 173 of file test_kicad_sexpr.cpp.
References BOARD_STACKUP::GetCount(), and KI_TEST::GetPcbnewTestDataDir().
| BOOST_AUTO_TEST_CASE | ( | Issue23752_AppendBoardPreservesStackupAndGrowsToSixCopperLayers | ) |
Verify that append-board preserves the destination stackup while still growing it to match a source board with more copper layers.
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23752
Definition at line 200 of file test_kicad_sexpr.cpp.
References PCB_IO_LOAD_PROPERTIES::APPEND_PRESERVE_DESTINATION_STACKUP, BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), BS_ITEM_TYPE_COPPER, BS_ITEM_TYPE_DIELECTRIC, BOARD_STACKUP_ITEM::GetMaterial(), KI_TEST::GetPcbnewTestDataDir(), BOARD_STACKUP_ITEM::GetThickness(), and BOARD_STACKUP::m_FinishType.
| BOOST_AUTO_TEST_CASE | ( | ScientificNotationLoading | ) |
Verify the parser still can read floating point values written in scientific notation.
Even though the KiCad file writter doesn't write using scientific notation anymore, at one point it did, so the parser must still support reading it.
Definition at line 146 of file test_kicad_sexpr.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), BOOST_TEST(), EDA_SHAPE::GetArcMid(), KI_TEST::GetPcbnewTestDataDir(), VECTOR2< T >::x, and VECTOR2< T >::y.