Controller Tester provides several macros to help users write test code more easily. You can check and write the macro provided using the shortcut(Ctrl + Spacebar) in the Test Editor.

ASSERT macro

Examine the conditional expression and print the success/failure in the Test Case Tab.

Macro Parameter Example
CS_ASSERT(_b) _b: conditional expression CS_ASSERT(val!=1);
CS_ASSERT_MSG(_B, _msg) _B: conditional expression
_mgs: message to print when the conditional expression is false
CS_ASSERT_MSG(val==1, "val is not 1!");

Output macro

Print the values of specific variables in the Test Case Tab.

Macro Parameter Example
CS_INT_OUTPUT(_v, _s)
CS_UINT_OUTPUT(_v, _s)
CS_FLT_OUTPUT(_v, _s)
CS_STR_OUTPUT(_v, _s)
v: a variable to print the value
_s: a name to show in the Test Case Tab
CS_INT_OUTPUT(int_var, "int_var_name");
CS_UINT_OUTPUT(unsigned_int_var, "unsigned_int_var_name");
CS_FLT_OUTPUT(float_var, "float_var_name");
CS_STR_OUTPUT(string_var, "string_var_name");

Input macro

Pass test data to the function under test.

Macro Parameter Example
CS_INT_INPUT(_t, _s)
CS_UINT_INPUT(_t, _s)
CS_FLT_INPUT(_t, _s)
CS_STR_INPUT(_t, _s)
_t: a type of the variable
_s: a name to show in the Test Case Tab
CS_INT_INPUT(int, "int_var_name");
CS_UINT_INPUT(unsigned int, "unsigned_int_var_name");
CS_FLT_INPUT(float, "float_var_name");
CS_STR_INPUT(char*, "string_var_name");

Address-related macros

If there is a part that directly assigns or fetches the value in the embedded address in the converted source code, it may not operate normally when executed on the local computer. In this case, you can use an address-related macro for the virtual address.

Macro Description
CS_VIRTUAL_ADDR(_b,_e) Creates the space from the address (_b) to the address (_e)
CS_ADDR_ASSIGN(_t,_a,_v)
CS_ADDR_SET(_t,_a,_v)
Assigns the value (_v) of type (_t) to the address (_a)
CS_ADDR_GET(_t,_a) Fetches the value of type (_t) from the address (_a)
CS_VIRTUAL_ADDR_CLEAR() Frees the memory space created

Address-related macro example

// Create a virtual memory area of size 100 from 0xFFE40000U.
CS_VIRTUAL_ADDR(0xFFE40000U, 0xFFE40000U+100);

// Assign value 10 of int type to 0xFFE40000U
CS_ADDR_ASSIGN(int ,0xFFE40000U, 10);
CS_ADDR_SET(int ,0xFFE40000U, 10);

// Return the value from 0xFFE40000U to the variable a.
int a = CS_ADDR_GET(int ,0xFFE40000U);

// Return an address of 0xFFE40000U into variable ptr of pointer type.
int* ptr = CS_ADDR_PTR(0xFFE40000U);

// Frees the memory space created.
CS_VIRTUAL_ADDR_CLEAR();

Other macros

Macro Parameter Description Example
CS_LOG(_msg) _msg: log message Outputs user log CS_LOG("User Log");
CS_TESTCASENO() Returns the number of the test currently running int testCaseNum = CS_TESTCASENO();

Need more help with this?
Don’t hesitate to contact us here.

Thanks for your feedback.