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 }
92};
93
94
95BOOST_FIXTURE_TEST_SUITE( Netlists, TEST_NETLIST_EXPORTER_KICAD_FIXTURE )
96
97
99{
100 BOOST_CHECK_NE( m_pi.get(), nullptr );
101}
102
103
104BOOST_AUTO_TEST_CASE( GlobalPromotion )
105{
106 TestNetlist( "test_global_promotion" );
107}
108
109
110BOOST_AUTO_TEST_CASE( GlobalPromotion2 )
111{
112 TestNetlist( "test_global_promotion_2" );
113}
114
115
117{
118 TestNetlist( "video" );
119}
120
121
122BOOST_AUTO_TEST_CASE( ComplexHierarchy )
123{
124 TestNetlist( "complex_hierarchy" );
125}
126
127
128BOOST_AUTO_TEST_CASE( WeakVectorBusDisambiguation )
129{
130 TestNetlist( "weak_vector_bus_disambiguation" );
131}
132
133
134BOOST_AUTO_TEST_CASE( BusJunctions )
135{
136 TestNetlist( "bus_junctions" );
137}
138
139
140BOOST_AUTO_TEST_CASE( HierRenaming )
141{
142 TestNetlist( "test_hier_renaming" );
143}
144
145
147{
148 TestNetlist( "noconnects" );
149}
150
151
152BOOST_AUTO_TEST_CASE( PrefixBusAlias )
153{
154 TestNetlist( "prefix_bus_alias" );
155}
156
157
158BOOST_AUTO_TEST_CASE( GroupBusMatching )
159{
160 TestNetlist( "group_bus_matching" );
161}
162
163
164BOOST_AUTO_TEST_CASE( TopLevelHierPins )
165{
166 TestNetlist( "top_level_hier_pins" );
167}
168
169
171{
172 TestNetlist( "bus_entries" );
173}
174
175
176BOOST_AUTO_TEST_CASE( HierNoConnect )
177{
178 TestNetlist( "test_hier_no_connect" );
179}
180
181
182BOOST_AUTO_TEST_CASE( BusConnection )
183{
184 TestNetlist( "bus_connection" );
185}
186
188{
189 TestNetlist( "issue14657" );
190}
191
192BOOST_AUTO_TEST_CASE( HierarchyAliases )
193{
194 TestNetlist( "hierarchy_aliases" );
195}
196
198{
199 TestNetlist( "issue14818" );
200}
201
203{
204 TestNetlist( "issue16003" );
205}
206
208{
209 TestNetlist( "issue16439" );
210}
211
212
213BOOST_AUTO_TEST_SUITE_END()
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
Definition: pcb_netlist.h:45
const wxString & GetNetName() const
Definition: pcb_netlist.h:59
const wxString & GetPinFunction() const
Definition: pcb_netlist.h:60
const wxString & GetPinName() const
Definition: pcb_netlist.h:58
const wxString & GetPinType() const
Definition: pcb_netlist.h:61
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:86
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:112
const KIID_PATH & GetPath() const
Definition: pcb_netlist.h:150
const wxString & GetReference() const
Definition: pcb_netlist.h:127
const std::vector< KIID > & GetKIIDs() const
Definition: pcb_netlist.h:152
unsigned GetNetCount() const
Definition: pcb_netlist.h:110
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:223
unsigned GetCount() const
Definition: pcb_netlist.h:244
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
Definition: pcb_netlist.h:252
BOOST_AUTO_TEST_CASE(FindPlugin)