KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_netlist_exporter_kicad.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) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21#include <eeschema_test_utils.h>
22
23
25{
26public:
27 void CompareNetlists() override
28 {
29 NETLIST golden;
31
32 {
33 std::unique_ptr<NETLIST_READER> netlistReader( NETLIST_READER::GetNetlistReader(
34 &golden, GetNetlistPath(), wxEmptyString ) );
35
36 BOOST_REQUIRE_NO_THROW( netlistReader->LoadNetlist() );
37 }
38
39 {
40 std::unique_ptr<NETLIST_READER> netlistReader( NETLIST_READER::GetNetlistReader(
41 &test, GetNetlistPath( true ), wxEmptyString ) );
42
43 BOOST_REQUIRE_NO_THROW( netlistReader->LoadNetlist() );
44 }
45
46 // Number of components should match
47 BOOST_REQUIRE_EQUAL( golden.GetCount(), test.GetCount() );
48
49 for( unsigned i = 0; i < golden.GetCount(); i++ )
50 {
51 COMPONENT* goldenComp = golden.GetComponent( i );
52 COMPONENT* refComp = test.GetComponentByReference( goldenComp->GetReference() );
53
54 // Retrieval by reference
55 BOOST_REQUIRE_NE( refComp, nullptr );
56
57 // Retrieval by KIID
58 KIID_PATH path = goldenComp->GetPath();
59
60 BOOST_REQUIRE( !goldenComp->GetKIIDs().empty() );
61
62 path.push_back( goldenComp->GetKIIDs().front() );
63
64 COMPONENT* pathComp = test.GetComponentByPath( path );
65 BOOST_REQUIRE_NE( pathComp, nullptr );
66
67 // We should have found the same component
68 BOOST_REQUIRE_EQUAL( refComp->GetReference(), pathComp->GetReference() );
69
70 // And that component should have the same number of attached nets
71 BOOST_REQUIRE_EQUAL( goldenComp->GetNetCount(), refComp->GetNetCount() );
72
73 for( unsigned net = 0; net < goldenComp->GetNetCount(); net++ )
74 {
75 const COMPONENT_NET& goldenNet = goldenComp->GetNet( net );
76 const COMPONENT_NET& testNet = refComp->GetNet( net );
77
78 // The video test has a bunch of unconnected RESERVED pins which cause duplicate
79 // auto-generated netnames. The connectivity algo disambiguates these with "_n"
80 // suffixes, but since the algorithm is multi-threaded, which ones get which suffix
81 // is not deterministic. So skip these.
82 if( testNet.GetPinFunction().Contains( "RESERVED" ) )
83 continue;
84
85 // The two nets at the same index should be identical
86 BOOST_REQUIRE_EQUAL( goldenNet.GetNetName(), testNet.GetNetName() );
87 BOOST_REQUIRE_EQUAL( goldenNet.GetPinName(), testNet.GetPinName() );
88 BOOST_REQUIRE_EQUAL( goldenNet.GetPinType(), testNet.GetPinType() );
89 }
90
91 // And the the resolved component class is the same
92 BOOST_REQUIRE( goldenComp->GetComponentClassNames()
93 == refComp->GetComponentClassNames() );
94 }
95 }
96};
97
98
99BOOST_FIXTURE_TEST_SUITE( Netlists, TEST_NETLIST_EXPORTER_KICAD_FIXTURE )
100
101
103{
104 BOOST_CHECK_NE( m_pi.get(), nullptr );
105}
106
107
108BOOST_AUTO_TEST_CASE( GlobalPromotion )
109{
110 TestNetlist( "test_global_promotion" );
111}
112
113
114BOOST_AUTO_TEST_CASE( GlobalPromotion2 )
115{
116 TestNetlist( "test_global_promotion_2" );
117}
118
119
121{
122 TestNetlist( "video" );
123}
124
125
126BOOST_AUTO_TEST_CASE( ComplexHierarchy )
127{
128 TestNetlist( "complex_hierarchy" );
129}
130
131
132BOOST_AUTO_TEST_CASE( WeakVectorBusDisambiguation )
133{
134 TestNetlist( "weak_vector_bus_disambiguation" );
135}
136
137
138BOOST_AUTO_TEST_CASE( BusJunctions )
139{
140 TestNetlist( "bus_junctions" );
141}
142
143
144BOOST_AUTO_TEST_CASE( HierRenaming )
145{
146 TestNetlist( "test_hier_renaming" );
147}
148
149
151{
152 TestNetlist( "noconnects" );
153}
154
155
156BOOST_AUTO_TEST_CASE( PrefixBusAlias )
157{
158 TestNetlist( "prefix_bus_alias" );
159}
160
161
162BOOST_AUTO_TEST_CASE( GroupBusMatching )
163{
164 TestNetlist( "group_bus_matching" );
165}
166
167
168BOOST_AUTO_TEST_CASE( TopLevelHierPins )
169{
170 TestNetlist( "top_level_hier_pins" );
171}
172
173
175{
176 TestNetlist( "bus_entries" );
177}
178
179
180BOOST_AUTO_TEST_CASE( HierNoConnect )
181{
182 TestNetlist( "test_hier_no_connect" );
183}
184
185
186BOOST_AUTO_TEST_CASE( BusConnection )
187{
188 TestNetlist( "bus_connection" );
189}
190
192{
193 TestNetlist( "issue14657" );
194}
195
196BOOST_AUTO_TEST_CASE( HierarchyAliases )
197{
198 TestNetlist( "hierarchy_aliases" );
199}
200
202{
203 TestNetlist( "issue14818" );
204}
205
207{
208 TestNetlist( "issue16003" );
209}
210
212{
213 TestNetlist( "issue16439" );
214}
215
216BOOST_AUTO_TEST_CASE( ComponentClasses )
217{
218 TestNetlist( "component_classes" );
219}
220
221
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
Definition: pcb_netlist.h:47
const wxString & GetNetName() const
Definition: pcb_netlist.h:61
const wxString & GetPinFunction() const
Definition: pcb_netlist.h:62
const wxString & GetPinName() const
Definition: pcb_netlist.h:60
const wxString & GetPinType() const
Definition: pcb_netlist.h:63
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:88
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:114
const KIID_PATH & GetPath() const
Definition: pcb_netlist.h:152
const wxString & GetReference() const
Definition: pcb_netlist.h:129
const std::vector< KIID > & GetKIIDs() const
Definition: pcb_netlist.h:154
unsigned GetNetCount() const
Definition: pcb_netlist.h:112
std::unordered_set< wxString > & GetComponentClassNames()
Definition: pcb_netlist.h:184
static NETLIST_READER * GetNetlistReader(NETLIST *aNetlist, const wxString &aNetlistFileName, const wxString &aCompFootprintFileName=wxEmptyString)
Attempt to determine the net list file type of aNetlistFileName and return the appropriate NETLIST_RE...
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:241
unsigned GetCount() const
Definition: pcb_netlist.h:262
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
Definition: pcb_netlist.h:270
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(FindPlugin)