shared/tester: Add option to filter by string
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 11 Nov 2020 02:06:00 +0000 (18:06 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:33 +0000 (19:08 +0530)
This adds option to filter by string which does not require to enter
the entire prefix.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/shared/tester.c

index c4c4f2e..7c19bbb 100755 (executable)
@@ -105,6 +105,7 @@ static gboolean option_debug = FALSE;
 static gboolean option_monitor = FALSE;
 static gboolean option_list = FALSE;
 static const char *option_prefix = NULL;
+static const char *option_string = NULL;
 
 struct monitor_hdr {
        uint16_t opcode;
@@ -284,6 +285,12 @@ void tester_add_full(const char *name, const void *test_data,
                return;
        }
 
+       if (option_string && !strstr(name, option_string)) {
+               if (destroy)
+                       destroy(user_data);
+               return;
+       }
+
        if (option_list) {
                tester_log("%s", name);
                if (destroy)
@@ -803,6 +810,8 @@ static GOptionEntry options[] = {
                                "Only list the tests to be run" },
        { "prefix", 'p', 0, G_OPTION_ARG_STRING, &option_prefix,
                                "Run tests matching provided prefix" },
+       { "string", 's', 0, G_OPTION_ARG_STRING, &option_string,
+                               "Run tests matching provided string" },
        { NULL },
 };