[utest] remove delay for on thread testing (#9053)
* [utest] remove delay for on thread testing
The delay is introduced from 0dc7b9a5a2
.
Though this is unnecessary for on sync utest.
So this is removed by a new entry and delay for asynchronous utest only.
Signed-off-by: Shell <smokewood@qq.com>
* fixup: msh cmd prototype
---------
Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
parent
1b4b338ed1
commit
540370e4de
|
@ -131,7 +131,7 @@ int utest_init(void)
|
||||||
}
|
}
|
||||||
INIT_COMPONENT_EXPORT(utest_init);
|
INIT_COMPONENT_EXPORT(utest_init);
|
||||||
|
|
||||||
static void utest_tc_list(void)
|
static long utest_tc_list(void)
|
||||||
{
|
{
|
||||||
rt_size_t i = 0;
|
rt_size_t i = 0;
|
||||||
|
|
||||||
|
@ -141,6 +141,8 @@ static void utest_tc_list(void)
|
||||||
{
|
{
|
||||||
LOG_I("[testcase name]:%s; [run timeout]:%d", tc_table[i].name, tc_table[i].run_timeout);
|
LOG_I("[testcase name]:%s; [run timeout]:%d", tc_table[i].name, tc_table[i].run_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_list, output all utest testcase);
|
MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_list, output all utest testcase);
|
||||||
|
|
||||||
|
@ -197,8 +199,6 @@ static void utest_run(const char *utest_name)
|
||||||
rt_uint32_t tc_fail_num = 0;
|
rt_uint32_t tc_fail_num = 0;
|
||||||
rt_uint32_t tc_run_num = 0;
|
rt_uint32_t tc_run_num = 0;
|
||||||
|
|
||||||
rt_thread_mdelay(1000);
|
|
||||||
|
|
||||||
for (index = 0; index < tc_loop; index ++)
|
for (index = 0; index < tc_loop; index ++)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -300,9 +300,16 @@ static void utest_run(const char *utest_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void utest_testcase_run(int argc, char** argv)
|
static void utest_thr_entry(const char *utest_name)
|
||||||
|
{
|
||||||
|
/* see commit:0dc7b9a for details */
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
|
||||||
|
utest_run(utest_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
long utest_testcase_run(int argc, char** argv)
|
||||||
{
|
{
|
||||||
void *thr_param = RT_NULL;
|
|
||||||
|
|
||||||
static char utest_name[UTEST_NAME_MAX_LEN];
|
static char utest_name[UTEST_NAME_MAX_LEN];
|
||||||
rt_memset(utest_name, 0x0, sizeof(utest_name));
|
rt_memset(utest_name, 0x0, sizeof(utest_name));
|
||||||
|
@ -312,7 +319,7 @@ static void utest_testcase_run(int argc, char** argv)
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
utest_run(RT_NULL);
|
utest_run(RT_NULL);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (argc == 2 || argc == 3 || argc == 4)
|
else if (argc == 2 || argc == 3 || argc == 4)
|
||||||
{
|
{
|
||||||
|
@ -322,12 +329,11 @@ static void utest_testcase_run(int argc, char** argv)
|
||||||
if (argc == 3 || argc == 4)
|
if (argc == 3 || argc == 4)
|
||||||
{
|
{
|
||||||
rt_strncpy(utest_name, argv[2], sizeof(utest_name) -1);
|
rt_strncpy(utest_name, argv[2], sizeof(utest_name) -1);
|
||||||
thr_param = (void*)utest_name;
|
|
||||||
|
|
||||||
if (argc == 4) tc_loop = atoi(argv[3]);
|
if (argc == 4) tc_loop = atoi(argv[3]);
|
||||||
}
|
}
|
||||||
tid = rt_thread_create("utest",
|
tid = rt_thread_create("utest",
|
||||||
(void (*)(void *))utest_run, thr_param,
|
(void (*)(void *))utest_thr_entry, utest_name,
|
||||||
UTEST_THREAD_STACK_SIZE, UTEST_THREAD_PRIORITY, 10);
|
UTEST_THREAD_STACK_SIZE, UTEST_THREAD_PRIORITY, 10);
|
||||||
if (tid != NULL)
|
if (tid != NULL)
|
||||||
{
|
{
|
||||||
|
@ -350,6 +356,7 @@ static void utest_testcase_run(int argc, char** argv)
|
||||||
LOG_E("[ error ] at (%s:%d), in param error.", __func__, __LINE__);
|
LOG_E("[ error ] at (%s:%d), in param error.", __func__, __LINE__);
|
||||||
utest_help();
|
utest_help();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [-thread or -help] [testcase name] [loop num]);
|
MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [-thread or -help] [testcase name] [loop num]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue