summaryrefslogtreecommitdiff
path: root/components/utilities
diff options
context:
space:
mode:
authorMurphyZhao <[email protected]>2019-02-13 09:37:26 +0800
committerMurphyZhao <[email protected]>2019-02-13 14:37:08 +0800
commit82f022f6f0e975243e25888c5ba8b5dfb37fd4f6 (patch)
tree67dc0a830fcdf176b4fde4b405fba77487c914ec /components/utilities
parent821c81e21a5dbe2b229fae5fafbcfb4fc6758343 (diff)
[components][utest] 增加 utest 线程模式
Signed-off-by: MurphyZhao <[email protected]>
Diffstat (limited to 'components/utilities')
-rw-r--r--components/utilities/Kconfig9
-rw-r--r--components/utilities/utest/utest.c46
2 files changed, 49 insertions, 6 deletions
diff --git a/components/utilities/Kconfig b/components/utilities/Kconfig
index 8e43cfa0a0..1175006a58 100644
--- a/components/utilities/Kconfig
+++ b/components/utilities/Kconfig
@@ -234,4 +234,13 @@ config RT_USING_UTEST
bool "Enable utest (RT-Thread test framework)"
default n
+ if RT_USING_UTEST
+ config UTEST_THR_STACK_SIZE
+ int "The utest thread stack size"
+ default 4096
+ config UTEST_THR_PRIORITY
+ int "The utest thread priority"
+ default 20
+ endif
+
endmenu
diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c
index a0a42d7438..ee9710c0df 100644
--- a/components/utilities/utest/utest.c
+++ b/components/utilities/utest/utest.c
@@ -32,6 +32,18 @@
#error "RT_CONSOLEBUF_SIZE is less than 256!"
#endif
+#ifdef UTEST_THR_STACK_SIZE
+#define UTEST_THREAD_STACK_SIZE UTEST_THR_STACK_SIZE
+#else
+#define UTEST_THREAD_STACK_SIZE (4096)
+#endif
+
+#ifdef UTEST_THR_PRIORITY
+#define UTEST_THREAD_PRIORITY UTEST_THR_PRIORITY
+#else
+#define UTEST_THREAD_PRIORITY FINSH_THREAD_PRIORITY
+#endif
+
static rt_uint8_t utest_log_lv = UTEST_LOG_ALL;
static utest_tc_export_t tc_table = RT_NULL;
static rt_size_t tc_num;
@@ -163,24 +175,46 @@ __tc_continue:
static void utest_testcase_run(int argc, char** argv)
{
- char utest_name[UTEST_NAME_MAX_LEN];
+ void *thr_param = RT_NULL;
+
+ static char utest_name[UTEST_NAME_MAX_LEN];
+ rt_memset(utest_name, 0x0, sizeof(utest_name));
if (argc == 1)
{
utest_run(RT_NULL);
+ return;
}
- else if (argc == 2)
+ else if (argc == 2 || argc == 3)
{
- rt_memset(utest_name, 0x0, sizeof(utest_name));
- rt_strncpy(utest_name, argv[1], sizeof(utest_name) -1);
- utest_run(utest_name);
+ if (rt_strcmp(argv[1], "-thread") == 0)
+ {
+ rt_thread_t tid = RT_NULL;
+ if (argc == 3)
+ {
+ rt_strncpy(utest_name, argv[2], sizeof(utest_name) -1);
+ thr_param = (void*)utest_name;
+ }
+ tid = rt_thread_create("utest",
+ (void (*)(void *))utest_run, thr_param,
+ UTEST_THREAD_STACK_SIZE, UTEST_THREAD_PRIORITY, 10);
+ if (tid != NULL)
+ {
+ rt_thread_startup(tid);
+ }
+ }
+ else
+ {
+ rt_strncpy(utest_name, argv[1], sizeof(utest_name) -1);
+ utest_run(utest_name);
+ }
}
else
{
LOG_E("[ error ] at (%s:%d), in param error.", __func__, __LINE__);
}
}
-MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [testcase name]);
+MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [-thread] [testcase name]);
utest_t utest_handle_get(void)
{