This is an automated email from the ASF dual-hosted git repository. ligd pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push: new 1ddeaa146 testing/cmocka: shuffling test sequence and pass seed arg 1ddeaa146 is described below commit 1ddeaa14680f506b4d18d861d08babc7b14d9b58 Author: zhangchao53 <zhangcha...@xiaomi.com> AuthorDate: Thu Nov 30 15:56:10 2023 +0800 testing/cmocka: shuffling test sequence and pass seed arg Signed-off-by: zhangchao53 <zhangcha...@xiaomi.com> --- testing/cmocka/cmocka_main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/testing/cmocka/cmocka_main.c b/testing/cmocka/cmocka_main.c index c5d171efb..f3220931f 100644 --- a/testing/cmocka/cmocka_main.c +++ b/testing/cmocka/cmocka_main.c @@ -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); @@ -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; @@ -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]; @@ -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); }