Frequently Asked Question
If the SUT code to be tested contains variables or parameters that are not part of the AUTOSAR-RTE, the testframe needs to be adjusted to make those variables available in TPT.
In this example the main code contains a condition like the following
The variable errorCase is only modifiable by some function that is not part of the Rte, like
In this example the function is declared in the file "LightsControlAtomic.h".
To make the variable errorCase available in TPT, this function needs to be called. TPT offers options to add patches to the generated testframe code. When the "Generate & Compile" button is pressed, some C-code is generated into the TPT output folder and compiled to create the executable that runs the testframe. The important file here is "testframe.c". This file is regenerated when you click on "Generate &Compile", but there are a few sections surrounded by "%%--- begin custom user code" and "%%--- end custom user code". Code between those sections will be kept when the testframe is regenerated. Code to add the custom variables must be added between those sections.
To make the variable errorCase available, the first step is to include the header file declaring this function. The proper place is between %%--- begin custom user code for init and %%--- end custom user code for init. At that place the header needs to be included and some helper-variable needs to be declared. This helper-variable needs to be added here to make it available in TPT.
So, combined you need to add:
#include "LightsControlAtomic.h" boolean TPT_errorCode;
between the two comments.
The next step is to make TPT_errorCode available in TPT. To achieve this, the variable needs to be created as a channel or parameter in TPT. This can be done in the declaration editor in TPT. The code to connect this variable to the testframe will be generated automatically. The additional channels or parameter can also be imported from an external file like an A2L file.
Now, the code needs to be added that calls the function setErrorCase() before the first testcase. This is different depending on the TPT version you are using.
In TPT-18, the preprocessor definition TPT_SAMPLERATE can be used that is used in each function call. To modify this, an additional header file "TPT_helper.h" can be created and define TPT_SAMPLERATE there. E.g
#define TPT_SAMPLERATE(x) setErrorCase(TPT_errorCode);
This file need to be stored underneath the Project root folder.
This file will automatically be included into your code by adding the filename to the AUTOSAR setting.
In TPT-19 the method setErrorCase(TPT_errorCode) can be added in the section %%--- begin custom user code for sutcycle start in the method sutcycle.
The example contains the patched testframe.c files and the examples for TPT-18 and TPT-19.
In case there are no setter and getter functions available, the variables need to be made available. Sometimes this can be done by including further headers to testframe.c. If the variables are static inside the relevant AUTOSAR code, this cannot be answered in general.
If the variables are made available in testframe.c you simply need to add the channels or parameters in TPT and TPT will automatically generate the code to connect the C variables in TPT. This also works for Arrays and Matrices.