KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_allegro_boards.cpp File Reference
#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  BOARD_TEST_INFO
 
class  ALLEGRO_BLOCK_TEST_FIXTURE
 
struct  ALLEGRO_BLOCK_TEST
 Just enough information about the board and block tests to be able to name and register the test cases and look up the definitions at runtime. More...
 
struct  ALLEGRO_BOARD_TEST_REF
 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  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_INFOcreateHeaderTestEntry (const std::string &boardDir, const nlohmann::json &headerTestEntry)
 
static BLK_TEST_INFO createBlockTestEntry (const std::string &boardDir, const nlohmann::json &blockTestEntry)
 
static BOARD_TEST_INFO createBoardTestInfo (const std::string &aBrdName, const nlohmann::json &boardTestEntry)
 
void RunBoardLoad (const std::string &aBrdName, const nlohmann::json &aBoardTestJson)
 
void RunBoardExpectations (const std::string &aBrdName, const nlohmann::json &aBoardTestJson)
 
static std::vector< ALLEGRO_BOARD_TEST_REFgetBoardTestDefinitions (const nlohmann::json &aJson)
 Construct a list of test definitions for the boards we have test data for, by reading the registry JSON file.
 
static const ALLEGRO_BLOCK_TEST_REGISTRYbuildTestRegistry ()
 
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
 

Function Documentation

◆ buildAllegroBoardSuites()

static std::vector< boost::unit_test::test_suite * > buildAllegroBoardSuites ( )
static

This function initializes the test suites for Allegro block and board parsing.

It reads about the minium 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 implementions and then run them.

Definition at line 570 of file test_allegro_boards.cpp.

References BOOST_REQUIRE(), buildTestRegistry(), ALLEGRO_BLOCK_TEST_REGISTRY::GetBoardJson(), getBoardTestLabels(), ALLEGRO_BOARD_TEST_REF::m_BlockTests, ALLEGRO_BLOCK_TEST_REGISTRY::m_BoardTests, ALLEGRO_BOARD_TEST_REF::m_BrdName, ALLEGRO_BOARD_TEST_REF::m_HasBoardFile, ALLEGRO_BOARD_TEST_REF::m_HasExpectations, ALLEGRO_BOARD_TEST_REF::m_HasHeaderTest, ALLEGRO_BLOCK_TEST_FIXTURE::RunBlockTest(), RunBoardExpectations(), RunBoardLoad(), and ALLEGRO_BLOCK_TEST_FIXTURE::RunHeaderTest().

Referenced by RegisterBlockSuites::RegisterBlockSuites().

◆ buildTestRegistry()

◆ createBlockTestEntry()

static BLK_TEST_INFO createBlockTestEntry ( const std::string & boardDir,
const nlohmann::json & blockTestEntry )
static

Definition at line 134 of file test_allegro_boards.cpp.

Referenced by ALLEGRO_BLOCK_TEST_FIXTURE::RunBlockTest().

◆ createBoardTestInfo()

static BOARD_TEST_INFO createBoardTestInfo ( const std::string & aBrdName,
const nlohmann::json & boardTestEntry )
static

◆ createHeaderTestEntry()

static std::unique_ptr< HEADER_TEST_INFO > createHeaderTestEntry ( const std::string & boardDir,
const nlohmann::json & headerTestEntry )
static

Definition at line 117 of file test_allegro_boards.cpp.

Referenced by ALLEGRO_BLOCK_TEST_FIXTURE::RunHeaderTest().

◆ getBoardTestDefinitions()

static std::vector< ALLEGRO_BOARD_TEST_REF > getBoardTestDefinitions ( const nlohmann::json & aJson)
static

Construct a list of test definitions 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 data loads and tests will run at runtime.

Definition at line 459 of file test_allegro_boards.cpp.

Referenced by buildTestRegistry().

◆ getBoardTestLabels()

static std::vector< std::string > getBoardTestLabels ( const nlohmann::json & boardTestJson)
static

Get the labels associated with a board test, which can be used to e.g.

filter tests.

Definition at line 542 of file test_allegro_boards.cpp.

Referenced by buildAllegroBoardSuites().

◆ getFormatVersionFromStr()

ALLEGRO::FMT_VER getFormatVersionFromStr ( const std::string & aFmtVerStr)

◆ loadDataByUri()

static std::vector< uint8_t > loadDataByUri ( const std::string & aDataSource)
static

◆ RunBoardExpectations()

void RunBoardExpectations ( const std::string & aBrdName,
const nlohmann::json & aBoardTestJson )

◆ RunBoardLoad()

Variable Documentation

◆ s_registerHeaderBlockSuites

struct RegisterBlockSuites s_registerHeaderBlockSuites
static