From: Ralf Habacker Date: Fri, 10 Dec 2021 09:24:30 +0000 (+0100) Subject: In _dbus_test_main() check if a specified test name is available X-Git-Tag: dbus-1.13.20~13^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d0649145ff3728a687454062c44c3680e3fd582;p=thirdparty%2Fdbus.git In _dbus_test_main() check if a specified test name is available Fixes #362 --- diff --git a/test/test-utils.c b/test/test-utils.c index fbdd27591..479461625 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -669,6 +669,20 @@ _dbus_test_show_available_tests (const DBusTestCase *tests) fprintf(stdout, "%s\n", p->name); } +static const DBusTestCase* +_dbus_test_find_test (const DBusTestCase *tests, const char *specific_test) +{ + const DBusTestCase *p; + + for (p = tests; p->name; p++) + { + if (strcmp (specific_test, p->name) == 0) + return p; + } + return NULL; +} + + /* * _dbus_test_main: * @argc: number of command-line arguments @@ -748,6 +762,15 @@ _dbus_test_main (int argc, else specific_test = strdup0_or_die (_dbus_getenv ("DBUS_TEST_ONLY")); + /* check that test is present */ + if (specific_test) + { + if (_dbus_test_find_test (tests, specific_test) == NULL) + { + _dbus_test_fatal ("Invalid test name '%s' specified", specific_test); + } + } + /* Some NSS modules like those for sssd and LDAP might allocate fds * on a one-per-process basis. Make sure those have already been * allocated before we enter the code under test, so that they don't