KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_erc_power_pin_marker_location.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 The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
32
35
36#include <connection_graph.h>
37#include <schematic.h>
38#include <sch_marker.h>
39#include <sch_pin.h>
40#include <sch_sheet_path.h>
41#include <erc/erc_settings.h>
42#include <erc/erc.h>
43#include <erc/erc_item.h>
44#include <erc/erc_report.h>
46#include <locale_io.h>
47
48
58
59
60BOOST_FIXTURE_TEST_CASE( ERCPowerPinNotDrivenMarkerOnPowerInputPin, ERC_POWER_PIN_MARKER_FIXTURE )
61{
63
64 KI_TEST::LoadSchematic( m_settingsManager, wxS( "issue24328/issue24328" ), m_schematic );
65
66 ERC_SETTINGS& settings = m_schematic->ErcSettings();
67 SHEETLIST_ERC_ITEMS_PROVIDER errors( m_schematic.get() );
68
73
74 m_schematic->ConnectionGraph()->RunERC();
75
76 ERC_TESTER tester( m_schematic.get() );
77 tester.TestPinToPin();
78
80
81 ERC_REPORT reportWriter( m_schematic.get(), EDA_UNITS::MM );
82
83 int powerPinErrors = 0;
84 bool allPowerInputAnchors = true;
85 std::vector<wxString> anchorDescriptions;
86
87 for( int ii = 0; ii < errors.GetCount(); ++ii )
88 {
89 std::shared_ptr<RC_ITEM> item = errors.GetItem( ii );
90
91 if( item->GetErrorCode() != ERCE_POWERPIN_NOT_DRIVEN )
92 continue;
93
94 powerPinErrors++;
95
96 SCH_SHEET_PATH sheetPath;
97 SCH_ITEM* mainItem = m_schematic->ResolveItem( item->GetMainItemID(),
98 &sheetPath, true );
99
100 BOOST_REQUIRE_MESSAGE( mainItem,
101 "ERCE_POWERPIN_NOT_DRIVEN marker has no main item" );
102 BOOST_REQUIRE_MESSAGE( mainItem->Type() == SCH_PIN_T,
103 "ERCE_POWERPIN_NOT_DRIVEN marker main item is not a pin" );
104
105 SCH_PIN* pin = static_cast<SCH_PIN*>( mainItem );
106
107 anchorDescriptions.push_back(
108 wxString::Format( "ref=%s pin=%s type=%s",
109 pin->GetParentSymbol()->GetRef( &sheetPath ),
110 pin->GetNumber(),
111 ElectricalPinTypeGetText( pin->GetType() ) ) );
112
113 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_IN )
114 allPowerInputAnchors = false;
115 }
116
117 wxString anchorDump;
118
119 for( const wxString& s : anchorDescriptions )
120 anchorDump << s << wxS( "\n" );
121
122 BOOST_CHECK_MESSAGE( powerPinErrors >= 1,
123 "Expected at least 1 ERCE_POWERPIN_NOT_DRIVEN error\n"
124 << reportWriter.GetTextReport() );
125
126 BOOST_CHECK_MESSAGE( allPowerInputAnchors,
127 "At least one ERCE_POWERPIN_NOT_DRIVEN marker was anchored on a "
128 "non-PT_POWER_IN pin. The marker should refer to the pin the "
129 "error message is about.\nAnchors seen:\n"
130 << anchorDump.ToStdString()
131 << "\n"
132 << reportWriter.GetTextReport() );
133}
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
wxString GetTextReport()
Returns the ERC report in "text" (human readable) format in the C-locale.
Container for ERC settings.
std::map< int, SEVERITY > m_ERCSeverities
int TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
Definition erc.cpp:980
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
int GetCount(int aSeverity=-1) const override
void SetSeverities(int aSeverities) override
std::shared_ptr< RC_ITEM > GetItem(int aIndex) const override
Retrieve a RC_ITEM by index.
@ ERCE_UNANNOTATED
Symbol has not been annotated.
@ ERCE_POWERPIN_NOT_DRIVEN
Power input pin connected to some others pins but no power out pin to drive it.
@ ERCE_LIB_SYMBOL_MISMATCH
Symbol doesn't match copy in library.
@ ERCE_LIB_SYMBOL_ISSUES
Symbol not found in active libraries.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
Definition pin_type.h:42
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE)
Definition pin_type.cpp:203
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_IGNORE
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< FAB_LAYER_COLOR > dummy
BOOST_FIXTURE_TEST_CASE(ERCPowerPinNotDrivenMarkerOnPowerInputPin, ERC_POWER_PIN_MARKER_FIXTURE)
KIBIS_PIN * pin
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
@ SCH_PIN_T
Definition typeinfo.h:150