winIDEA SDK
isys::CTestBench Class Reference

Description

This class encapsulates all data required to run isystem unit tests.

Use one of static methods to get instances of this class.

Python example (from filterTests.py):

0 test_bench = ic.CTestBench.load('test_min_int.iyaml', 0)

Python example.

#include <CTestBench.h>

Inheritance diagram for isys::CTestBench:
isys::CTestBase

Public Types

enum  ETestBenchSectionIds
 Ids of test specification sections.
 

Public Member Functions

isys::CTestEnvironmentConfigSPtr getTestEnvironmentConfig (bool isConst)
 Returns test environment configuration.
 
isys::CTestReportConfigSPtr getTestReportConfig (bool isConst)
 Returns test report configuration.
 
isys::CTestBaseListSPtr getTestFilters (bool isConst)
 Returns test filters.
 
isys::CTestFilterSPtr getTestFilter (const std::string &filterId)
 Returns test filter with the given ID, or NULL if the filter is not found.
 
isys::CTestGroupSPtr getGroup (bool isConst)
 Returns root group.
 
isys::CTestSpecificationSPtr getTestSpecification (bool isConst)
 Returns root test case. More...
 
std::string getWarnings ()
 If there were any warnings detected during parsing, this method returns non-empty string with description of warnings. More...
 
std::string getFileName ()
 Returns file from which this test bench data was loaded, or saved to.
 
void setFileName (const std::string &fileName)
 Sets name of the file this test bench is related to. More...
 
std::string getModelDirectory ()
 Returns directory of the model file.
 
void save (const std::string &fileName, bool isAppend=false, bool isSaveLineNumbers=false)
 Saves test bench configuration into the given file. More...
 
isys::CTestReportContainerSPtr getTestReportContainer ()
 Returns instance of class containing information for test reports.
 
isys::CTestFilterControllerSPtr getFilterController ()
 Returns reference to filter controller.
 
void refreshSymbolsAndGroupsIfEmpty (const CMulticoreConnectionMgrSPtr &mccmgr, const CTestEnvironmentConfigSPtr &customEnvConfig)
 Refreshes symbols and assigns test cases to groups, if none are initialized. More...
 
virtual bool isEmpty () const
 This method returns true, if the object contains no data.
 
virtual void serialize (const isys::IEmitterSPtr &emitter)
 Sends contents of this class to emitter.
 
virtual std::string toString ()
 Returns object data as YAML string.
 

Static Public Member Functions

static CTestBenchSPtr cast (CTestBaseSPtr &testBase)
 Casts the given object to this class. More...
 
static CTestBenchSPtr load (const std::string &fileName, size_t filePos=0)
 Loads test environment configuration and test specifications from the given file.
 
static CTestBenchSPtr parse (const std::string &yamlSpec)
 Parses test environment configuration and test specifications from the given string.
 
static void addUserInfoToReportConfig (const isys::CTestReportConfigSPtr &reportConfig, const std::string &testSpecificationFile, const std::string &winIDEAWorkspace, const std::string &winIDEAWorkspaceFile, const std::string &defaultDlFile)
 This method adds the following info to report config: More...
 
static void createDirIfNotExists (const std::string filePath)
 Creates directory for the given file path, if it does not exist. More...
 
static void saveTestResults (const isys::CTestReportContainerSPtr &testResults, isys::CTestReportConfigSPtr &reportConfig)
 This method saves test results into file in the specified format. More...
 
static void initTargetForTest (isys::CTestEnvironmentConfigSPtr &config, isys::CDebugFacadeSPtr &debug, isys::CIDEControllerSPtr &ideCtrl, int targetStopTimeout)
 Deprecated since 9.12.188, 2014-09-05, it works for old style init sequences only (download, reset, run, and runUntil actions are supported only and only in this order, no multicore support). More...
 
static bool execTestCaseInitSequence (isys::CTestCaseTargetInitConfigSPtr &testCaseInitConfig, isys::ConnectionMgrSPtr &connectionMgr, isys::CDebugFacadeSPtr &debug, int targetStopTimeout, bool isTestBatchOn)
 This function initializes target before execution of each test case. More...
 
static void configureBreakpointsMode (isys::CIDEControllerSPtr &ideCtrl, isys::CTestEnvironmentConfig::EBreakpointsType bpType, int coreIdx, bool isBeforeInit)
 This method configures type of breakpoints (software of hardware) as needed for target initialization. More...
 
static void configureStackUsage (CDataController2SPtr &dataCtrl, CTestEnvironmentConfigSPtr &runConfiguration, const std::string &coreIdParam)
 This method configures stack usage. More...
 
static bool isTestWithScripts (const isys::CTestSpecificationSPtr &testSpec)
 Returns true, if test contains scripts. More...
 

Protected Member Functions

void setStaticTagsAsConst ()
 This method is called by all objects which are immediately contained in CTestSpecification, for example CTestCoverage, CTestHIL, ...
 

Member Function Documentation

◆ addUserInfoToReportConfig()

static void isys::CTestBench::addUserInfoToReportConfig ( const isys::CTestReportConfigSPtr reportConfig,
const std::string &  testSpecificationFile,
const std::string &  winIDEAWorkspace,
const std::string &  winIDEAWorkspaceFile,
const std::string &  defaultDlFile 
)
static

This method adds the following info to report config:

  • path to test spec. file given as parameter
  • path to winIDEA workspace file given as parameter
  • SDK (testIDEA) version (automatically obtained)
  • current date and time if specified in 'reportConfig'.

◆ cast()

static CTestBenchSPtr isys::CTestBench::cast ( CTestBaseSPtr testBase)
static

Casts the given object to this class.

Returns NULL if input is NULL.

Exceptions
IllegalArgumentExceptionif input object is not instance of this class.

◆ configureBreakpointsMode()

static void isys::CTestBench::configureBreakpointsMode ( isys::CIDEControllerSPtr ideCtrl,
isys::CTestEnvironmentConfig::EBreakpointsType  bpType,
int  coreIdx,
bool  isBeforeInit 
)
static

This method configures type of breakpoints (software of hardware) as needed for target initialization.

Parameters
ideCtrlcontroller object needed to access winIDEA
bpTypetype of breakpoints
coreIdxindex of core for BP configuration
isBeforeInitshould be true, when this method is called before init sequence, false when it is called for the second time after init seq.

◆ configureStackUsage()

static void isys::CTestBench::configureStackUsage ( CDataController2SPtr dataCtrl,
CTestEnvironmentConfigSPtr runConfiguration,
const std::string &  coreIdParam 
)
static

This method configures stack usage.

Parameters
dataCtrlcontroller object needed to access winIDEA
runConfigurationobject containing stack measurement configurations
coreIdParamid of core for which stack usage measurement should be configured.

◆ createDirIfNotExists()

static void isys::CTestBench::createDirIfNotExists ( const std::string  filePath)
static

Creates directory for the given file path, if it does not exist.

If path does not contain file name, it must end with path separator.

◆ execTestCaseInitSequence()

static bool isys::CTestBench::execTestCaseInitSequence ( isys::CTestCaseTargetInitConfigSPtr testCaseInitConfig,
isys::ConnectionMgrSPtr connectionMgr,
isys::CDebugFacadeSPtr debug,
int  targetStopTimeout,
bool  isTestBatchOn 
)
static

This function initializes target before execution of each test case.

Parameters
testCaseInitConfiginitialization configuration
connectionMgrConnectionMgr with connection to winIDEA instance to initialize.
debugdebug facade
targetStopTimeouttimeout in milliseconds to wait for target to stop on the given function, address or breakpoint. TimeoutException is thrown in case of timeout.
isTestBatchOntrue test batch is on.

◆ getTestSpecification()

isys::CTestSpecificationSPtr isys::CTestBench::getTestSpecification ( bool  isConst)

Returns root test case.

This test case is a container only - it has no data set, but contains derived test cases (as they were defined in testIDEA, for example).

◆ getWarnings()

std::string isys::CTestBench::getWarnings ( )

If there were any warnings detected during parsing, this method returns non-empty string with description of warnings.

It is recommended to call this method always after parsing. This method calls getWarning() on all aggregated classes, so it is not necessary to call getWarning() on each of them.

◆ initTargetForTest()

static void isys::CTestBench::initTargetForTest ( isys::CTestEnvironmentConfigSPtr config,
isys::CDebugFacadeSPtr debug,
isys::CIDEControllerSPtr ideCtrl,
int  targetStopTimeout 
)
static

Deprecated since 9.12.188, 2014-09-05, it works for old style init sequences only (download, reset, run, and runUntil actions are supported only and only in this order, no multicore support).

Call 'executeInitAction' for all init actions in CTestEnvironmentConfig instead. Python has method PTestCase.executeInitSequence(), which replaces this method.

Initializes target according to settings in 'config' to be ready for unit tests.

Parameters
configinitialization configuration
debugdebug facade
ideCtrlide controller
targetStopTimeouttimeout in milliseconds to wait for target to stop on the given function, address or breakpoint. TimeoutException is thrown in case of timeout.

◆ isTestWithScripts()

static bool isys::CTestBench::isTestWithScripts ( const isys::CTestSpecificationSPtr &  testSpec)
static

Returns true, if test contains scripts.

Parameters
testSpecthe test spec. to be tested for usage of scripts

◆ refreshSymbolsAndGroupsIfEmpty()

void isys::CTestBench::refreshSymbolsAndGroupsIfEmpty ( const CMulticoreConnectionMgrSPtr mccmgr,
const CTestEnvironmentConfigSPtr customEnvConfig 
)

Refreshes symbols and assigns test cases to groups, if none are initialized.

To refresh possibly existing symbols in this object, first call: testBench.getFilterController().clear(); and then this method.

Parameters
mccmgrconnection object
customEnvConfigif you want to specify custom coreIds. If null, then object returned by call to getTestEnvironmentConfig(true) is used.

◆ save()

void isys::CTestBench::save ( const std::string &  fileName,
bool  isAppend = false,
bool  isSaveLineNumbers = false 
)

Saves test bench configuration into the given file.

Parameters
fileNamefile to save to
isAppendif true, new data is appended to the end of the file, otherwise any previous contents is erased.
isSaveLineNumbersif true, line numbers are assigned to test specifications when saved

◆ saveTestResults()

static void isys::CTestBench::saveTestResults ( const isys::CTestReportContainerSPtr &  testResults,
isys::CTestReportConfigSPtr reportConfig 
)
static

This method saves test results into file in the specified format.

Only XML, YAML and CSV files are supported by this function. XLS and XLSX (Excel) formats are available only from testIDEA, but CSV format can be easily imported to Excel.

Note for CSV format: Because there are three different tables stored (configuration, statistics, and results), three files are created for CSV format. File name specified in reportConfig gets appended '-config' and '-statistics' strings for configuration and statistics tables respectively.

Python example.

◆ setFileName()

void isys::CTestBench::setFileName ( const std::string &  fileName)

Sets name of the file this test bench is related to.

It should be always absolute, as this directory is considered as working directory, when relative path names are specified for other files in test spec (reports, diagrams, ...).