Skip to content

Commit 540370e

Browse files
authored
[utest] remove delay for on thread testing (#9053)
* [utest] remove delay for on thread testing The delay is introduced from 0dc7b9a. 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 <[email protected]> * fixup: msh cmd prototype --------- Signed-off-by: Shell <[email protected]>
1 parent 1b4b338 commit 540370e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

components/utilities/utest/utest.c

+16-9
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ int utest_init(void)
131131
}
132132
INIT_COMPONENT_EXPORT(utest_init);
133133

134-
static void utest_tc_list(void)
134+
static long utest_tc_list(void)
135135
{
136136
rt_size_t i = 0;
137137

@@ -141,6 +141,8 @@ static void utest_tc_list(void)
141141
{
142142
LOG_I("[testcase name]:%s; [run timeout]:%d", tc_table[i].name, tc_table[i].run_timeout);
143143
}
144+
145+
return 0;
144146
}
145147
MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_list, output all utest testcase);
146148

@@ -197,8 +199,6 @@ static void utest_run(const char *utest_name)
197199
rt_uint32_t tc_fail_num = 0;
198200
rt_uint32_t tc_run_num = 0;
199201

200-
rt_thread_mdelay(1000);
201-
202202
for (index = 0; index < tc_loop; index ++)
203203
{
204204
i = 0;
@@ -300,9 +300,16 @@ static void utest_run(const char *utest_name)
300300
}
301301
}
302302

303-
static void utest_testcase_run(int argc, char** argv)
303+
static void utest_thr_entry(const char *utest_name)
304+
{
305+
/* see commit:0dc7b9a for details */
306+
rt_thread_mdelay(1000);
307+
308+
utest_run(utest_name);
309+
}
310+
311+
long utest_testcase_run(int argc, char** argv)
304312
{
305-
void *thr_param = RT_NULL;
306313

307314
static char utest_name[UTEST_NAME_MAX_LEN];
308315
rt_memset(utest_name, 0x0, sizeof(utest_name));
@@ -312,7 +319,7 @@ static void utest_testcase_run(int argc, char** argv)
312319
if (argc == 1)
313320
{
314321
utest_run(RT_NULL);
315-
return;
322+
return 0;
316323
}
317324
else if (argc == 2 || argc == 3 || argc == 4)
318325
{
@@ -322,13 +329,12 @@ static void utest_testcase_run(int argc, char** argv)
322329
if (argc == 3 || argc == 4)
323330
{
324331
rt_strncpy(utest_name, argv[2], sizeof(utest_name) -1);
325-
thr_param = (void*)utest_name;
326332

327333
if (argc == 4) tc_loop = atoi(argv[3]);
328334
}
329335
tid = rt_thread_create("utest",
330-
(void (*)(void *))utest_run, thr_param,
331-
UTEST_THREAD_STACK_SIZE, UTEST_THREAD_PRIORITY, 10);
336+
(void (*)(void *))utest_thr_entry, utest_name,
337+
UTEST_THREAD_STACK_SIZE, UTEST_THREAD_PRIORITY, 10);
332338
if (tid != NULL)
333339
{
334340
rt_thread_startup(tid);
@@ -350,6 +356,7 @@ static void utest_testcase_run(int argc, char** argv)
350356
LOG_E("[ error ] at (%s:%d), in param error.", __func__, __LINE__);
351357
utest_help();
352358
}
359+
return 0;
353360
}
354361
MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [-thread or -help] [testcase name] [loop num]);
355362

0 commit comments

Comments
 (0)