21#include <boost/test/results_collector.hpp>
30#include <wx/filename.h>
31#include <wx/tokenzr.h>
41std::set<wxString> collectIncludeFileNames(
const wxString& aNetlist )
43 std::set<wxString> names;
44 wxStringTokenizer lines( aNetlist, wxS(
"\n" ), wxTOKEN_RET_EMPTY_ALL );
46 while( lines.HasMoreTokens() )
48 wxString line = lines.GetNextToken();
50 if( line.StartsWith( wxS(
".include " ) ) )
52 wxFileName fn( line.AfterFirst(
'"' ).BeforeLast(
'"' ) );
53 names.insert( fn.GetFullName() );
77 fn.SetName( aBaseName );
85 wxFileName netFile =
m_schematic->Project().GetProjectFullName();
88 netFile.SetName( netFile.GetName() +
"_test" );
90 netFile.SetExt(
"spice" );
91 return netFile.GetFullPath();
126 TestNetlist(
"issue13591" );
127 TestTranPoint( 100e-6, { {
"I(R1)", 0 }, {
"I(R2)", 0 } }, 0.00001 );
128 TestTranPoint( 500e-6, { {
"I(R1)", 0 }, {
"I(R2)", 0 } }, 0.00001 );
136 m_SaveCurrents =
false;
138 TestNetlist(
"issue13431" );
139 TestTranPoint( 0.005, { {
"V(/soft_start)", 2.489 } } );
140 TestTranPoint( 0.012, { {
"V(/soft_start)", 5.100 } } );
151 const MOCK_PGM_BASE&
program =
static_cast<MOCK_PGM_BASE&
>(
Pgm() );
154 TestNetlist(
"issue13112" );
155 TestTranPoint( 0.01, { {
"V(out)", -0.060 } } );
156 TestTranPoint( 0.02, { {
"V(out)", 0.856 } } );
168 TestNetlist(
"issue13162" );
169 TestTranPoint( 0.030, { {
"V(out)", 0.000829682 } } );
170 TestTranPoint( 0.035, { {
"V(out)", -0.000829692 } } );
181 TestNetlist(
"issue12505" );
182 TestTranPoint( 0.015, { {
"V(Net-_R1-Pad2_)", -311 } } );
183 TestTranPoint( 0.025, { {
"V(Net-_R1-Pad2_)", 311 } } );
194 TestNetlist(
"issue16223" );
195 TestTranPoint( 0.0, { {
"V(PRBS_OUTPUT)", 5.114 } } );
196 TestTranPoint( 1e-6, { {
"V(PRBS_OUTPUT)", -0.1144 } } );
210 wxFFile netlistFile( GetNetlistPath(
true ),
"rt" );
214 netlistFile.ReadAll( &
netlist );
219 std::set<wxString> includes = collectIncludeFileNames(
netlist );
223 for(
const wxString& ref : { wxS(
"U1" ), wxS(
"U2" ), wxS(
"U3" ),
224 wxS(
"U4" ), wxS(
"U5" ), wxS(
"U6" ) } )
226 wxString cacheName = ref + wxS(
".cache" );
228 BOOST_CHECK_MESSAGE( includes.count( cacheName ) == 1,
229 "IBIS cache device " << cacheName <<
" was not emitted as a .include" );
245 const wxString fftCommand = wxS(
"linearize v(/out)\nfft v(/out)" );
247 BOOST_REQUIRE(
model.GetNetlist( fftCommand, GetNetlistOptions(), &formatter, *m_reporter ) );
250 wxStringTokenizer lines(
netlist, wxS(
"\n" ), wxTOKEN_RET_EMPTY_ALL );
251 bool inControl =
false;
253 while( lines.HasMoreTokens() )
255 wxString line = lines.GetNextToken().Trim(
false ).Trim(
true ).Lower();
257 if( line.IsSameAs( wxS(
".control" ) ) )
259 else if( line.IsSameAs( wxS(
".endc" ) ) )
261 else if( !inControl )
262 BOOST_CHECK_MESSAGE( !line.StartsWith( wxS(
"linearize" ) ) && !line.StartsWith( wxS(
"fft" ) ),
263 "Bare control command leaked into netlist: " << line );
278 model.SetParamValue(
"lib",
"device.lib" );
280 std::vector<wxString> includes =
model.GetSpiceIncludes( item,
nullptr,
283 BOOST_REQUIRE_EQUAL( includes.size(), 1u );
std::unique_ptr< SCHEMATIC > m_schematic
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
@ OPTION_SAVE_ALL_CURRENTS
@ OPTION_SAVE_ALL_VOLTAGES
@ OPTION_SAVE_ALL_DISSIPATIONS
@ OPTION_ADJUST_INCLUDE_PATHS
static REPORTER & GetInstance()
Special netlist exporter flavor that allows one to override simulation commands.
TEST_NETLIST_EXPORTER_SPICE_FIXTURE()
unsigned GetNetlistOptions() override
wxFileName SchematicQAPath(const wxString &aBaseName) override
TEST_SIM_REGRESSIONS_FIXTURE()
wxString GetNetlistPath(bool aTest=false) override
~TEST_SIM_REGRESSIONS_FIXTURE()
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.
static void LoadSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName)
std::vector< FAB_LAYER_COLOR > dummy
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_TEST_INFO("Two-port Series .op current = "<< iDevice)
BOOST_FIXTURE_TEST_CASE(WindowsPaths, TEST_SIM_REGRESSIONS_FIXTURE)
BOOST_AUTO_TEST_CASE(RawSpiceModelSuppliesLibraryInclude)
BOOST_CHECK_EQUAL(result, "25.4")