From: Ralf Habacker Date: Fri, 10 Dec 2021 09:22:56 +0000 (+0100) Subject: test/test-utils.c: Add command line option --list-tests to test applications X-Git-Tag: dbus-1.13.20~13^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=febafd863ec66c61e9e81b98dea346d0dd5517fc;p=thirdparty%2Fdbus.git test/test-utils.c: Add command line option --list-tests to test applications With this command line option a list of available tests is printed to stdout. --- diff --git a/test/test-utils.c b/test/test-utils.c index e78527080..fbdd27591 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -653,12 +653,22 @@ _dbus_test_help_page (const char *appname) fprintf(stdout, "%s [] [] []\n", appname); fprintf(stdout, "Options:\n"); fprintf(stdout, " --help this page\n"); + fprintf(stdout, " --list-tests show available tests\n"); fprintf(stdout, " --tap expect test data dir to be set by environment variable DBUS_TEST_DATA\n"); fprintf(stdout, "Environment variables:\n"); fprintf(stdout, " DBUS_TEST_ONLY= set specific test to run\n"); fprintf(stdout, " DBUS_TEST_DATA= set test data dir (required when using --tap)\n"); } +static void +_dbus_test_show_available_tests (const DBusTestCase *tests) +{ + const DBusTestCase *p; + + for (p = tests; p->name; p++) + fprintf(stdout, "%s\n", p->name); +} + /* * _dbus_test_main: * @argc: number of command-line arguments @@ -702,6 +712,12 @@ _dbus_test_main (int argc, exit(0); } + else if (argc > 1 && strcmp (argv[1], "--list-tests") == 0) + { + _dbus_test_show_available_tests (tests); + exit (0); + } + /* We can't assume that strings from _dbus_getenv() will remain valid * forever, because some tests call setenv(), which is allowed to * reallocate the entire environment block, and in Wine it seems that it