KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_allegro_boards.cpp File Reference

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_INFOcreateHeaderTestEntry (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_DESCRIPTORgetBoardTestDefinitions (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_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
 

Detailed Description

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.

Function Documentation

◆ AssertNoErrors()

◆ buildAllegroBoardSuites()

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

◆ buildTestRegistry()

◆ createBlockTestDescriptor()

static ALLEGRO_BLOCK_TEST_DESCRIPTOR createBlockTestDescriptor ( const nlohmann::json & aBlockTestJson)
static

Definition at line 444 of file test_allegro_boards.cpp.

References getByteFromHexStr().

Referenced by getBoardTestDefinitions().

◆ createBlockTestEntry()

static BLOCK_TEST_INFO createBlockTestEntry ( const std::string & boardDir,
const ALLEGRO_BLOCK_TEST_DESCRIPTOR & aBlockTestDescriptor )
static

◆ 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 166 of file test_allegro_boards.cpp.

Referenced by ALLEGRO_BLOCK_TEST_FIXTURE::RunHeaderTest().

◆ getBoardTestDefinitions()

static std::vector< ALLEGRO_BOARD_TEST_DESCRIPTOR > getBoardTestDefinitions ( const nlohmann::json & aJson)
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().

◆ 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 537 of file test_allegro_boards.cpp.

Referenced by buildAllegroBoardSuites().

◆ getByteFromHexStr()

static uint8_t getByteFromHexStr ( const nlohmann::json & aJsonEntry,
const std::string & aFieldName )
static

Definition at line 411 of file test_allegro_boards.cpp.

Referenced by createBlockTestDescriptor().

◆ getFormatVersionFromStr()

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

◆ loadDataByUri()

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

◆ RunBoardLoad()

Variable Documentation

◆ s_registerHeaderBlockSuites

struct RegisterBlockSuites s_registerHeaderBlockSuites
static