From 4ee0b6b589b7dc52aaba697ee9b2a230bdb266b7 Mon Sep 17 00:00:00 2001 From: jing wang Date: Tue, 8 Nov 2016 09:38:51 +0800 Subject: [PATCH] tests: provide MACRO to easily wrap test function to shell command usage is as below: TC_CMD_DEFINE(test_func_1) TC_CMD_DEFINE(test_func_2) static const struct shell_cmd commands[] = { TC_CMD_ITEM(test_func_1), TC_CMD_ITEM(test_func_2), { NULL, NULL } }; SHELL_REGISTER("runtest", commands); Change-Id: I4eab67113954f373d5a2cbfaa729be180fd31444 Signed-off-by: jing wang --- tests/include/tc_util.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/include/tc_util.h b/tests/include/tc_util.h index 85a3e8fff16..d2b18a9ecb9 100644 --- a/tests/include/tc_util.h +++ b/tests/include/tc_util.h @@ -22,6 +22,7 @@ #include #include +#include #if defined(CONFIG_STDOUT_CONSOLE) #include @@ -98,4 +99,14 @@ (result) == TC_PASS ? "SUCCESSFUL" : "FAILED"); \ } while (0) +#define TC_CMD_DEFINE(name) \ + int cmd_##name(int argc, char *argv[]) \ + { \ + TC_START(__func__); \ + name(); \ + TC_END_RESULT(TC_PASS); \ + return 0; \ + } + +#define TC_CMD_ITEM(name) {STRINGIFY(name), cmd_##name, "none"} #endif /* __TC_UTIL_H__ */