|
KiCad PCB EDA Suite
|
This file contains unit tests for parsing individual Allegro blocks and headers, loading from declarative test definitions in JSON files and binary data files. More...
#include <qa_utils/wx_utils/unit_test_utils.h>#include "allegro_block_tests.h"#include "allegro_test_utils.h"#include <filesystem>#include <fstream>#include <boost/test/data/test_case.hpp>#include <json_common.h>#include <board.h>#include <reporter.h>#include <pcbnew/pcb_io/allegro/pcb_io_allegro.h>#include <pcbnew_utils/board_file_utils.h>#include <pcbnew_utils/board_expectations.h>#include <convert/allegro_parser.h>Go to the source code of this file.
Classes | |
| struct | ALLEGRO_BLOCK_TEST_DESCRIPTOR |
| Just enough information about a block-level test to be able to name and register it with the test runner at static init time. More... | |
| struct | ALLEGRO_BOARD_TEST_DESCRIPTOR |
| Just enough information about the board test to be able to name and register any tests for this board. More... | |
| struct | ALLEGRO_BLOCK_TEST_REGISTRY |
| The registry of known Allegro board and block tests, populated at static init time by reading the JSON registry file. More... | |
| struct | BOARD_TEST_INFO |
| class | ALLEGRO_BLOCK_TEST_FIXTURE |
| struct | RegisterBlockSuites |
| At static initialization, register the test suite. More... | |
Functions | |
| static std::vector< uint8_t > | loadDataByUri (const std::string &aDataSource) |
| ALLEGRO::FMT_VER | getFormatVersionFromStr (const std::string &aFmtVerStr) |
| static std::unique_ptr< HEADER_TEST_INFO > | createHeaderTestEntry (const std::string &boardDir, const nlohmann::json &headerTestEntry) |
| static BLOCK_TEST_INFO | createBlockTestEntry (const std::string &boardDir, const ALLEGRO_BLOCK_TEST_DESCRIPTOR &aBlockTestDescriptor) |
| static BOARD_TEST_INFO | createBoardTestInfo (const std::string &aBrdName, const nlohmann::json &boardTestEntry) |
| static void | AssertNoErrors (const CAPTURING_REPORTER &aReporter) |
| void | RunBoardLoad (const std::string &aBrdName, const nlohmann::json &aBoardTestJson) |
| static uint8_t | getByteFromHexStr (const nlohmann::json &aJsonEntry, const std::string &aFieldName) |
| static ALLEGRO_BLOCK_TEST_DESCRIPTOR | createBlockTestDescriptor (const nlohmann::json &aBlockTestJson) |
| static std::vector< ALLEGRO_BOARD_TEST_DESCRIPTOR > | getBoardTestDefinitions (const nlohmann::json &aJson) |
| Construct a list of test descriptrs (lightweight objects) for the boards we have test data for, by reading the registry JSON file. | |
| static const ALLEGRO_BLOCK_TEST_REGISTRY & | buildTestRegistry () |
| static std::vector< std::string > | getBoardTestLabels (const nlohmann::json &boardTestJson) |
| Get the labels associated with a board test, which can be used to e.g. | |
| static std::vector< boost::unit_test::test_suite * > | buildAllegroBoardSuites () |
| This function initializes the test suites for Allegro block and board parsing. | |
Variables | |
| static struct RegisterBlockSuites | s_registerHeaderBlockSuites |
This file contains unit tests for parsing individual Allegro blocks and headers, loading from declarative test definitions in JSON files and binary data files.
This allows to put regression/validation tests in place for block parsing, without having to load an entire .brd file and parse all of its blocks. Allows to "lock in" known parsable blocks at various file version.
Definition in file test_allegro_boards.cpp.
|
static |
Definition at line 332 of file test_allegro_boards.cpp.
References BOOST_TEST(), BOOST_TEST_MESSAGE(), KI_TEST::CAPTURING_REPORTER::GetErrorCount(), KI_TEST::CAPTURING_REPORTER::GetMessages(), and RPT_SEVERITY_ERROR.
Referenced by RunBoardLoad().
|
static |
This function initializes the test suites for Allegro block and board parsing.
It reads about the minimum information it needs to to construct the test cases (i.e. it needs to know the name and which tests are present).
Each test case will call the appropriate test function (e.g. RunHeaderTest or RunBlockTest) at runtime, which will construct more complete test implementations and then run them.
Definition at line 565 of file test_allegro_boards.cpp.
References KI_TEST::AllegroBoardDataDir(), BOOST_REQUIRE(), BOOST_TEST(), buildTestRegistry(), ALLEGRO_BLOCK_TEST_REGISTRY::GetBoardJson(), getBoardTestLabels(), KI_TEST::CACHED_BOARD_LOADER::GetCachedBoard(), KI_TEST::ALLEGRO_CACHED_LOADER::GetInstance(), ALLEGRO_BOARD_TEST_DESCRIPTOR::m_BlockTests, ALLEGRO_BLOCK_TEST_REGISTRY::m_BoardTests, ALLEGRO_BOARD_TEST_DESCRIPTOR::m_BrdName, ALLEGRO_BOARD_TEST_DESCRIPTOR::m_ExpectationTests, ALLEGRO_BOARD_TEST_DESCRIPTOR::m_HasBoardFile, ALLEGRO_BOARD_TEST_DESCRIPTOR::m_HasHeaderTest, KI_TEST::BOARD_EXPECTATION_TEST::DESCRIPTOR::m_Tags, KI_TEST::BOARD_EXPECTATION_TEST::DESCRIPTOR::m_TestName, ALLEGRO_BLOCK_TEST_FIXTURE::RunBlockTest(), RunBoardLoad(), KI_TEST::BOARD_EXPECTATION_TEST::RunFromRef(), and ALLEGRO_BLOCK_TEST_FIXTURE::RunHeaderTest().
Referenced by RegisterBlockSuites::RegisterBlockSuites().
|
static |
Definition at line 513 of file test_allegro_boards.cpp.
References KI_TEST::AllegroBoardDataDir(), getBoardTestDefinitions(), ALLEGRO_BLOCK_TEST_REGISTRY::m_BoardTests, and ALLEGRO_BLOCK_TEST_REGISTRY::m_Json.
Referenced by buildAllegroBoardSuites().
|
static |
Definition at line 444 of file test_allegro_boards.cpp.
References getByteFromHexStr().
Referenced by getBoardTestDefinitions().
|
static |
Definition at line 183 of file test_allegro_boards.cpp.
References ALLEGRO_BLOCK_TEST_DESCRIPTOR::m_BlockOffset, ALLEGRO_BLOCK_TEST_DESCRIPTOR::m_BlockTestJson, and ALLEGRO_BLOCK_TEST_DESCRIPTOR::m_BlockType.
Referenced by ALLEGRO_BLOCK_TEST_FIXTURE::RunBlockTest().
|
static |
Definition at line 218 of file test_allegro_boards.cpp.
References getFormatVersionFromStr().
Referenced by ALLEGRO_BLOCK_TEST_FIXTURE::RunBlockTest(), and ALLEGRO_BLOCK_TEST_FIXTURE::RunHeaderTest().
|
static |
Definition at line 166 of file test_allegro_boards.cpp.
Referenced by ALLEGRO_BLOCK_TEST_FIXTURE::RunHeaderTest().
|
static |
Construct a list of test descriptrs (lightweight objects) for the boards we have test data for, by reading the registry JSON file.
These definitions will then be bound to the test cases. This all happens at static init time, but the main work of data loading and test setup and running will run at runtime.
Definition at line 471 of file test_allegro_boards.cpp.
References createBlockTestDescriptor(), and KI_TEST::BOARD_EXPECTATION_TEST::ExtractExpectationTestsFromJson().
Referenced by buildTestRegistry().
|
static |
Get the labels associated with a board test, which can be used to e.g.
filter tests.
Definition at line 537 of file test_allegro_boards.cpp.
Referenced by buildAllegroBoardSuites().
|
static |
Definition at line 411 of file test_allegro_boards.cpp.
Referenced by createBlockTestDescriptor().
| ALLEGRO::FMT_VER getFormatVersionFromStr | ( | const std::string & | aFmtVerStr | ) |
Definition at line 140 of file test_allegro_boards.cpp.
References ALLEGRO::V_160, ALLEGRO::V_162, ALLEGRO::V_164, ALLEGRO::V_165, ALLEGRO::V_166, ALLEGRO::V_172, ALLEGRO::V_174, ALLEGRO::V_175, ALLEGRO::V_180, and ALLEGRO::V_UNKNOWN.
Referenced by createBoardTestInfo().
|
static |
Definition at line 109 of file test_allegro_boards.cpp.
References KI_TEST::LoadBinaryData(), and path.
Referenced by ALLEGRO_BLOCK_TEST_FIXTURE::RunBlockTest(), and ALLEGRO_BLOCK_TEST_FIXTURE::RunHeaderTest().
| void RunBoardLoad | ( | const std::string & | aBrdName, |
| const nlohmann::json & | aBoardTestJson ) |
Definition at line 352 of file test_allegro_boards.cpp.
References KI_TEST::AllegroBoardDataDir(), AssertNoErrors(), BOOST_CHECK_MESSAGE(), BOOST_TEST_CONTEXT(), BOOST_TEST_MESSAGE(), KI_TEST::ALLEGRO_CACHED_LOADER::GetInstance(), KI_TEST::CAPTURING_REPORTER::GetMessages(), KI_TEST::CAPTURING_REPORTER::GetWarningCount(), KI_TEST::CACHED_BOARD_LOADER::LoadAndCache(), KI_TEST::PrintBoardStats(), and RPT_SEVERITY_WARNING.
Referenced by buildAllegroBoardSuites().
|
static |