]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test/test-utils.c: Add command line option --list-tests to test applications
authorRalf Habacker <ralf.habacker@freenet.de>
Fri, 10 Dec 2021 09:22:56 +0000 (10:22 +0100)
committerRalf Habacker <ralf.habacker@freenet.de>
Fri, 10 Dec 2021 09:36:28 +0000 (10:36 +0100)
With this command line option a list of available tests is printed to
stdout.

test/test-utils.c

index e78527080e360b71673f8a8f167a4f860cc0f846..fbdd275910c7bf5e12b338ddeb056ebe9d893560 100644 (file)
@@ -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