diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2021-12-10 10:22:56 +0100 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2021-12-10 10:36:28 +0100 |
commit | febafd863ec66c61e9e81b98dea346d0dd5517fc (patch) | |
tree | 2e2051ad99b93473176ef173a9cd6adcb697f84e /test/test-utils.c | |
parent | 3432cd938de74e1b269893f6882a34052965a800 (diff) | |
download | dbus-febafd863ec66c61e9e81b98dea346d0dd5517fc.tar.gz |
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.
Diffstat (limited to 'test/test-utils.c')
-rw-r--r-- | test/test-utils.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test-utils.c b/test/test-utils.c index e7852708..fbdd2759 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 [<options>] [<test-data-dir>] [<specific-test>]\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=<specific-test> set specific test to run\n"); fprintf(stdout, " DBUS_TEST_DATA=<test-data-dir> 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 |