From a1a99b1ec2b80197ab4bd9749dbc616e400921a0 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Wed, 10 Aug 2022 17:53:13 +0200 Subject: [PATCH] Sim QA: Check NGSPICE's LoadNetlist() and Run() status code --- eeschema/sim/ngspice.cpp | 7 +++---- qa/unittests/eeschema/test_netlist_exporter_spice.cpp | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp index d28b142545..c1f416ebc3 100644 --- a/eeschema/sim/ngspice.cpp +++ b/eeschema/sim/ngspice.cpp @@ -296,12 +296,12 @@ bool NGSPICE::LoadNetlist( const string& aNetlist ) lines.push_back( nullptr ); // sentinel, as requested in ngSpice_Circ description Command( "remcirc" ); - m_ngSpice_Circ( lines.data() ); + bool success = !m_ngSpice_Circ( lines.data() ); for( auto line : lines ) free( line ); - return true; + return success; } @@ -345,8 +345,7 @@ bool NGSPICE::Command( const string& aCmd ) { LOCALE_IO c_locale; // ngspice works correctly only with C locale validate(); - m_ngSpice_Command( (char*) aCmd.c_str() ); - return true; + return !m_ngSpice_Command( (char*) aCmd.c_str() ); } diff --git a/qa/unittests/eeschema/test_netlist_exporter_spice.cpp b/qa/unittests/eeschema/test_netlist_exporter_spice.cpp index c47bbea294..d7edd29a9a 100644 --- a/qa/unittests/eeschema/test_netlist_exporter_spice.cpp +++ b/qa/unittests/eeschema/test_netlist_exporter_spice.cpp @@ -117,8 +117,8 @@ public: //ngspice->Init(); ngspice->Command( "set ngbehavior=ps" ); ngspice->Command( "setseed 1" ); - ngspice->LoadNetlist( netlist.ToStdString() ); - ngspice->Run(); + BOOST_REQUIRE( ngspice->LoadNetlist( netlist.ToStdString() ) ); + BOOST_REQUIRE( ngspice->Run() ); // We need to make sure that the number of points always the same. ngspice->Command( "linearize" );