Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[utest] remove delay for on thread testing #9053

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions components/utilities/utest/utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int utest_init(void)
}
INIT_COMPONENT_EXPORT(utest_init);

static void utest_tc_list(void)
static long utest_tc_list(void)
{
rt_size_t i = 0;

Expand All @@ -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);
}

return 0;
}
MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_list, output all utest testcase);

Expand Down Expand Up @@ -197,8 +199,6 @@ static void utest_run(const char *utest_name)
rt_uint32_t tc_fail_num = 0;
rt_uint32_t tc_run_num = 0;

rt_thread_mdelay(1000);

for (index = 0; index < tc_loop; index ++)
{
i = 0;
Expand Down Expand Up @@ -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];
rt_memset(utest_name, 0x0, sizeof(utest_name));
Expand All @@ -312,7 +319,7 @@ static void utest_testcase_run(int argc, char** argv)
if (argc == 1)
{
utest_run(RT_NULL);
return;
return 0;
}
else if (argc == 2 || argc == 3 || argc == 4)
{
Expand All @@ -322,13 +329,12 @@ static void utest_testcase_run(int argc, char** argv)
if (argc == 3 || argc == 4)
{
rt_strncpy(utest_name, argv[2], sizeof(utest_name) -1);
thr_param = (void*)utest_name;

if (argc == 4) tc_loop = atoi(argv[3]);
}
tid = rt_thread_create("utest",
(void (*)(void *))utest_run, thr_param,
UTEST_THREAD_STACK_SIZE, UTEST_THREAD_PRIORITY, 10);
(void (*)(void *))utest_thr_entry, utest_name,
UTEST_THREAD_STACK_SIZE, UTEST_THREAD_PRIORITY, 10);
if (tid != NULL)
{
rt_thread_startup(tid);
Expand All @@ -350,6 +356,7 @@ static void utest_testcase_run(int argc, char** argv)
LOG_E("[ error ] at (%s:%d), in param error.", __func__, __LINE__);
utest_help();
}
return 0;
}
MSH_CMD_EXPORT_ALIAS(utest_testcase_run, utest_run, utest_run [-thread or -help] [testcase name] [loop num]);

Expand Down
Loading