summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMurphyZhao <[email protected]>2019-02-15 11:47:21 +0800
committerMurphyZhao <[email protected]>2019-02-15 12:04:36 +0800
commite3546a50437404c8d95f63d1f830f98d35c09bce (patch)
tree457809423b0f84e93c169e71e1f16e469bf55d32 /components
parenta305c6cca93cb7c33cd522098163ae52d6964e90 (diff)
[components][utest] 增加 utest_help,用于输出帮助信息
[components][utest] 对于不支持的测试用例,增加输出日志 Signed-off-by: MurphyZhao <[email protected]>
Diffstat (limited to 'components')
-rw-r--r--components/utilities/utest/utest.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c
index 13cb405550..f7348b3be4 100644
--- a/components/utilities/utest/utest.c
+++ b/components/utilities/utest/utest.c
@@ -119,16 +119,45 @@ static const char *file_basename(const char *file)
return (const char *)rst;
}
+static int utest_help(void)
+{
+ rt_kprintf("\n");
+ rt_kprintf("Command: utest_run\n");
+ rt_kprintf(" info: Execute test cases.\n");
+ rt_kprintf(" format: utest_run [-thread or -help] [testcase name] [loop num]\n");
+ rt_kprintf(" usage:\n");
+ rt_kprintf(" 1. utest_run\n");
+ rt_kprintf(" Do not specify a test case name. Run all test cases.\n");
+ rt_kprintf(" 2. utest_run -thread\n");
+ rt_kprintf(" Do not specify a test case name. Run all test cases in threaded mode.\n");
+ rt_kprintf(" 3. utest_run testcaseA\n");
+ rt_kprintf(" Run 'testcaseA'.\n");
+ rt_kprintf(" 4. utest_run testcaseA 10\n");
+ rt_kprintf(" Run 'testcaseA' ten times.\n");
+ rt_kprintf(" 5. utest_run -thread testcaseA\n");
+ rt_kprintf(" Run 'testcaseA' in threaded mode.\n");
+ rt_kprintf(" 6. utest_run -thread testcaseA 10\n");
+ rt_kprintf(" Run 'testcaseA' ten times in threaded mode.\n");
+ rt_kprintf(" 7. utest_run test*\n");
+ rt_kprintf(" support '*' wildcard. Run all test cases starting with 'test'.\n");
+ rt_kprintf(" 8. utest_run -help\n");
+ rt_kprintf(" Show utest help information\n");
+ rt_kprintf("\n");
+ return 0;
+}
+
static void utest_run(const char *utest_name)
{
rt_size_t i;
rt_uint32_t index;
+ rt_bool_t is_find;
rt_thread_mdelay(1000);
for (index = 0; index < tc_loop; index ++)
{
i = 0;
+ is_find = RT_FALSE;
LOG_I("[==========] [ utest ] started");
while(i < tc_num)
{
@@ -145,6 +174,7 @@ static void utest_run(const char *utest_name)
continue;
}
}
+ is_find = RT_TRUE;
LOG_I("[----------] [ testcase ] (%s) started", tc_table[i].name);
if (tc_table[i].init != RT_NULL)
@@ -187,6 +217,14 @@ static void utest_run(const char *utest_name)
i++;
}
+
+ if (i == tc_num && is_find == RT_FALSE)
+ {
+ LOG_I("[==========] [ utest ] Not find (%s)", utest_name);
+ LOG_I("[==========] [ utest ] finished");
+ break;
+ }
+
LOG_I("[==========] [ utest ] finished");
}
}
@@ -225,6 +263,10 @@ static void utest_testcase_run(int argc, char** argv)
rt_thread_startup(tid);
}
}
+ else if (rt_strcmp(argv[1], "-help") == 0)
+ {
+ utest_help();
+ }
else
{
rt_strncpy(utest_name, argv[1], sizeof(utest_name) -1);
@@ -235,9 +277,10 @@ static void utest_testcase_run(int argc, char** argv)
else
{
LOG_E("[ error ] at (%s:%d), in param error.", __func__, __LINE__);
+ utest_help();
}
}
-MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [-thread] [testcase name]);
+MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [-thread or -help] [testcase name] [loop num]);
utest_t utest_handle_get(void)
{