24#define BOOST_TEST_NO_MAIN
26#include <wx/cmdline.h>
27#include <wx/stdstream.h>
28#include <wx/wfstream.h>
29#include <wx/textfile.h>
41#include <boost/test/unit_test.hpp>
43using namespace boost::unit_test;
91 wxString boardFilename;
93 if( hash.has_value() )
98 boardFilename = it->second;
105 BOOST_TEST_ERROR(
"Failed to load test " << aTestData->
GetName() <<
" from " << aTestData->
GetDataPath() );
116 <<
" removed items, " <<
expected.m_addedItems.size() <<
" added items" );
117 BOOST_TEST_MESSAGE(
"- computed: " << cstate.m_heads.size() <<
" heads, " << cstate.m_removedIds.size()
118 <<
" removed items, " << cstate.m_addedItems.size() <<
" added items" );
120 bool pass = cstate.Compare(
expected );
133std::vector<wxString>
scanSubdirs(
const wxString& absPath,
bool aFiles, wxString filespec = wxEmptyString )
135 std::vector<wxString> rv;
137 wxDir dir( absPath );
138 if( !dir.IsOpened() )
140 BOOST_TEST_ERROR(
"Failed to open directory: " << absPath );
146 bool hasFiles = dir.GetFirst( &dirName, filespec, aFiles ? wxDIR_FILES : wxDIR_DIRS );
149 rv.push_back( dirName );
150 hasFiles = dir.GetNext( &dirName );
158 for(
const wxString& brdFile :
scanSubdirs( aPath,
true, wxT(
"*.kicad_pcb") ) )
160 wxFileName
path ( aPath );
161 path.SetName( brdFile );
165 BOOST_TEST_MESSAGE(
"- file: " << std::left << std::setw(50) << brdFile <<
" hash: " << ( *hash ) );
173 std::vector<PNS_TEST_CASE*> testCases;
176 absPath.AppendDir (wxT(
"pns_regressions"));
178 wxFileName boardsPath( absPath );
179 boardsPath.AppendDir(wxT(
"boards"));
183 for(
const wxString& subdir :
scanSubdirs( absPath.GetFullPath(),
false ) )
185 if( !subdir.CmpNoCase( wxT(
"boards") ) )
188 wxFileName
path( absPath );
189 path.AppendDir( subdir );
191 for(
const wxString& logName:
scanSubdirs(
path.GetFullPath(),
true, wxT(
"*.log") ) )
193 wxFileName logPath(
path );
194 logPath.SetName( logName );
198 testCases.push_back(
new PNS_TEST_CASE( subdir, logPath.GetFullPath() ) );
208 test_suite* pnsTestSuite = BOOST_TEST_SUITE(
"pns_regressions" );
212 for(
auto& c : testCases )
218 framework::master_test_suite().p_name.value =
"P&S router regressions";
219 framework::master_test_suite().add( pnsTestSuite );
224int main(
int argc,
char* argv[] )
General utilities for PCB file IO for QA programs.
KI_TEST::CONSOLE_LOG * m_Log
KI_TEST::CONSOLE_MSG_REPORTER * m_Reporter
const std::optional< wxString > GetLogBoardHash(const wxString &logFileName)
const COMMIT_STATE & GetExpectedResult() const
bool Load(const wxFileName &logFileName, REPORTER *aRpt, const wxString boardFileName=wxT(""))
const PNS_LOG_FILE::COMMIT_STATE GetRouterUpdatedItems()
void ReplayLog(PNS_LOG_FILE *aLog, int aStartEventIndex=0, int aFrom=0, int aTo=-1, bool aUpdateExpectedResult=false)
void SetReporter(REPORTER *aReporter)
std::optional< wxString > fileHashMMH3(const wxString &aFilePath)
Calculates an MMH3 hash of a given file.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::vector< PNS_TEST_CASE * > createTestCases()
void scanAndHashBoards(const wxString &aPath)
std::map< wxString, wxString > g_testBoards
bool init_pns_test_suite()
std::vector< wxString > scanSubdirs(const wxString &absPath, bool aFiles, wxString filespec=wxEmptyString)
PNS_TEST_CASE(const wxString &aName, const wxString &aPath)
wxString GetDataPath() const
static bool RunTest(PNS_TEST_CASE *aTestData)
static FIXTURE_LOGGER m_logger
VECTOR3I expected(15, 30, 45)
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))