OSDN Git Service

tester: Add -l command line switch for listing test cases
authorJohan Hedberg <johan.hedberg@intel.com>
Fri, 11 Jan 2013 22:12:25 +0000 (00:12 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 11 Jan 2013 22:29:12 +0000 (00:29 +0200)
src/shared/tester.c

index 440bf10..9e62ce8 100644 (file)
@@ -98,6 +98,7 @@ static GTimer *test_timer;
 static gboolean option_version = FALSE;
 static gboolean option_quiet = FALSE;
 static gboolean option_debug = FALSE;
+static gboolean option_list = FALSE;
 static const char *option_prefix = NULL;
 
 static void test_destroy(gpointer data)
@@ -175,6 +176,13 @@ void tester_add_full(const char *name, const void *test_data,
                return;
        }
 
+       if (option_list) {
+               printf("%s\n", name);
+               if (destroy)
+                       destroy(user_data);
+               return;
+       }
+
        test = g_new0(struct test_case, 1);
 
        test->name = g_strdup(name);
@@ -676,6 +684,8 @@ static GOptionEntry options[] = {
                                "Run tests without logging" },
        { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug,
                                "Run tests with debug output" },
+       { "list", 'l', 0, G_OPTION_ARG_NONE, &option_list,
+                               "Only list the tests to be run" },
        { "prefix", 'p', 0, G_OPTION_ARG_STRING, &option_prefix,
                                "Run tests matching provided prefix" },
        { NULL },
@@ -718,6 +728,11 @@ int tester_run(void)
        if (!main_loop)
                return EXIT_FAILURE;
 
+       if (option_list) {
+               g_main_loop_unref(main_loop);
+               return EXIT_SUCCESS;
+       }
+
        signal = setup_signalfd();
 
        g_idle_add(start_tester, NULL);