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, you may find one at
18 * http://www.gnu.org/licenses/
19 */
20
33
36
37#include <connection_graph.h>
38#include <schematic.h>
39#include <sch_marker.h>
40#include <sch_pin.h>
41#include <sch_sheet_path.h>
42#include <erc/erc_settings.h>
43#include <erc/erc.h>
44#include <erc/erc_item.h>
45#include <erc/erc_report.h>
47#include <locale_io.h>
48
49
59
60
61BOOST_FIXTURE_TEST_CASE( ERCPowerPinNotDrivenMarkerOnPowerInputPin, ERC_POWER_PIN_MARKER_FIXTURE )
62{
64
65 KI_TEST::LoadSchematic( m_settingsManager, wxS( "issue24328/issue24328" ), m_schematic );
66
67 ERC_SETTINGS& settings = m_schematic->ErcSettings();
68 SHEETLIST_ERC_ITEMS_PROVIDER errors( m_schematic.get() );
69
74
75 m_schematic->ConnectionGraph()->RunERC();
76
77 ERC_TESTER tester( m_schematic.get() );
78 tester.TestPinToPin();
79
81
82 ERC_REPORT reportWriter( m_schematic.get(), EDA_UNITS::MM );
83
84 int powerPinErrors = 0;
85 bool allPowerInputAnchors = true;
86 std::vector<wxString> anchorDescriptions;
87
88 for( int ii = 0; ii < errors.GetCount(); ++ii )
89 {
90 std::shared_ptr<RC_ITEM> item = errors.GetItem( ii );
91
92 if( item->GetErrorCode() != ERCE_POWERPIN_NOT_DRIVEN )
93 continue;
94
95 powerPinErrors++;
96
97 SCH_SHEET_PATH sheetPath;
98 SCH_ITEM* mainItem = m_schematic->ResolveItem( item->GetMainItemID(),
99 &sheetPath, true );
100
101 BOOST_REQUIRE_MESSAGE( mainItem,
102 "ERCE_POWERPIN_NOT_DRIVEN marker has no main item" );
103 BOOST_REQUIRE_MESSAGE( mainItem->Type() == SCH_PIN_T,
104 "ERCE_POWERPIN_NOT_DRIVEN marker main item is not a pin" );
105
106 SCH_PIN* pin = static_cast<SCH_PIN*>( mainItem );
107
108 anchorDescriptions.push_back(
109 wxString::Format( "ref=%s pin=%s type=%s",
110 pin->GetParentSymbol()->GetRef( &sheetPath ),
111 pin->GetNumber(),
112 ElectricalPinTypeGetText( pin->GetType() ) ) );
113
114 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_IN )
115 allPowerInputAnchors = false;
116 }
117
118 wxString anchorDump;
119
120 for( const wxString& s : anchorDescriptions )
121 anchorDump << s << wxS( "\n" );
122
123 BOOST_CHECK_MESSAGE( powerPinErrors >= 1,
124 "Expected at least 1 ERCE_POWERPIN_NOT_DRIVEN error\n"
125 << reportWriter.GetTextReport() );
126
127 BOOST_CHECK_MESSAGE( allPowerInputAnchors,
128 "At least one ERCE_POWERPIN_NOT_DRIVEN marker was anchored on a "
129 "non-PT_POWER_IN pin. The marker should refer to the pin the "
130 "error message is about.\nAnchors seen:\n"
131 << anchorDump.ToStdString()
132 << "\n"
133 << reportWriter.GetTextReport() );
134}
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
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:984
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:41
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:166
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:46
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE)
Definition pin_type.cpp:207
@ 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:154