From 45aa83e93529a20731803ce7d3a4c4d0b534a9fb Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 11 Jan 2013 23:48:36 +0200 Subject: [PATCH] tester: Add -p option to filter which test to be executed --- src/shared/tester.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/shared/tester.c b/src/shared/tester.c index 8906ba652..440bf109d 100644 --- a/src/shared/tester.c +++ b/src/shared/tester.c @@ -95,6 +95,11 @@ static GList *test_list; static GList *test_current; static GTimer *test_timer; +static gboolean option_version = FALSE; +static gboolean option_quiet = FALSE; +static gboolean option_debug = FALSE; +static const char *option_prefix = NULL; + static void test_destroy(gpointer data) { struct test_case *test = data; @@ -164,6 +169,12 @@ void tester_add_full(const char *name, const void *test_data, if (!test_func) return; + if (option_prefix && !g_str_has_prefix(name, option_prefix)) { + if (destroy) + destroy(user_data); + return; + } + test = g_new0(struct test_case, 1); test->name = g_strdup(name); @@ -648,10 +659,6 @@ static guint setup_signalfd(void) return source; } -static gboolean option_version = FALSE; -static gboolean option_quiet = FALSE; -static gboolean option_debug = FALSE; - bool tester_use_quiet(void) { return option_quiet == TRUE ? true : false; @@ -669,6 +676,8 @@ static GOptionEntry options[] = { "Run tests without logging" }, { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug, "Run tests with debug output" }, + { "prefix", 'p', 0, G_OPTION_ARG_STRING, &option_prefix, + "Run tests matching provided prefix" }, { NULL }, }; -- 2.47.3