KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_ipc2581_export.cpp File Reference

Test suite for IPC-2581 export validation. More...

#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/ipc2581/pcb_io_ipc2581.h>
#include <pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h>
#include <board.h>
#include <board_design_settings.h>
#include <board_stackup_manager/board_stackup.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_track.h>
#include <base_units.h>
#include <wx/dir.h>
#include <wx/file.h>
#include <wx/filename.h>
#include <wx/process.h>
#include <wx/txtstrm.h>
#include <fstream>
#include <sstream>

Go to the source code of this file.

Classes

struct  IPC2581_EXPORT_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (SurfaceFinishExport)
 Test that surface finish is exported correctly (Issue #22690)
 
 BOOST_AUTO_TEST_CASE (NoSurfaceFinishExport)
 Test that boards without surface finish don't generate coating layers.
 
 BOOST_AUTO_TEST_CASE (SchemaValidationVersionB)
 Validate IPC-2581B export against schema for multiple boards.
 
 BOOST_AUTO_TEST_CASE (SchemaValidationVersionC)
 Validate IPC-2581C export against schema for multiple boards.
 
 BOOST_AUTO_TEST_CASE (ComplexBoardExport)
 Test export of boards with complex features.
 
 BOOST_AUTO_TEST_CASE (SmdPadSolderMaskExport_Issue16658)
 Test that SMD pad solder mask openings are exported (Issue #16658)
 
, or PinRef/@componentRef attributes, which are

Test that footprints with empty references produce valid XML attributes.

Footprints with blank GetReference() must not produce empty refDes, RefDes/ schema-invalid qualified names.

 BOOST_AUTO_TEST_CASE (EmptyRefDesProducesValidXml)
 
 BOOST_AUTO_TEST_CASE (FlippedComponentRotation)
 Test that flipped component rotation is not inverted (Finding A / Issue #18013)
 
 BOOST_AUTO_TEST_CASE (ContentBomRef)
 Test that Content section includes BomRef when BOM is emitted.
 
 BOOST_AUTO_TEST_CASE (KnockoutTextMultiContour_Issue23968)
 Test that knockout text with holes emits schema-valid XML (Issue #23968)
 
 BOOST_AUTO_TEST_CASE (BackdrillSpecEncoding)
 Verify IPC-2581 backdrill encoding matches the schema and expresses the correct must-not-cut layer.
 

Detailed Description

Test suite for IPC-2581 export validation.

Tests per GitLab issues:

  • #22690: Surface finish data not exported
  • #19912: OtherSideView may be incorrect for bottom components

Definition in file test_ipc2581_export.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/11]

BOOST_AUTO_TEST_CASE ( BackdrillSpecEncoding )

Verify IPC-2581 backdrill encoding matches the schema and expresses the correct must-not-cut layer.

KiCad's PADSTACK::DRILL_PROPS::end is the must-cut layer (per the UI "must-cut" labels). The IPC-2581 standard expects the must-not-cut layer, which is the next signal layer past the must-cut layer. The exporter must emit one Spec containing three sibling Backdrill children with type START_LAYER, MUST_NOT_CUT_LAYER, and MAX_STUB_LENGTH, each carrying its value in a Property child.

Definition at line 688 of file test_ipc2581_export.cpp.

References BOARD::Add(), B_Cu, BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), BOARD_STACKUP::BuildDefaultStackupList(), COUNTERSINK, F_Cu, BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), In3_Cu, pcbIUScale, BOARD::SetCopperLayerCount(), and via.

◆ BOOST_AUTO_TEST_CASE() [2/11]

BOOST_AUTO_TEST_CASE ( ComplexBoardExport )

Test export of boards with complex features.

Tests boards with zones, custom pads, and other features that may exercise edge cases in the IPC-2581 exporter.

Definition at line 418 of file test_ipc2581_export.cpp.

References BOOST_CHECK_MESSAGE(), and BOOST_TEST_CONTEXT().

◆ BOOST_AUTO_TEST_CASE() [3/11]

BOOST_AUTO_TEST_CASE ( ContentBomRef )

Test that Content section includes BomRef when BOM is emitted.

Definition at line 616 of file test_ipc2581_export.cpp.

References BOOST_CHECK_MESSAGE(), and BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [4/11]

BOOST_AUTO_TEST_CASE ( EmptyRefDesProducesValidXml )

◆ BOOST_AUTO_TEST_CASE() [5/11]

BOOST_AUTO_TEST_CASE ( FlippedComponentRotation )

Test that flipped component rotation is not inverted (Finding A / Issue #18013)

IPC-2581C 3.3.2 defines positive rotation as CCW from board top. mirror="true" handles the X-axis negation for bottom components. The component rotation must be the normalized board-top angle, NOT its inverse.

Definition at line 571 of file test_ipc2581_export.cpp.

References BOOST_CHECK_MESSAGE(), and BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [6/11]

BOOST_AUTO_TEST_CASE ( KnockoutTextMultiContour_Issue23968 )

Test that knockout text with holes emits schema-valid XML (Issue #23968)

Knockout text renders as a filled polygon with each glyph contour becoming a separate outline. The IPC-2581 FeaturesType allows only one Feature child, so when a knockout text produces more than one Contour it must be wrapped in a UserSpecial (which itself is a Feature that may contain any number of child Features).

test_copper_graphics.kicad_pcb contains a knockout text "Otherwise" on B.Cu, whose 'O' glyph produces two contours (outer and inner), which reproduces the multi-contour case.

Definition at line 655 of file test_ipc2581_export.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), and BOOST_TEST_CONTEXT().

◆ BOOST_AUTO_TEST_CASE() [7/11]

BOOST_AUTO_TEST_CASE ( NoSurfaceFinishExport )

Test that boards without surface finish don't generate coating layers.

Definition at line 288 of file test_ipc2581_export.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), and BOARD_STACKUP::m_FinishType.

◆ BOOST_AUTO_TEST_CASE() [8/11]

BOOST_AUTO_TEST_CASE ( SchemaValidationVersionB )

Validate IPC-2581B export against schema for multiple boards.

This test exports each board in VALIDATION_TEST_BOARDS to IPC-2581B format and validates against the IPC-2581B1.xsd schema using xmllint (if available).

Definition at line 332 of file test_ipc2581_export.cpp.

References BOOST_CHECK_MESSAGE(), and BOOST_TEST_CONTEXT().

◆ BOOST_AUTO_TEST_CASE() [9/11]

BOOST_AUTO_TEST_CASE ( SchemaValidationVersionC )

Validate IPC-2581C export against schema for multiple boards.

This test exports each board in VALIDATION_TEST_BOARDS to IPC-2581C format and validates against the IPC-2581C.xsd schema using xmllint (if available).

Definition at line 375 of file test_ipc2581_export.cpp.

References BOOST_CHECK_MESSAGE(), and BOOST_TEST_CONTEXT().

◆ BOOST_AUTO_TEST_CASE() [10/11]

BOOST_AUTO_TEST_CASE ( SmdPadSolderMaskExport_Issue16658 )

Test that SMD pad solder mask openings are exported (Issue #16658)

This test verifies that SMD pads which have implicit solder mask openings (pads on copper layers that don't explicitly include F_Mask/B_Mask in their layer set) still get exported with solder mask features in the IPC-2581 output.

Definition at line 463 of file test_ipc2581_export.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), F_Cu, F_Mask, pad, and SMD.

◆ BOOST_AUTO_TEST_CASE() [11/11]

BOOST_AUTO_TEST_CASE ( SurfaceFinishExport )

Test that surface finish is exported correctly (Issue #22690)

This test verifies that when a board has a surface finish defined:

  1. A Spec element with SurfaceFinish is created
  2. COATING_TOP and COATING_BOTTOM Layer elements are created with layerFunction="COATINGCOND"
  3. StackupLayer entries reference the surface finish Spec

Definition at line 242 of file test_ipc2581_export.cpp.

References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), and BOARD_STACKUP::m_FinishType.