winIDEA SDK
Loading...
Searching...
No Matches
isys::CTestBench Class Reference

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

#include <CTestBench.h>

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

Public Types

enum  ETestBenchSectionIds
 Ids of test specification sections.

Public Member Functions

virtual void assign (const CTestObjectSPtr &base)
 Assigns members of base to this.
void calculateGroupResults (const CMulticoreConnectionMgrSPtr &mcmgr, const CTestEnvironmentConfigSPtr &envConfig)
bool containsSection (int section) const
 Returns true, if the specified section exists for this object.
virtual CTestObjectSPtr copy () const
 Creates a deep copy of this object.
CTestBaseSPtr createInstance (const CTestBaseSPtr &parent) const
CTestBaseSPtr createTestBase (int section, size_t lineNo=IEmitter::LINE_NUM_NOT_SET) const
 CTestBench ()
std::string getClassName () const
virtual CTestTreeNodeSPtr getContainerTestNode ()
 virtual CTestSpecificationSPtr getContainerTestSpec();
int getEnumTagValue (int section)
 Returns value of enum type.
std::string getFileName ()
 Returns file from which this test bench data was loaded, or saved to.
isys::CTestFilterControllerSPtr getFilterController ()
 Returns reference to filter controller.
isys::CTestGroupSPtr getGroup (bool isConst)
 Returns root group.
std::string getModelDirectory ()
 Returns directory of the model file.
CTestBaseSPtr getParent () const
 Returns parent.
int getSectionId (const std::string &sectionName)
 Returns section ID for the given section name.
CTestBaseSPtr getTestBase (int section, bool isConst)
CTestBaseListSPtr getTestBaseList (int section, bool isConst)
isys::CTestEnvironmentConfigSPtr getTestEnvironmentConfig (bool isConst)
 Returns test environment configuration.
isys::CTestFilterSPtr getTestFilter (const std::string &filterId)
 Returns test filter with the given ID, or NULL if the filter is not found.
isys::CTestBaseListSPtr getTestFilters (bool isConst)
 Returns test filters.
CTestObject::ETestObjType getTestObjType () const
 Returns type of this object, which is CTestObject::ETestBase.
isys::CTestReportConfigSPtr getTestReportConfig (bool isConst)
 Returns test report configuration.
isys::CTestReportContainerSPtr getTestReportContainer ()
 Returns instance of class containing information for test reports.
isys::CTestSpecificationSPtr getTestSpecification (bool isConst)
 Returns root test case.
std::string getWarnings ()
 If there were any warnings detected during parsing, this method returns non-empty string with description of warnings.
virtual bool isEmpty () const
 This method returns true, if the object contains no data.
bool isSectionEmpty (int sectionId)
 Returns true, if the given section is empty.
virtual bool isSerializedAsList (bool isParsing)
 Returns true if object should be serialized as list, for example CTestFunction.
void refreshSymbolsAndGroupsIfEmpty (const CMulticoreConnectionMgrSPtr &mccmgr, const CTestEnvironmentConfigSPtr &customEnvConfig)
 Refreshes symbols and assigns test cases to groups, if none are initialized.
void save (const std::string &fileName, bool isAppend=false, bool isSaveLineNumbers=false)
 Saves test bench configuration into the given file.
virtual void serialize (const isys::IEmitterSPtr &emitter)
 Sends contents of this class to emitter.
virtual void setComment (int section, int idx, const std::string &nlComment, const std::string &eolComment)
void setEnumTagValue (int section, int enumValue)
 Sets value of enum type.
void setFileName (const std::string &fileName)
 Sets name of the file this test bench is related to.
virtual void setMainMapStyle (isys::IEmitter::EYamlStyle mappingStyle)
 Sets style of the mapping for complete object.
void setParent (CTestBaseSPtr parent)
 Sets parent.
void setTestSpecification (isys::CTestSpecificationSPtr &testSpec)
 Assigns root test specification.
virtual std::string toString ()
 Returns object data as YAML string.

Static Public Member Functions

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:
static CTestBenchSPtr cast (CTestBaseSPtr &testBase)
 Casts the given object to this class.
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.
static void configureStackUsage (CDataController2SPtr &dataCtrl, CTestEnvironmentConfigSPtr &runConfiguration, const std::string &coreIdParam)
 This method configures stack usage.
static void createDirIfNotExists (const std::string filePath)
 Creates directory for the given file path, if it does not exist.
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.
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).
static bool isTestWithScripts (const isys::CTestSpecificationSPtr &testSpec)
 Returns true, if test contains scripts.
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 saveTestResults (const isys::CTestReportContainerSPtr &testResults, isys::CTestReportConfigSPtr &reportConfig)
 This method saves test results into file in the specified format.

Protected Member Functions

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

Detailed 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)
59 root_test_spec = test_bench.getTestSpecification(True)

Python example: filter_tests.py

Constructor & Destructor Documentation

◆ CTestBench()

isys::CTestBench::CTestBench ( )
Since
9.12.288

Member Function Documentation

◆ addUserInfoToReportConfig()

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'.

◆ assign()

virtual void isys::CTestBase::assign ( const CTestObjectSPtr & base)
virtualinherited

Assigns members of base to this.

Since
9.12.288

Reimplemented in isys::CTestFunction.

◆ calculateGroupResults()

void isys::CTestBench::calculateGroupResults ( const CMulticoreConnectionMgrSPtr & mcmgr,
const CTestEnvironmentConfigSPtr & envConfig )
Since
9.12.288

◆ cast()

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()

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()

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.

◆ containsSection()

bool isys::CTestBase::containsSection ( int section) const
inherited

Returns true, if the specified section exists for this object.

Since
9.12.288

◆ copy()

virtual CTestObjectSPtr isys::CTestBase::copy ( ) const
virtualinherited

Creates a deep copy of this object.

Parent is set.

Since
9.12.288

◆ createDirIfNotExists()

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.

◆ createInstance()

CTestBaseSPtr isys::CTestBench::createInstance ( const CTestBaseSPtr & parent) const
virtual
Since
9.12.288

Implements isys::CTestBase.

◆ createTestBase()

CTestBaseSPtr isys::CTestBench::createTestBase ( int section,
size_t lineNo = IEmitter::LINE_NUM_NOT_SET ) const
virtual
Since
9.12.288

Reimplemented from isys::CTestBase.

◆ execTestCaseInitSequence()

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.

◆ getClassName()

std::string isys::CTestBase::getClassName ( ) const
inherited
Since
9.12.288

◆ getContainerTestNode()

virtual CTestTreeNodeSPtr isys::CTestBase::getContainerTestNode ( )
virtualinherited

virtual CTestSpecificationSPtr getContainerTestSpec();

Since
9.12.288

◆ getEnumTagValue()

int isys::CTestBase::getEnumTagValue ( int section)
inherited

Returns value of enum type.

Since
9.12.288

◆ getFileName()

std::string isys::CTestBench::getFileName ( )

Returns file from which this test bench data was loaded, or saved to.

Since
9.12.288

◆ getFilterController()

isys::CTestFilterControllerSPtr isys::CTestBench::getFilterController ( )

Returns reference to filter controller.

Since
9.12.288

◆ getGroup()

isys::CTestGroupSPtr isys::CTestBench::getGroup ( bool isConst)

Returns root group.

Since
9.12.288

◆ getModelDirectory()

std::string isys::CTestBench::getModelDirectory ( )

Returns directory of the model file.

Since
9.12.288

◆ getParent()

CTestBaseSPtr isys::CTestBase::getParent ( ) const
inherited

Returns parent.

Since
9.12.288

◆ getSectionId()

int isys::CTestBase::getSectionId ( const std::string & sectionName)
inherited

Returns section ID for the given section name.

Since
9.12.288

◆ getTestBase()

CTestBaseSPtr isys::CTestBase::getTestBase ( int section,
bool isConst )
inherited
Since
9.12.288

◆ getTestBaseList()

CTestBaseListSPtr isys::CTestBase::getTestBaseList ( int section,
bool isConst )
inherited
Since
9.12.288

◆ getTestEnvironmentConfig()

isys::CTestEnvironmentConfigSPtr isys::CTestBench::getTestEnvironmentConfig ( bool isConst)

Returns test environment configuration.

Since
9.12.288

◆ getTestFilter()

isys::CTestFilterSPtr isys::CTestBench::getTestFilter ( const std::string & filterId)

Returns test filter with the given ID, or NULL if the filter is not found.

Since
9.12.288

◆ getTestFilters()

isys::CTestBaseListSPtr isys::CTestBench::getTestFilters ( bool isConst)

Returns test filters.

Since
9.12.288

◆ getTestObjType()

CTestObject::ETestObjType isys::CTestBase::getTestObjType ( ) const
inherited

Returns type of this object, which is CTestObject::ETestBase.

Since
9.12.288

◆ getTestReportConfig()

isys::CTestReportConfigSPtr isys::CTestBench::getTestReportConfig ( bool isConst)

Returns test report configuration.

Since
9.12.288

◆ getTestReportContainer()

isys::CTestReportContainerSPtr isys::CTestBench::getTestReportContainer ( )

Returns instance of class containing information for test reports.

Since
9.12.288

◆ 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).

Since
9.12.288

◆ 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.

Since
9.12.288

◆ initTargetForTest()

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.

◆ isEmpty()

virtual bool isys::CTestBase::isEmpty ( ) const
virtualinherited

This method returns true, if the object contains no data.

Since
9.12.288

◆ isSectionEmpty()

bool isys::CTestBase::isSectionEmpty ( int sectionId)
inherited

Returns true, if the given section is empty.

Since
9.12.288

◆ isSerializedAsList()

virtual bool isys::CTestBase::isSerializedAsList ( bool isParsing)
virtualinherited

Returns true if object should be serialized as list, for example CTestFunction.

Since
9.12.288

Reimplemented in isys::CTestFunction.

◆ isTestWithScripts()

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.
Since
9.12.288

◆ 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
Since
9.12.288

◆ saveTestResults()

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: create_test_report.py

◆ serialize()

virtual void isys::CTestBase::serialize ( const isys::IEmitterSPtr & emitter)
virtualinherited

Sends contents of this class to emitter.

Since
9.12.288

Reimplemented in isys::CLogResult, and isys::CTestEnvironmentConfig.

◆ setComment()

virtual void isys::CTestBase::setComment ( int section,
int idx,
const std::string & nlComment,
const std::string & eolComment )
virtualinherited
Since
9.12.288

◆ setEnumTagValue()

void isys::CTestBase::setEnumTagValue ( int section,
int enumValue )
inherited

Sets value of enum type.

Since
9.12.288

◆ 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, ...).

Since
9.12.288

◆ setMainMapStyle()

virtual void isys::CTestBase::setMainMapStyle ( isys::IEmitter::EYamlStyle mappingStyle)
virtualinherited

Sets style of the mapping for complete object.

Since
9.12.288

◆ setParent()

void isys::CTestBase::setParent ( CTestBaseSPtr parent)
inherited

Sets parent.

Since
9.12.288

◆ setTestSpecification()

void isys::CTestBench::setTestSpecification ( isys::CTestSpecificationSPtr & testSpec)

Assigns root test specification.

Since
9.12.288

◆ toString()

virtual std::string isys::CTestBase::toString ( )
virtualinherited

Returns object data as YAML string.

Since
9.12.288