From f6d9a2574b53016e180c68fa4d5f968c98cb85e3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 22 Jan 2023 16:52:00 +0100 Subject: [PATCH] Fix a QA simulation test on W1/msys2: - Gives a bigger relative tolerance when comparing 2 values to pass some tests - Fix error in test_sim_regressions.cpp for 3 TestNetlist() calls --- .../directives/directives.kicad_sch-bak | 414 ------------------ .../eeschema/sim/test_sim_regressions.cpp | 9 + .../eeschema/test_netlist_exporter_spice.h | 12 +- 3 files changed, 17 insertions(+), 418 deletions(-) delete mode 100644 qa/data/eeschema/spice_netlists/directives/directives.kicad_sch-bak diff --git a/qa/data/eeschema/spice_netlists/directives/directives.kicad_sch-bak b/qa/data/eeschema/spice_netlists/directives/directives.kicad_sch-bak deleted file mode 100644 index 736b4ecf69..0000000000 --- a/qa/data/eeschema/spice_netlists/directives/directives.kicad_sch-bak +++ /dev/null @@ -1,414 +0,0 @@ -(kicad_sch (version 20220822) (generator eeschema) - - (uuid a442c838-4dd5-4486-8afe-ccab26ad4148) - - (paper "A4") - - (lib_symbols - (symbol "Device:L" (pin_numbers hide) (pin_names (offset 1.016) hide) (in_bom yes) (on_board yes) - (property "Reference" "L" (id 0) (at -1.27 0 90) - (effects (font (size 1.27 1.27))) - ) - (property "Value" "L" (id 1) (at 1.905 0 90) - (effects (font (size 1.27 1.27))) - ) - (property "Footprint" "" (id 2) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "~" (id 3) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_keywords" "inductor choke coil reactor magnetic" (id 4) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_description" "Inductor" (id 5) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_fp_filters" "Choke_* *Coil* Inductor_* L_*" (id 6) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (symbol "L_0_1" - (arc (start 0 -2.54) (mid 0.635 -1.905) (end 0 -1.27) - (stroke (width 0) (type default)) - (fill (type none)) - ) - (arc (start 0 -1.27) (mid 0.635 -0.635) (end 0 0) - (stroke (width 0) (type default)) - (fill (type none)) - ) - (arc (start 0 0) (mid 0.635 0.635) (end 0 1.27) - (stroke (width 0) (type default)) - (fill (type none)) - ) - (arc (start 0 1.27) (mid 0.635 1.905) (end 0 2.54) - (stroke (width 0) (type default)) - (fill (type none)) - ) - ) - (symbol "L_1_1" - (pin passive line (at 0 3.81 270) (length 1.27) - (name "1" (effects (font (size 1.27 1.27)))) - (number "1" (effects (font (size 1.27 1.27)))) - ) - (pin passive line (at 0 -3.81 90) (length 1.27) - (name "2" (effects (font (size 1.27 1.27)))) - (number "2" (effects (font (size 1.27 1.27)))) - ) - ) - ) - (symbol "Device:R" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes) - (property "Reference" "R" (id 0) (at 2.032 0 90) - (effects (font (size 1.27 1.27))) - ) - (property "Value" "R" (id 1) (at 0 0 90) - (effects (font (size 1.27 1.27))) - ) - (property "Footprint" "" (id 2) (at -1.778 0 90) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "~" (id 3) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_keywords" "R res resistor" (id 4) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_description" "Resistor" (id 5) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_fp_filters" "R_*" (id 6) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (symbol "R_0_1" - (rectangle (start -1.016 -2.54) (end 1.016 2.54) - (stroke (width 0.254) (type default)) - (fill (type none)) - ) - ) - (symbol "R_1_1" - (pin passive line (at 0 3.81 270) (length 1.27) - (name "~" (effects (font (size 1.27 1.27)))) - (number "1" (effects (font (size 1.27 1.27)))) - ) - (pin passive line (at 0 -3.81 90) (length 1.27) - (name "~" (effects (font (size 1.27 1.27)))) - (number "2" (effects (font (size 1.27 1.27)))) - ) - ) - ) - (symbol "Simulation_SPICE:VSIN" (pin_numbers hide) (pin_names (offset 0.0254)) (in_bom yes) (on_board yes) - (property "Reference" "V" (id 0) (at 2.54 2.54 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Value" "VSIN" (id 1) (at 2.54 0 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Footprint" "" (id 2) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "~" (id 3) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Spice_Netlist_Enabled" "Y" (id 4) (at 0 0 0) - (effects (font (size 1.27 1.27)) (justify left) hide) - ) - (property "Spice_Primitive" "V" (id 5) (at 0 0 0) - (effects (font (size 1.27 1.27)) (justify left) hide) - ) - (property "Spice_Model" "sin(0 1 1k)" (id 6) (at 2.54 -2.54 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "ki_keywords" "simulation" (id 7) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_description" "Voltage source, sinusoidal" (id 8) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (symbol "VSIN_0_0" - (arc (start 0 0) (mid -0.635 0.635) (end -1.27 0) - (stroke (width 0) (type default)) - (fill (type none)) - ) - (arc (start 0 0) (mid 0.635 -0.635) (end 1.27 0) - (stroke (width 0) (type default)) - (fill (type none)) - ) - (text "+" (at 0 1.905 0) - (effects (font (size 1.27 1.27))) - ) - ) - (symbol "VSIN_0_1" - (circle (center 0 0) (radius 2.54) - (stroke (width 0.254) (type default)) - (fill (type background)) - ) - ) - (symbol "VSIN_1_1" - (pin passive line (at 0 5.08 270) (length 2.54) - (name "~" (effects (font (size 1.27 1.27)))) - (number "1" (effects (font (size 1.27 1.27)))) - ) - (pin passive line (at 0 -5.08 90) (length 2.54) - (name "~" (effects (font (size 1.27 1.27)))) - (number "2" (effects (font (size 1.27 1.27)))) - ) - ) - ) - (symbol "power:GND" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes) - (property "Reference" "#PWR" (id 0) (at 0 -6.35 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Value" "GND" (id 1) (at 0 -3.81 0) - (effects (font (size 1.27 1.27))) - ) - (property "Footprint" "" (id 2) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "" (id 3) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_keywords" "power-flag" (id 4) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_description" "Power symbol creates a global label with name \"GND\" , ground" (id 5) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (symbol "GND_0_1" - (polyline - (pts - (xy 0 0) - (xy 0 -1.27) - (xy 1.27 -1.27) - (xy 0 -2.54) - (xy -1.27 -1.27) - (xy 0 -1.27) - ) - (stroke (width 0) (type default)) - (fill (type none)) - ) - ) - (symbol "GND_1_1" - (pin power_in line (at 0 0 270) (length 0) hide - (name "GND" (effects (font (size 1.27 1.27)))) - (number "1" (effects (font (size 1.27 1.27)))) - ) - ) - ) - ) - - (junction (at 114.3 88.9) (diameter 0) (color 0 0 0 0) - (uuid 1a4519d0-8b01-42ab-8ff1-36e90d7b1476) - ) - (junction (at 165.1 88.9) (diameter 0) (color 0 0 0 0) - (uuid bf39a85d-c7bd-47d5-9d55-1353fe5be59a) - ) - - (wire (pts (xy 114.3 76.2) (xy 139.7 76.2)) - (stroke (width 0) (type default)) - (uuid 12e159da-aa7d-4046-a4b1-09721c80fe01) - ) - (wire (pts (xy 165.1 86.36) (xy 165.1 88.9)) - (stroke (width 0) (type default)) - (uuid 4a5e7d13-141b-4818-97e1-9ddbb80f318a) - ) - (wire (pts (xy 114.3 88.9) (xy 114.3 87.63)) - (stroke (width 0) (type default)) - (uuid 4bd96004-bd58-4b69-8f69-d40488cbc2e1) - ) - (wire (pts (xy 152.4 76.2) (xy 152.4 78.74)) - (stroke (width 0) (type default)) - (uuid 526fc8d5-e3b4-4fb6-9bbd-f72e88d122f0) - ) - (wire (pts (xy 152.4 76.2) (xy 165.1 76.2)) - (stroke (width 0) (type default)) - (uuid 551a057e-701e-46b2-962a-cc3ddf2dec41) - ) - (wire (pts (xy 139.7 86.36) (xy 139.7 88.9)) - (stroke (width 0) (type default)) - (uuid 8698f9eb-c83c-4445-87c2-ee33fd1f28a4) - ) - (wire (pts (xy 114.3 88.9) (xy 139.7 88.9)) - (stroke (width 0) (type default)) - (uuid 9357a6f9-2d2b-4286-8fd5-2fdaacd8ebbf) - ) - (wire (pts (xy 114.3 76.2) (xy 114.3 77.47)) - (stroke (width 0) (type default)) - (uuid 9b6abdf8-e409-4b69-be35-aaefd16e1b0b) - ) - (wire (pts (xy 165.1 76.2) (xy 165.1 78.74)) - (stroke (width 0) (type default)) - (uuid a504d5bd-95e4-4f04-8718-80b4350ab7ab) - ) - (wire (pts (xy 152.4 86.36) (xy 152.4 88.9)) - (stroke (width 0) (type default)) - (uuid c05484ba-2868-4e2a-9055-f01b69f40b4e) - ) - (wire (pts (xy 139.7 78.74) (xy 139.7 76.2)) - (stroke (width 0) (type default)) - (uuid c575dbbf-6f76-4a5c-af2d-bc1844739369) - ) - (wire (pts (xy 152.4 88.9) (xy 165.1 88.9)) - (stroke (width 0) (type default)) - (uuid f7d978c1-79cd-451e-b9cd-722274d4cbbf) - ) - - (text ".tran 1u 10m" (at 139.7 93.98 0) - (effects (font (size 1.27 1.27)) (justify left bottom)) - (uuid 12c70666-8e01-4564-ba80-566a7722547a) - ) - (text "K12 L1 L2 0.95" (at 138.43 73.66 0) - (effects (font (size 1.27 1.27)) (justify left bottom)) - (uuid 503dd1f3-122c-4522-bda0-61ccab9d9d14) - ) - (text ".control\nlisting run\n.endc\n.model D D()" (at 137.16 58.42 0) - (effects (font (size 1.27 1.27)) (justify left bottom)) - (uuid a058a379-6994-404d-a9a1-17c467c1e639) - ) - (text ".subckt TEST\nR1 1 2 10\n.model DTEST D()\n.ends\n.model D D()" - (at 165.1 58.42 0) - (effects (font (size 1.27 1.27)) (justify left bottom)) - (uuid a806a0b3-52f9-4a96-ac22-fb65972c0ace) - ) - - (symbol (lib_id "power:GND") (at 165.1 88.9 0) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid 09a419c4-55ec-4f63-883d-ac849651dd08) - (default_instance (reference "#PWR?") (unit 1) (value "GND") (footprint "")) - (property "Reference" "#PWR?" (id 0) (at 165.1 95.25 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Value" "GND" (id 1) (at 165.1 93.98 0) - (effects (font (size 1.27 1.27))) - ) - (property "Footprint" "" (id 2) (at 165.1 88.9 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "" (id 3) (at 165.1 88.9 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 8a427ab7-ec3c-4ee4-bdbc-f86d4f8e2841)) - ) - - (symbol (lib_id "Device:R") (at 165.1 82.55 0) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid 27904b23-eeb1-4c48-8475-3520eefa7335) - (default_instance (reference "R1") (unit 1) (value "1M") (footprint "")) - (property "Reference" "R1" (id 0) (at 167.64 81.915 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Value" "1M" (id 1) (at 167.64 84.455 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Footprint" "" (id 2) (at 163.322 82.55 90) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "~" (id 3) (at 165.1 82.55 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid f3a7863c-6d15-47c4-8c18-821cab9870f0)) - (pin "2" (uuid 6c3cfdb7-22f3-45ea-8a26-b9e9f1c4daa3)) - ) - - (symbol (lib_id "Device:L") (at 152.4 82.55 180) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid 6ecb1219-f224-4524-b9b9-31bc191452b2) - (default_instance (reference "L1") (unit 1) (value "L") (footprint "")) - (property "Reference" "L1" (id 0) (at 153.67 81.915 0) - (effects (font (size 1.27 1.27)) (justify right)) - ) - (property "Value" "L" (id 1) (at 153.67 84.455 0) - (effects (font (size 1.27 1.27)) (justify right)) - ) - (property "Footprint" "" (id 2) (at 152.4 82.55 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "~" (id 3) (at 152.4 82.55 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid a53583dc-95c8-4fca-91b3-9355c491ff8e)) - (pin "2" (uuid adc9748a-7cbe-4cce-80d0-2d901552a4cf)) - ) - - (symbol (lib_id "Device:L") (at 139.7 82.55 0) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid 8f5f8cd4-c7c2-4eda-87a0-28bcb11f6284) - (default_instance (reference "L1") (unit 1) (value "L") (footprint "")) - (property "Reference" "L1" (id 0) (at 140.97 81.915 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Value" "L" (id 1) (at 140.97 84.455 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Footprint" "" (id 2) (at 139.7 82.55 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "~" (id 3) (at 139.7 82.55 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 0fe84496-e0c8-4141-8960-8b9cae8d2390)) - (pin "2" (uuid 203451e4-970e-42a8-abf2-211eb2fe3a4f)) - ) - - (symbol (lib_id "Simulation_SPICE:VSIN") (at 114.3 82.55 0) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid b317d6a2-96aa-490a-abf8-a92f528701f9) - (default_instance (reference "V1") (unit 1) (value "VSIN") (footprint "")) - (property "Reference" "V1" (id 0) (at 118.11 81.915 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Value" "VSIN" (id 1) (at 118.11 84.455 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Footprint" "" (id 2) (at 114.3 82.55 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "~" (id 3) (at 114.3 82.55 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 97129dd6-9c66-4077-b4e0-36ed8a999d2a)) - (pin "2" (uuid e7584aeb-a043-4b70-ad6e-fcf3f0fb48a0)) - ) - - (symbol (lib_id "power:GND") (at 114.3 88.9 0) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid fc591c2b-c8ca-4c4e-a219-4f95f5b3758b) - (default_instance (reference "#PWR?") (unit 1) (value "GND") (footprint "")) - (property "Reference" "#PWR?" (id 0) (at 114.3 95.25 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Value" "GND" (id 1) (at 114.3 93.98 0) - (effects (font (size 1.27 1.27))) - ) - (property "Footprint" "" (id 2) (at 114.3 88.9 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "" (id 3) (at 114.3 88.9 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 4504f1bf-35c5-490f-a53a-2a5a9d73ed5b)) - ) - - (sheet_instances - (path "/" (page "1")) - ) - - (symbol_instances - (path "/09a419c4-55ec-4f63-883d-ac849651dd08" - (reference "#PWR?") (unit 1) (value "GND") (footprint "") - ) - (path "/fc591c2b-c8ca-4c4e-a219-4f95f5b3758b" - (reference "#PWR?") (unit 1) (value "GND") (footprint "") - ) - (path "/8f5f8cd4-c7c2-4eda-87a0-28bcb11f6284" - (reference "L1") (unit 1) (value "10u") (footprint "") - ) - (path "/6ecb1219-f224-4524-b9b9-31bc191452b2" - (reference "L2") (unit 1) (value "10u") (footprint "") - ) - (path "/27904b23-eeb1-4c48-8475-3520eefa7335" - (reference "R1") (unit 1) (value "1M") (footprint "") - ) - (path "/b317d6a2-96aa-490a-abf8-a92f528701f9" - (reference "VSIN1") (unit 1) (value "ampl=1 f=1k") (footprint "") - ) - ) -) diff --git a/qa/unittests/eeschema/sim/test_sim_regressions.cpp b/qa/unittests/eeschema/sim/test_sim_regressions.cpp index 91829f2760..508242574c 100644 --- a/qa/unittests/eeschema/sim/test_sim_regressions.cpp +++ b/qa/unittests/eeschema/sim/test_sim_regressions.cpp @@ -88,6 +88,9 @@ BOOST_FIXTURE_TEST_CASE( WindowsPaths, TEST_SIM_REGRESSIONS_FIXTURE ) { LOCALE_IO dummy; + const MOCK_PGM_BASE& program = static_cast( Pgm() ); + MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() ); + TestNetlist( "issue13591" ); TestTranPoint( 100e-6, { { "I(R1)", 0 }, { "I(R2)", 0 } }, 0.00001 ); TestTranPoint( 500e-6, { { "I(R1)", 0 }, { "I(R2)", 0 } }, 0.00001 ); @@ -110,6 +113,9 @@ BOOST_FIXTURE_TEST_CASE( LegacyFixups, TEST_SIM_REGRESSIONS_FIXTURE ) { LOCALE_IO dummy; + const MOCK_PGM_BASE& program = static_cast( Pgm() ); + MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() ); + TestNetlist( "issue13112" ); TestTranPoint( 0.01, { { "V(out)", -0.060 } } ); TestTranPoint( 0.02, { { "V(out)", 0.856 } } ); @@ -120,6 +126,9 @@ BOOST_FIXTURE_TEST_CASE( DualNMOSAmp, TEST_SIM_REGRESSIONS_FIXTURE ) { LOCALE_IO dummy; + const MOCK_PGM_BASE& program = static_cast( Pgm() ); + MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() ); + TestNetlist( "issue13162" ); TestTranPoint( 0.030, { { "V(out)", 0.535 } } ); TestTranPoint( 0.035, { { "V(out)", -1.437 } } ); diff --git a/qa/unittests/eeschema/test_netlist_exporter_spice.h b/qa/unittests/eeschema/test_netlist_exporter_spice.h index fd31bccaac..dcf4bbf8e1 100644 --- a/qa/unittests/eeschema/test_netlist_exporter_spice.h +++ b/qa/unittests/eeschema/test_netlist_exporter_spice.h @@ -33,6 +33,9 @@ #include #include +// A relative max error accepted when comparing 2 values +#define MAX_DEFAULT_REL_ERROR 2e-2 + class TEST_NETLIST_EXPORTER_SPICE_FIXTURE : public TEST_NETLIST_EXPORTER_FIXTURE { @@ -169,7 +172,8 @@ public: ngspice->Command( "listing runnable" ); } - void TestOpPoint( double aRefValue, const std::string& aVectorName, double aMaxRelError = 1e-2 ) + void TestOpPoint( double aRefValue, const std::string& aVectorName, + double aMaxRelError = MAX_DEFAULT_REL_ERROR ) { BOOST_TEST_CONTEXT( "Vector name: " << aVectorName ) { @@ -186,7 +190,7 @@ public: void TestPoint( const std::string& aXVectorName, double aXValue, const std::map aTestVectorsAndValues, - double aMaxRelError = 1e-2 ) + double aMaxRelError = MAX_DEFAULT_REL_ERROR ) { // The default aMaxRelError is fairly large because we have some problems with determinism // in QA pipeline. We don't need to fix this for now because, if this has to be fixed in @@ -243,14 +247,14 @@ public: void TestTranPoint( double aTime, const std::map aTestVectorsAndValues, - double aMaxRelError = 1e-2 ) + double aMaxRelError = MAX_DEFAULT_REL_ERROR ) { TestPoint( "time", aTime, aTestVectorsAndValues, aMaxRelError ); } void TestACPoint( double aFrequency, const std::map aTestVectorsAndValues, - double aMaxRelError = 1e-2 ) + double aMaxRelError = MAX_DEFAULT_REL_ERROR ) { TestPoint( "frequency", aFrequency, aTestVectorsAndValues, aMaxRelError ); }