Skip to content

Commit

Permalink
testing/cmocka: shuffling test sequence and pass seed arg
Browse files Browse the repository at this point in the history
Signed-off-by: zhangchao53 <[email protected]>
  • Loading branch information
zhangchao53 authored and GUIDINGLI committed Oct 27, 2024
1 parent 71d26a5 commit 1ddeaa1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions testing/cmocka/cmocka_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ static void cm_usage(void)
"matches C pattern\n"
" -f, --output-path use xml report instead of standard "
"output\n"
" -d, --shuffle-seed shuffling test sequence,between "
"0 and 99999,\n"
" when seed is 0,use time(NULL) as "
"the seed for \n"
" the random number generator\n"
"Example: cmocka --suite mm|sched "
"--test Test* --skip TestNuttxMm0[123]\n\n";
printf("%s", mesg);
Expand Down Expand Up @@ -95,6 +100,7 @@ int main(int argc, FAR char *argv[])
FAR char *suite = NULL;
FAR char *skip = NULL;
FAR char *xml_path = NULL;
FAR char *shuffle_seed = NULL;
int num_bypass = 1;
int ret;
int i;
Expand Down Expand Up @@ -124,6 +130,11 @@ int main(int argc, FAR char *argv[])
{
xml_path = argv[++i];
}
else if (strcmp("--shuffle-seed", argv[i]) == 0
|| strcmp("-d", argv[i]) == 0)
{
shuffle_seed = argv[++i];
}
else if (strcmp("--test", argv[i]) == 0 || strcmp("-t", argv[i]) == 0)
{
testcase = argv[++i];
Expand Down Expand Up @@ -161,6 +172,11 @@ int main(int argc, FAR char *argv[])
cmocka_set_message_output(CM_OUTPUT_XML);
}

if (shuffle_seed != NULL)
{
setenv("CMOCKA_SHUFFLE_SEED", shuffle_seed, 1);
}

cmocka_set_test_filter(testcase);
cmocka_set_skip_filter(skip);
}
Expand Down

0 comments on commit 1ddeaa1

Please sign in to comment.