add short command-line arguments and record execution time

This commit is contained in:
zhangchao53 2023-11-10 18:15:29 +08:00 committed by Xiang Xiao
parent f32b4c7f9c
commit ac64c7d144
2 changed files with 19 additions and 10 deletions

View File

@ -23,6 +23,8 @@ include $(APPDIR)/Make.defs
CSRCS += $(wildcard cmocka/src/*.c)
CFLAGS += -Dprint_error=nx_print_error
CFLAGS += -DCMOCKA_PLATFORM_INCLUDE
CFLAGS += -DHAVE_CLOCK_REALTIME=1
CFLAGS += -DHAVE_STRUCT_TIMESPEC=1
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/testing/cmocka
PROGNAME = $(CONFIG_TESTING_CMOCKA_PROGNAME)

View File

@ -48,16 +48,16 @@ static void cm_usage(void)
"with support for mock objects\n"
"Usage: cmocka [OPTION [ARG]] ...\n"
" -?, --help show this help statement\n"
" --list display only the names of testcases "
" -l, --list display only the names of testcases "
"and testsuite,\n"
" don't execute them\n"
" --test A only run cases where case function "
" -t, --test A only run cases where case function "
"name matches A pattern\n"
" --skip B don't run cases where case function "
" -p, --skip B don't run cases where case function "
"name matches B pattern\n"
" --suite C only run suites where PROGNAME "
" -s, --suite C only run suites where PROGNAME "
"matches C pattern\n"
" --output-path use xml report instead of standard "
" -f, --output-path use xml report instead of standard "
"output\n"
"Example: cmocka --suite mm|sched "
"--test Test* --skip TestNuttxMm0[123]\n\n";
@ -115,26 +115,33 @@ int main(int argc, FAR char *argv[])
cm_usage();
return 0;
}
else if (strcmp("--list", argv[i]) == 0)
else if (strcmp("--list", argv[i]) == 0 || strcmp("-l", argv[i]) == 0)
{
list_tests = 1;
}
else if (strcmp("--output-path", argv[i]) == 0)
else if (strcmp("--output-path", argv[i]) == 0
|| strcmp("-f", argv[i]) == 0)
{
xml_path = argv[++i];
}
else if (strcmp("--test", argv[i]) == 0)
else if (strcmp("--test", argv[i]) == 0 || strcmp("-t", argv[i]) == 0)
{
testcase = argv[++i];
}
else if (strcmp("--suite", argv[i]) == 0)
else if (strcmp("--suite", argv[i]) == 0 || strcmp("-s", argv[i]) == 0)
{
suite = argv[++i];
}
else if (strcmp("--skip", argv[i]) == 0)
else if (strcmp("--skip", argv[i]) == 0 || strcmp("-p", argv[i]) == 0)
{
skip = argv[++i];
}
else if (argv[i][0] == '-')
{
printf("Unrecognized arguments: %s\nGet more"
" infomation by --help\n", argv[i]);
return 0;
}
else
{
bypass[num_bypass++] = argv[i];