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 <jing.j.wang@intel.com>
This commit is contained in:
jing wang 2016-11-08 09:38:51 +08:00 committed by Anas Nashif
commit 4ee0b6b589

View file

@ -22,6 +22,7 @@
#include <zephyr.h>
#include <string.h>
#include <misc/shell.h>
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
@ -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__ */