124 const wxString chainName = wxT(
"TEST_SYNTH_FILTER_CHAIN" );
125 const wxString realNetA = wxT(
"/SIG_A" );
126 const wxString realNetB = wxT(
"/SIG_B" );
128 + wxT(
"0xdeadbeef" );
130 m_schematic = std::make_unique<SCHEMATIC>(
nullptr );
131 m_schematic->SetProject( m_project );
132 m_schematic->CreateDefaultScreens();
134 std::vector<SCH_SHEET*> topSheets = m_schematic->GetTopLevelSheets();
141 wxString rootFileName = PathInWorkDir( wxT(
"synth_filter.kicad_sch" ) );
142 topSheet->
SetFileName( wxT(
"synth_filter.kicad_sch" ) );
145 m_schematic->RefreshHierarchy();
147 auto chain = std::make_unique<SCH_NETCHAIN>();
148 chain->SetName( chainName );
149 chain->AddNet( realNetA );
150 chain->AddNet( realNetB );
151 chain->AddNet( synthName );
155 chain->SetTerminalRefs( wxT(
"U1" ), wxT(
"1" ), wxT(
"U2" ), wxT(
"2" ) );
159 BOOST_REQUIRE_EQUAL( m_schematic->ConnectionGraph()->GetCommittedNetChains().size(), 1u );
162 wxFileName xmlFile( rootFileName );
163 xmlFile.SetName( xmlFile.GetName() + wxT(
"_netlist" ) );
164 xmlFile.SetExt( wxT(
"xml" ) );
165 m_tempFiles.push_back( xmlFile.GetFullPath() );
169 std::unique_ptr<NETLIST_EXPORTER_XML> exporter =
170 std::make_unique<NETLIST_EXPORTER_XML>( m_schematic.get() );
181 wxFFile rawXml( xmlFile.GetFullPath(),
"rb" );
185 rawXml.ReadAll( &xmlText );
190 "XML netlist must not contain synthetic __SG_* net names" );
199 wxXmlNode* netChains =
find_child( xdoc.GetRoot(), wxT(
"net_chains" ) );
202 wxXmlNode* targetChain =
nullptr;
204 for( wxXmlNode* xchain = netChains->GetChildren(); xchain; xchain = xchain->GetNext() )
206 if( xchain->GetName() != wxT(
"net_chain" ) )
209 if( xchain->GetAttribute( wxT(
"name" ), wxEmptyString ) == chainName )
211 targetChain = xchain;
216 BOOST_REQUIRE_MESSAGE( targetChain,
"Committed chain missing from XML output" );
218 wxXmlNode* members =
find_child( targetChain, wxT(
"members" ) );
221 std::set<wxString> emittedNets;
223 for( wxXmlNode* xmem = members->GetChildren(); xmem; xmem = xmem->GetNext() )
225 if( xmem->GetName() != wxT(
"member" ) )
228 emittedNets.insert( xmem->GetAttribute( wxT(
"net" ), wxEmptyString ) );
231 BOOST_CHECK( emittedNets.count( realNetA ) == 1u );
232 BOOST_CHECK( emittedNets.count( realNetB ) == 1u );
234 "Synthetic net leaked into XML <member> list" );
242 m_schematic.get() ) );
245 wxFFile rawSexpr( rootFileName,
"rb" );
249 rawSexpr.ReadAll( &sexprText );
254 "kicad_sch must not contain synthetic __SG_* net names" );
260 "kicad_sch must contain the committed net_chain section" );
262 "kicad_sch must reference the committed chain by name" );
264 "kicad_sch must retain real net A in the chain's nets list" );
266 "kicad_sch must retain real net B in the chain's nets list" );
279 BOOST_REQUIRE_NO_THROW(
284 auto it = overrides.find( chainName );
285 BOOST_REQUIRE_MESSAGE( it != overrides.end(),
286 "Reloaded schematic missing chain member-net override" );
288 const std::set<wxString>& reloadedNets = it->second;
289 BOOST_CHECK( !reloadedNets.empty() );
290 BOOST_CHECK( reloadedNets.count( realNetA ) == 1u );
291 BOOST_CHECK( reloadedNets.count( realNetB ) == 1u );
293 for(
const wxString& n : reloadedNets )
297 "Reloaded chain leaked a synthetic __SG_* member" );
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...