From: Mark Andrews Date: Fri, 11 Sep 2020 04:17:36 +0000 (+1000) Subject: Add the ability select individual tests to rdata_test X-Git-Tag: v9.17.6~19^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6293682020472e66a92094b57475a6b13ca1fa77;p=thirdparty%2Fbind9.git Add the ability select individual tests to rdata_test --- diff --git a/lib/dns/tests/rdata_test.c b/lib/dns/tests/rdata_test.c index 0f091214ba7..e44b2f1cabb 100644 --- a/lib/dns/tests/rdata_test.c +++ b/lib/dns/tests/rdata_test.c @@ -21,8 +21,9 @@ #include #define UNIT_TESTING -#include +#include +#include #include #include #include @@ -2656,14 +2657,44 @@ main(int argc, char **argv) { cmocka_unit_test_setup_teardown(atparent, NULL, NULL), cmocka_unit_test_setup_teardown(iszonecutauth, NULL, NULL), }; + struct CMUnitTest selected[sizeof(tests) / sizeof(tests[0])]; + size_t i; + int c; - UNUSED(argv); + memset(selected, 0, sizeof(selected)); - if (argc > 1) { - debug = true; + while ((c = isc_commandline_parse(argc, argv, "dlt:")) != -1) { + switch (c) { + case 'd': + debug = true; + break; + case 'l': + for (i = 0; i < (sizeof(tests) / sizeof(tests[0])); i++) + { + if (tests[i].name != NULL) { + fprintf(stdout, "%s\n", tests[i].name); + } + } + return (0); + case 't': + if (!cmocka_add_test_byname( + tests, isc_commandline_argument, selected)) + { + fprintf(stderr, "unknown test '%s'\n", + isc_commandline_argument); + exit(1); + } + break; + default: + break; + } } - return (cmocka_run_group_tests(tests, NULL, NULL)); + if (selected[0].name != NULL) { + return (cmocka_run_group_tests(selected, NULL, NULL)); + } else { + return (cmocka_run_group_tests(tests, NULL, NULL)); + } } #else /* HAVE_CMOCKA */