KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sim_regressions.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25#include <boost/test/results_collector.hpp> // To check if the current test failed (to be moved?).
26#include <eeschema_test_utils.h>
28#include <wx/ffile.h>
29#include <mock_pgm_base.h>
30#include <locale_io.h>
31
32
34{
35public:
38 {
39 }
40
42 {
43 }
44
45 wxFileName GetSchematicPath( const wxString& aBaseName ) override
46 {
47 wxFileName fn( KI_TEST::GetEeschemaTestDataDir() );
48 fn.SetName( aBaseName );
50
51 return fn;
52 }
53
54 wxString GetNetlistPath( bool aTest = false ) override
55 {
56 wxFileName netFile = m_schematic.Prj().GetProjectFullName();
57
58 if( aTest )
59 netFile.SetName( netFile.GetName() + "_test" );
60
61 netFile.SetExt( "spice" );
62 return netFile.GetFullPath();
63 }
64
65 unsigned GetNetlistOptions() override
66 {
69
70 if( m_SaveCurrents )
72
73 if( m_SaveVoltages )
75
78
79 return options;
80 }
81
82public:
83 bool m_SavesDissipations = false;
84 bool m_SaveVoltages = true;
85 bool m_SaveCurrents = true;
86};
87
88
90{
92
93 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
94 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
95
96 TestNetlist( "issue13591" );
97 TestTranPoint( 100e-6, { { "I(R1)", 0 }, { "I(R2)", 0 } }, 0.00001 );
98 TestTranPoint( 500e-6, { { "I(R1)", 0 }, { "I(R2)", 0 } }, 0.00001 );
99}
100
101
103{
105
106 m_SaveCurrents = false;
107
108 TestNetlist( "issue13431" );
109 TestTranPoint( 0.005, { { "V(/soft_start)", 2.489 } } );
110 TestTranPoint( 0.012, { { "V(/soft_start)", 5.100 } } );
111}
112
113
114// This test is flaky and fails on ngspice-42 / Linux.
115// Please replace it with something that is more stable
116#if 0
118{
120
121 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
122 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
123
124 TestNetlist( "issue13112" );
125 TestTranPoint( 0.01, { { "V(out)", -0.060 } } );
126 TestTranPoint( 0.02, { { "V(out)", 0.856 } } );
127}
128#endif
129
130
132{
134
135 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
136 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
137
138 TestNetlist( "issue13162" );
139 TestTranPoint( 0.030, { { "V(out)", 0.000829682 } } );
140 TestTranPoint( 0.035, { { "V(out)", -0.000829692 } } );
141}
142
143
145{
147
148 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
149 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
150
151 TestNetlist( "issue12505" );
152 TestTranPoint( 0.015, { { "V(Net-_R1-Pad2_)", -311 } } );
153 TestTranPoint( 0.025, { { "V(Net-_R1-Pad2_)", 311 } } );
154}
155
156
158{
160
161 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
162 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
163
164 TestNetlist( "issue16223" );
165 TestTranPoint( 0.0, { { "V(PRBS_OUTPUT)", 5.114 } } );
166 TestTranPoint( 1e-6, { { "V(PRBS_OUTPUT)", -0.1144 } } );
167}
168
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.cpp:923
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:129
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:90
wxFileName GetSchematicPath(const wxString &aBaseName) override
wxString GetNetlistPath(bool aTest=false) override
static const std::string KiCadSchematicFileExtension
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
PGM_SINGLE_TOP program
std::vector< FAB_LAYER_COLOR > dummy
BOOST_FIXTURE_TEST_CASE(WindowsPaths, TEST_SIM_REGRESSIONS_FIXTURE)