From edd4f2b2a2463d7b2e964e31e0a75049c4751fb7 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 5 Jun 2019 14:44:24 -0700 Subject: [PATCH] test-runner: allow glob matching of tests This allows a glob match of tests, e.g. ./test-runner -A testEAP-TTLS* would run all TTLS based tests --- tools/test-runner.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tools/test-runner.c b/tools/test-runner.c index a2c5fe43..16f599ac 100644 --- a/tools/test-runner.c +++ b/tools/test-runner.c @@ -1008,16 +1008,15 @@ static int is_test_dir(const char *dir) } static bool find_test_configuration(const char *path, int level, - struct l_hashmap *config_map) + struct l_hashmap *config_map); + +static bool add_path(const char *path, int level, struct l_hashmap *config_map) { DIR *dir = NULL; struct l_queue *py_test_queue = NULL; struct dirent *entry; char *npath; - if (!config_map) - return false; - dir = opendir(path); if (!dir) { l_error("Test directory does not exist: %s", path); @@ -1054,6 +1053,32 @@ static bool find_test_configuration(const char *path, int level, return true; } +static bool find_test_configuration(const char *path, int level, + struct l_hashmap *config_map) +{ + glob_t glist; + int i = 0; + int ret; + + if (!config_map) + return false; + + ret = glob(path, 0, NULL, &glist); + if (ret != 0) { + l_error("Could not match glob %s", path); + return false; + } + + while (glist.gl_pathv[i]) { + if (!add_path(glist.gl_pathv[i], level, config_map)) + return false; + + i++; + } + + return true; +} + #define HW_CONFIG_FILE_NAME "hw.conf" #define HW_CONFIG_GROUP_HOSTAPD "HOSTAPD" #define HW_CONFIG_GROUP_SETUP "SETUP"