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 {
70
71 if( m_SaveCurrents )
73
74 if( m_SaveVoltages )
76
79
80 return options;
81 }
82
83public:
84 bool m_SavesDissipations = false;
85 bool m_SaveVoltages = true;
86 bool m_SaveCurrents = true;
87};
88
89
91{
93
94 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
95 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
96
97 TestNetlist( "issue13591" );
98 TestTranPoint( 100e-6, { { "I(R1)", 0 }, { "I(R2)", 0 } }, 0.00001 );
99 TestTranPoint( 500e-6, { { "I(R1)", 0 }, { "I(R2)", 0 } }, 0.00001 );
100}
101
102
104{
106
107 m_SaveCurrents = false;
108
109 TestNetlist( "issue13431" );
110 TestTranPoint( 0.005, { { "V(/soft_start)", 2.489 } } );
111 TestTranPoint( 0.012, { { "V(/soft_start)", 5.100 } } );
112}
113
114
115// This test is flaky and fails on ngspice-42 / Linux.
116// Please replace it with something that is more stable
117#if 0
119{
121
122 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
123 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
124
125 TestNetlist( "issue13112" );
126 TestTranPoint( 0.01, { { "V(out)", -0.060 } } );
127 TestTranPoint( 0.02, { { "V(out)", 0.856 } } );
128}
129#endif
130
131
133{
135
136 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
137 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
138
139 TestNetlist( "issue13162" );
140 TestTranPoint( 0.030, { { "V(out)", 0.000829682 } } );
141 TestTranPoint( 0.035, { { "V(out)", -0.000829692 } } );
142}
143
144
146{
148
149 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
150 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
151
152 TestNetlist( "issue12505" );
153 TestTranPoint( 0.015, { { "V(Net-_R1-Pad2_)", -311 } } );
154 TestTranPoint( 0.025, { { "V(Net-_R1-Pad2_)", 311 } } );
155}
156
157
159{
161
162 const MOCK_PGM_BASE& program = static_cast<MOCK_PGM_BASE&>( Pgm() );
163 MOCK_EXPECT( program.GetLocalEnvVariables ).returns( ENV_VAR_MAP() );
164
165 TestNetlist( "issue16223" );
166 TestTranPoint( 0.0, { { "V(PRBS_OUTPUT)", 5.114 } } );
167 TestTranPoint( 1e-6, { { "V(PRBS_OUTPUT)", -0.1144 } } );
168}
169
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:924
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:92
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:1060
PGM_SINGLE_TOP program
std::vector< FAB_LAYER_COLOR > dummy
BOOST_FIXTURE_TEST_CASE(WindowsPaths, TEST_SIM_REGRESSIONS_FIXTURE)