123 const wxString chainName = wxT(
"TEST_SYNTH_FILTER_CHAIN" );
124 const wxString realNetA = wxT(
"/SIG_A" );
125 const wxString realNetB = wxT(
"/SIG_B" );
127 + wxT(
"0xdeadbeef" );
129 m_schematic = std::make_unique<SCHEMATIC>(
nullptr );
130 m_schematic->SetProject( m_project );
131 m_schematic->CreateDefaultScreens();
133 std::vector<SCH_SHEET*> topSheets = m_schematic->GetTopLevelSheets();
140 wxString rootFileName = PathInWorkDir( wxT(
"synth_filter.kicad_sch" ) );
141 topSheet->
SetFileName( wxT(
"synth_filter.kicad_sch" ) );
144 m_schematic->RefreshHierarchy();
146 auto chain = std::make_unique<SCH_NETCHAIN>();
147 chain->SetName( chainName );
148 chain->AddNet( realNetA );
149 chain->AddNet( realNetB );
150 chain->AddNet( synthName );
154 chain->SetTerminalRefs( wxT(
"U1" ), wxT(
"1" ), wxT(
"U2" ), wxT(
"2" ) );
158 BOOST_REQUIRE_EQUAL( m_schematic->ConnectionGraph()->GetCommittedNetChains().size(), 1u );
161 wxFileName xmlFile( rootFileName );
162 xmlFile.SetName( xmlFile.GetName() + wxT(
"_netlist" ) );
163 xmlFile.SetExt( wxT(
"xml" ) );
164 m_tempFiles.push_back( xmlFile.GetFullPath() );
168 std::unique_ptr<NETLIST_EXPORTER_XML> exporter =
169 std::make_unique<NETLIST_EXPORTER_XML>( m_schematic.get() );
180 wxFFile rawXml( xmlFile.GetFullPath(),
"rb" );
184 rawXml.ReadAll( &xmlText );
189 "XML netlist must not contain synthetic __SG_* net names" );
198 wxXmlNode* netChains =
find_child( xdoc.GetRoot(), wxT(
"net_chains" ) );
201 wxXmlNode* targetChain =
nullptr;
203 for( wxXmlNode* xchain = netChains->GetChildren(); xchain; xchain = xchain->GetNext() )
205 if( xchain->GetName() != wxT(
"net_chain" ) )
208 if( xchain->GetAttribute( wxT(
"name" ), wxEmptyString ) == chainName )
210 targetChain = xchain;
215 BOOST_REQUIRE_MESSAGE( targetChain,
"Committed chain missing from XML output" );
217 wxXmlNode* members =
find_child( targetChain, wxT(
"members" ) );
220 std::set<wxString> emittedNets;
222 for( wxXmlNode* xmem = members->GetChildren(); xmem; xmem = xmem->GetNext() )
224 if( xmem->GetName() != wxT(
"member" ) )
227 emittedNets.insert( xmem->GetAttribute( wxT(
"net" ), wxEmptyString ) );
230 BOOST_CHECK( emittedNets.count( realNetA ) == 1u );
231 BOOST_CHECK( emittedNets.count( realNetB ) == 1u );
233 "Synthetic net leaked into XML <member> list" );
241 m_schematic.get() ) );
244 wxFFile rawSexpr( rootFileName,
"rb" );
248 rawSexpr.ReadAll( &sexprText );
253 "kicad_sch must not contain synthetic __SG_* net names" );
259 "kicad_sch must contain the committed net_chain section" );
261 "kicad_sch must reference the committed chain by name" );
263 "kicad_sch must retain real net A in the chain's nets list" );
265 "kicad_sch must retain real net B in the chain's nets list" );
278 BOOST_REQUIRE_NO_THROW(
283 auto it = overrides.find( chainName );
284 BOOST_REQUIRE_MESSAGE( it != overrides.end(),
285 "Reloaded schematic missing chain member-net override" );
287 const std::set<wxString>& reloadedNets = it->second;
288 BOOST_CHECK( !reloadedNets.empty() );
289 BOOST_CHECK( reloadedNets.count( realNetA ) == 1u );
290 BOOST_CHECK( reloadedNets.count( realNetB ) == 1u );
292 for(
const wxString& n : reloadedNets )
296 "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,...