Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
tc_util.h File Reference
#include <zephyr/kernel.h>
#include <string.h>
#include <zephyr/sys/printk.h>

Go to the source code of this file.

Macros

#define PRINT_DATA(fmt, ...)
 
#define TC_STR_HELPER(x)
 
#define TC_STR(x)
 
#define TC_PRINT_RUNID   do {} while (false)
 Report a Run ID.
 
#define PRINT_LINE
 
#define TASK_STACK_SIZE   (1024 * 2)
 
#define FMT_ERROR   "%s - %s@%d. "
 
#define TC_PASS   0
 
#define TC_FAIL   1
 
#define TC_SKIP   2
 
#define TC_FLAKY   3
 
#define TC_PASS_STR   "PASS"
 
#define TC_FAIL_STR   "FAIL"
 
#define TC_SKIP_STR   "SKIP"
 
#define TC_FLAKY_STR   "FLAKY"
 
#define TC_ERROR(fmt, ...)
 
#define TC_PRINT(fmt, ...)
 
#define TC_SUMMARY_PRINT(fmt, ...)
 
#define TC_START_PRINT(name)
 
#define TC_START(name)
 
#define TC_END(result, fmt, ...)
 
#define TC_END_PRINT(result, fmt, ...)
 
#define TC_END_RESULT(result)
 
#define TC_END_RESULT_CUSTOM(result, func)
 
#define TC_SUITE_PRINT(fmt, ...)
 
#define TC_SUITE_START(name)
 
#define TC_SUITE_END(name, result)
 
#define TC_END_POST(result)
 
#define TC_END_REPORT(result)
 
#define TC_CMD_DEFINE(name)
 
#define TC_CMD_ITEM(name)
 

Functions

static const char * TC_RESULT_TO_STR (int result)
 
static void get_start_time_cyc (void)
 
static void get_test_duration_ms (void)
 
static void print_nothing (const char *fmt,...)
 

Variables

static uint32_t tc_start_time
 
static uint32_t tc_spend_time
 

Macro Definition Documentation

◆ FMT_ERROR

#define FMT_ERROR   "%s - %s@%d. "

◆ PRINT_DATA

#define PRINT_DATA ( fmt,
... )
Value:
printk(fmt, ##__VA_ARGS__)
static void printk(const char *fmt,...)
Print kernel debugging message.
Definition printk.h:51

◆ PRINT_LINE

#define PRINT_LINE
Value:
"============================================================" \
"=======\n")
#define PRINT_DATA(fmt,...)
Definition tc_util.h:25

◆ TASK_STACK_SIZE

#define TASK_STACK_SIZE   (1024 * 2)

◆ TC_CMD_DEFINE

#define TC_CMD_DEFINE ( name)
Value:
int cmd_##name(int argc, char *argv[]) \
{ \
TC_START(__func__); \
name(); \
TC_END_RESULT(TC_PASS); \
return 0; \
}
#define TC_PASS
Definition tc_util.h:67

◆ TC_CMD_ITEM

#define TC_CMD_ITEM ( name)
Value:
{STRINGIFY(name), cmd_##name, "none"}
#define STRINGIFY(s)
Definition common.h:134

◆ TC_END

#define TC_END ( result,
fmt,
... )
Value:
PRINT_DATA(fmt, ##__VA_ARGS__)

◆ TC_END_POST

#define TC_END_POST ( result)

◆ TC_END_PRINT

#define TC_END_PRINT ( result,
fmt,
... )
Value:
static void print_nothing(const char *fmt,...)
Definition tc_util.h:124

◆ TC_END_REPORT

#define TC_END_REPORT ( result)
Value:
do { \
TC_END(result, \
"PROJECT EXECUTION %s\n", \
(result) == TC_PASS ? "SUCCESSFUL" : "FAILED"); \
TC_END_POST(result); \
} while (false)
#define TC_PRINT_RUNID
Report a Run ID.
Definition tc_util.h:52
#define PRINT_LINE
Definition tc_util.h:56

◆ TC_END_RESULT

#define TC_END_RESULT ( result)
Value:
Z_TC_END_RESULT((result), __func__)

◆ TC_END_RESULT_CUSTOM

#define TC_END_RESULT_CUSTOM ( result,
func )
Value:
Z_TC_END_RESULT((result), func)

◆ TC_ERROR

#define TC_ERROR ( fmt,
... )
Value:
do { \
PRINT_DATA(FMT_ERROR, "FAIL", __func__, __LINE__); \
PRINT_DATA(fmt, ##__VA_ARGS__); \
} while (false)
#define FMT_ERROR
Definition tc_util.h:65

◆ TC_FAIL

#define TC_FAIL   1

◆ TC_FAIL_STR

#define TC_FAIL_STR   "FAIL"

◆ TC_FLAKY

#define TC_FLAKY   3

◆ TC_FLAKY_STR

#define TC_FLAKY_STR   "FLAKY"

◆ TC_PASS

#define TC_PASS   0

◆ TC_PASS_STR

#define TC_PASS_STR   "PASS"

◆ TC_PRINT

#define TC_PRINT ( fmt,
... )
Value:
print_nothing(fmt, ##__VA_ARGS__)

◆ TC_PRINT_RUNID

#define TC_PRINT_RUNID   do {} while (false)

Report a Run ID.

When the CPP symbol TC_RUNID is defined (for example, from the compile environment), print the defined string RunID: <TC_RUNID> when called (TC_END_REPORT() will also call it).

This is used mainly when automating the execution and running of multiple test cases, to verify that the expected image is being executed (as sometimes the targets fail to flash or reset properly).

TC_RUNID is any string, that will be converted to a string literal.

◆ TC_SKIP

#define TC_SKIP   2

◆ TC_SKIP_STR

#define TC_SKIP_STR   "SKIP"

◆ TC_START

#define TC_START ( name)
Value:
do { \
TC_START_PRINT(name); \
} while (0)

◆ TC_START_PRINT

#define TC_START_PRINT ( name)
Value:

◆ TC_STR

#define TC_STR ( x)
Value:
#define TC_STR_HELPER(x)
Definition tc_util.h:47

◆ TC_STR_HELPER

#define TC_STR_HELPER ( x)
Value:
#x

◆ TC_SUITE_END

#define TC_SUITE_END ( name,
result )
Value:
do { \
if (result != TC_FAIL) { \
TC_SUITE_PRINT("TESTSUITE %s succeeded\n", name); \
} else { \
TC_SUITE_PRINT("TESTSUITE %s failed.\n", name); \
} \
} while (false)
#define TC_FAIL
Definition tc_util.h:68

◆ TC_SUITE_PRINT

#define TC_SUITE_PRINT ( fmt,
... )
Value:
PRINT_DATA(fmt, ##__VA_ARGS__)

◆ TC_SUITE_START

#define TC_SUITE_START ( name)
Value:
do { \
TC_SUITE_PRINT("Running TESTSUITE %s\n", name); \
} while (false)

◆ TC_SUMMARY_PRINT

#define TC_SUMMARY_PRINT ( fmt,
... )
Value:
PRINT_DATA(fmt, ##__VA_ARGS__)

Function Documentation

◆ get_start_time_cyc()

static void get_start_time_cyc ( void )
inlinestatic

◆ get_test_duration_ms()

static void get_test_duration_ms ( void )
inlinestatic

◆ print_nothing()

static void print_nothing ( const char * fmt,
... )
inlinestatic

◆ TC_RESULT_TO_STR()

static const char * TC_RESULT_TO_STR ( int result)
inlinestatic

Variable Documentation

◆ tc_spend_time

uint32_t tc_spend_time
static

◆ tc_start_time

uint32_t tc_start_time
static