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 a static variable inside of the AUTOSAR c code.
The c standard is meant to make static variables not accessible outside of the file that declares them, so a little patching is necessary. In this example a folder "TPT_Patches" was added and placed next to the folder containing the implementation of the SUT to be tested.
One file inside of this folder is a header file called "TPT_Helper.h". This file includes some AUTOSAR header to make the datatype available. Afterwards a variable
is declared which will later be connected to TPT. 2 functions to copy variables are also declared, those functions will be used to copy the variables that are connected to TPT to the SUT variables and to copy the SUT variables to TPT. Additionaly we define TPT_SAMPLERATE to enable the call of the copy function before the call of the runnable (note that this is not necessary with TPT-19, and may cause issues if more runnables are connected).
To patch the actual "LightsControlAtomic.c" file a file "LightsControlAtomicPatch.c" is added. This file uses a #include preprocessor statement which will copy the original source code to this file. You may need to adapt that path. The static variables from the original c code are therefore available in this file.
Inside of this file we implement the copy functions. After the #include statement the static variables are available.
As last measure we need to patch the testframe.c generated by TPT. There is a place in the code where manually added code is retained on regeneration. The method copyStaticVariablesToTPTVariables() needs to be added there.
For TPT-19, the "#define TPT_SAMPLERATE(x) copyTPTVariablesToStaticVariables();" in TPT_Helper.h is not necessary anymore instead the call of the function copyTPTVariablesToStaticVariables() needs to be added in the custom code block in sutcycle.
To make the channel in TPT available the TPT_Helper.h needs to be set in the AUTOSAR platform and the "TPT_Patches" folder needs to be added as include folder in the AUTOSAR platform.
At last step the channel needs to be added to the TPT project. To do this open the declaration editor in TPT and add a new channel called errorCase. Select the mapping from the AUTOSAR platform and set the External_Name to TPT_errorCase. This step sets the TPT-variable "errorCase" to the C-variable TPT_errorCase.
The example is focused on a primitive variable, but the mechanic works equally with structures or arrays.