From f49ff4f0eaf1a9176b6b9b1249af96612398e50a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 17 Jul 2022 16:20:14 +0100 Subject: dispatch test: Pass in test data directory as a C string This reduces duplication a little bit. Signed-off-by: Simon McVittie --- bus/dispatch.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'bus') diff --git a/bus/dispatch.c b/bus/dispatch.c index 118258e4..c7803b42 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -4797,25 +4797,27 @@ setenv_TEST_LAUNCH_HELPER_CONFIG(const DBusString *test_data_dir, } static dbus_bool_t -bus_dispatch_test_conf (const DBusString *test_data_dir, - const char *filename, - dbus_bool_t use_launcher) +bus_dispatch_test_conf (const char *test_data_dir_cstr, + const char *filename, + dbus_bool_t use_launcher) { BusContext *context; DBusConnection *foo; DBusConnection *bar; DBusConnection *baz; DBusError error; + DBusString test_data_dir; + _dbus_string_init_const (&test_data_dir, test_data_dir_cstr); _dbus_test_diag ("%s:%s...", _DBUS_FUNCTION_NAME, filename); /* save the config name for the activation helper */ - if (!setenv_TEST_LAUNCH_HELPER_CONFIG (test_data_dir, filename)) + if (!setenv_TEST_LAUNCH_HELPER_CONFIG (&test_data_dir, filename)) _dbus_test_fatal ("no memory setting TEST_LAUNCH_HELPER_CONFIG"); dbus_error_init (&error); - context = bus_context_new_test (test_data_dir, filename); + context = bus_context_new_test (&test_data_dir, filename); if (context == NULL) { _dbus_test_not_ok ("%s:%s - bus_context_new_test() failed", @@ -4972,22 +4974,24 @@ bus_dispatch_test_conf (const DBusString *test_data_dir, #if defined(ENABLE_TRADITIONAL_ACTIVATION) && !defined(DBUS_WIN) static dbus_bool_t -bus_dispatch_test_conf_fail (const DBusString *test_data_dir, - const char *filename) +bus_dispatch_test_conf_fail (const char *test_data_dir_cstr, + const char *filename) { BusContext *context; DBusConnection *foo; DBusError error; + DBusString test_data_dir; + _dbus_string_init_const (&test_data_dir, test_data_dir_cstr); _dbus_test_diag ("%s:%s...", _DBUS_FUNCTION_NAME, filename); /* save the config name for the activation helper */ - if (!setenv_TEST_LAUNCH_HELPER_CONFIG (test_data_dir, filename)) + if (!setenv_TEST_LAUNCH_HELPER_CONFIG (&test_data_dir, filename)) _dbus_test_fatal ("no memory setting TEST_LAUNCH_HELPER_CONFIG"); dbus_error_init (&error); - context = bus_context_new_test (test_data_dir, filename); + context = bus_context_new_test (&test_data_dir, filename); if (context == NULL) { _dbus_test_not_ok ("%s:%s - bus_context_new_test() failed", @@ -5040,11 +5044,7 @@ bus_dispatch_test_conf_fail (const DBusString *test_data_dir, dbus_bool_t bus_test_normal_activation (const char *test_data_dir_cstr) { - DBusString test_data_dir; - - _dbus_string_init_const (&test_data_dir, test_data_dir_cstr); - - if (!bus_dispatch_test_conf (&test_data_dir, + if (!bus_dispatch_test_conf (test_data_dir_cstr, "valid-config-files/debug-allow-all.conf", FALSE)) return FALSE; @@ -5055,11 +5055,7 @@ bus_test_normal_activation (const char *test_data_dir_cstr) dbus_bool_t bus_test_helper_activation (const char *test_data_dir_cstr) { - DBusString test_data_dir; - - _dbus_string_init_const (&test_data_dir, test_data_dir_cstr); - - if (!bus_dispatch_test_conf (&test_data_dir, + if (!bus_dispatch_test_conf (test_data_dir_cstr, "valid-config-files-system/debug-allow-all-pass.conf", TRUE)) return FALSE; @@ -5069,12 +5065,8 @@ bus_test_helper_activation (const char *test_data_dir_cstr) dbus_bool_t bus_test_failed_helper_activation (const char *test_data_dir_cstr) { - DBusString test_data_dir; - - _dbus_string_init_const (&test_data_dir, test_data_dir_cstr); - /* run select launch-helper activation tests on broken service files */ - if (!bus_dispatch_test_conf_fail (&test_data_dir, + if (!bus_dispatch_test_conf_fail (test_data_dir_cstr, "valid-config-files-system/debug-allow-all-fail.conf")) return FALSE; -- cgit v1.2.1