Glossary
| Acronym | Definition |
|---|---|
| SUT | System Under Test |
| CSE | Communication & Scheduling Entity |
| SM | State Machine |
| Tal | Targeted Application Layer |
| TAM | Target Abstraction Module |
Glossary
Referenced Documents
General ConceptsPrinciple of the testsThe Component Tester turns the generated code of a component into a System Under Test (SUT) compiled as a shared library, and provides two layers of APIs to drive and observe it from a test case:
A test case is a piece of C or C++ code that:
The execution is driven by virtual
time: the SUT does not run in real time. The test case
explicitly advances time with Component Tester ArchitectureThe Component Tester is composed of an executable and a shared library. The shared library is compiled with the source code generated by the operations UML to C and UML to C++. It may also be compiled with the test cases, if any. The executable loads the shared library, manages the test cases, schedules the execution and logs the results.
+-------------------------------------------------------------+
| Tester / executable |
| http Server Test cases Manager Exec. scheduler Logger|
+-------------------------------------------------------------+
| loads
v
+-------------------------------------------------------------+
| System Under Test / shared library |
| |
| Component (Target independent |
| & dependent) |
| Communication & Scheduling Component (Target independent) |
| |
| Tester Target Abstraction Layer: |
| Shared Objects | Hooks | Test case | Scheduler | |
| Tracer | Memory | Timer | Api |
+-------------------------------------------------------------+
Development EnvironmentVSCodeThe development environment can rely on the VSCode software. VSCode eases the development activity: code development, compilation, execution including debug. Note that the Component Tester can be used in an alternative environment. In such a case, it may require additional user-specific configuration. The installation of VSCode is described in VS Code installation. MSYS2The Component Tester Generator provides an environment already compiled and ready for execution. Nevertheless, it may be required to recompile the project locally following a code change, or the user may need to debug the application. In both cases, MSYS2 may be required. The installation of MSYS2 is described in MSYS2 installation. Observability of behaviors
The behavior monitoring part of the API (active state / transition
of state machines, active node / flows of activities, and event
injection) is available only when the SUT
and the harness are generated with instrumented code.
See the Naming conventionsThe model-specific API uses a function suffix derived from the path of the element in the component, with a prefix identifying its kind:
Component Tester UsageVS Code installationGo to https://code.visualstudio.com/download and follow the instructions to install VSCode. Install the C/C++ extension to enable application execution and debugging: ![]() MSYS2 installationTo take advantage of all the capabilities delivered by the Component Tester, we advise installing MSYS2. To do so, go to https://www.msys2.org/ and install MSYS2. Note that installing MSYS2 in the default directory simplifies the configuration of your environment.
To enable compilation, install
pacman -S make pacman -S mingw-w64-x86_64-gcc
To enable debugging, install
pacman -S mingw-w64-x86_64-gdb Tester Command Line Parameters
The Component Tester is composed of an executable compatible with
Windows 64-bit (named
The tester supports command line parameters. Each parameter is
identified with a <path to tester>\Tester.exe [PARAMETER] ... -dll [FILE] ...
Running
Usage: Tester [OPTION] ... -dll [FILE] ...
Execute a test sequence on a system under test contained in the DLL.
-dll <dll path> [Mandatory] absolute/relative path to the
dll containing the model.
-report <name> [Optional|Default:TestReport] name of the report file
referencing the general informations of the test execution.
-logName <name> [Optional|Default:TestLog] default log name given when log
files are created.
-timestamp <true/false> [Optional|Default:true] indicate if timestamp must be
added at the end of the generated report and logs.
-logDirectory <directory> [Optional|Default:current dir] directory where report and logs
are stored.
-enableLogging <true/false> [Optional|Default:true] enable or disable logging
mechanism. If set to false, neither the report nor logs are
generated.
-logLevel <N0/N1/N2/N3/N4/N5> [Optional|Default:N5] level of details printed in log.
N0 means nothing, N5 means everything.
-httpServer <true/false> [Optional|Default:false] start or not http server to
communicate with tester.
-port <number> [Optional] port number on which server is
listening. Mandatory if startServer is set to "true"
-listTestCases [Optional] list the test cases availables
in the dll provided via -dll option and exit.
-executeTestCases <true/false>[Optional|Default:true] execute test cases if set to
true. If set to false, no test case is executed. False is
only permitted if -httpServer is set to true.
-testCases <tc1 tc2 ...> [Optional] execute the listed test cases.
If no testcase is provided, all the available tests are
executed.
-verbose [Optional] activate verbose mode to get
more details during execution.
-help [Optional] display this help and exit.
The parameters are detailed below. dll parameter
report parameter
logName parameter
timestamp parameter
logDirectory parameter
enableLogging parameter
logLevel parameter
httpServer parameter
port parameter
listTestCases parameter
executeTestCases parameter
testCases parameter
verbose parameter
help parameter
Test Case Format
A test case includes the data types of the SUT and the two API headers: #include "Cse_cfg.h" // data types (Integer, Boolean, String, ...) #include "TestCase_Api.h" // model-independent API #include "TestCase_Api_Gen.h" // model-specific API generated for the component
The test data types are: C test case
A C test case is a collection of tests, each declared with the
macro
#include "Cse_cfg.h"
#include "TestCase_Api.h"
#include "TestCase_Api_Gen.h"
TEST(C_test){
Log_Info("C_test startup");
Sut_Runduring(10); // run the SUT during 10 virtual seconds
}
C++ test case
A C++ test case is a class declaring a collection of tests with
the macro
#include "Cse_cfg.h"
#include "TestCase_Api.h"
#include "TestCase_Api_Gen.h"
class Cpp_TestCase {
public:
TEST_DECL(Cpp_test);
};
TEST(Cpp_TestCase, Cpp_test){
Log_Info("Cpp_test startup");
Sut_Runduring(10);
}
Test cases are placed in the Model-Independent APIs
These APIs are declared in Logging
The logging macros accept a printf-style format string and arguments. Traceability
Time and scheduling
Advancing the virtual time is required for the SUT to react: events injected or data written by the test case are processed by the scheduler while time advances. Generic checks
Check kinds
The model-specific
Access counter flagsFor interface elements, an access counter can be configured to monitor how often a data is accessed. The configuration flags are:
Model-Specific APIs
These APIs are declared in
Server operations exposed on ports are callable:
For interface shared variables, the access counter APIs are also
generated: Behavior members (instrumented code)
When the harness is generated with instrumented code, each state
machine and activity exposes, through
The instrumented value of a state / node is a
Event injection (instrumented code)When the harness is generated with instrumented code, each behavior exposes an event injection function that sends an event directly to the input event pool of that behavior: Send_<suffix>(eventId);
Example
The following C++ test case (extract) drives the
#include "Cse_cfg.h"
#include "TestCase_Api.h"
#include "TestCase_Api_Gen.h"
class StopwatchUML {
public:
TEST_DECL(Cpp_test);
};
#define SETTLE 0.5 // virtual seconds left to the scheduler to propagate an event
TEST(StopwatchUML, Cpp_test){
Traca_TestCase_Title("StopwatchUML - event-driven state machines");
Traca_TestCase_Description(
"Inject StartStop / LapReset into the Controller and verify the "
"Controller (IDLE/Running/Paused) and Timer (Stopped/Running) state machines.");
// Expected instrumented states: "<State> (<uuid>)"
char ctrlIdleStr[] = "IDLE (...)";
char ctrlRunningStr[] = "Running (...)";
String pCtrlIdle = ctrlIdleStr;
String pCtrlRunning = ctrlRunningStr;
Boolean bTrue = TRUE;
// 1. Initialisation: each SM reaches its stable initial state
Log_Info("SUT initialisation");
Sut_Runduring(SETTLE);
Traca_Check_Description("Initial state: Controller = IDLE");
Check_Stopwatch_controller_..._state_...(EQ, &pCtrlIdle);
// 2. StartStop -> IDLE -> Running (the Timer starts)
Log_Info("StartStop #1 -> start");
Send_Stopwatch_controller(CONTROLLER_EVENT_T_StartStop);
Sut_Runduring(SETTLE);
Traca_Check_Description("Controller = Running");
Check_Stopwatch_controller_..._state_...(EQ, &pCtrlRunning);
Traca_Check_Description("Timer.isRunning = true");
Check_Stopwatch_timer_isRunning(EQ, &bTrue);
Log_Info("Cpp_test done");
}
Test Execution and Results
When run, a test case produces a log file. Each
[INFO] 0.500 - CHKDESC: Initial state: Controller = IDLE [OK] 0.500 - CHECK: state_... - Current: IDLE (...) == Expected: IDLE (...) ... ============================================================================ Total checks: 17 - Passed: 16 - Failed: 1 ============================================================================ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||