summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-07-15 15:41:14 +0100
committerSimon McVittie <smcv@collabora.com>2022-07-18 11:15:54 +0000
commitbef88fd5627f2d990915c9009982107a8e329ef5 (patch)
tree629403df44f1e564e9b47e5f4ee0d01b95ef5041 /bus
parent11e6c92e9521ef55ceb0b421c5d077d5793c71d5 (diff)
downloaddbus-bef88fd5627f2d990915c9009982107a8e329ef5.tar.gz
test/bus: Break up dispatch test into three separate tests
This is really three separate test-cases: one for traditional activation as a direct child process of the dbus-daemon, and two for traditional activation (successful and failing) via the setuid dbus-daemon-launch-helper on Unix. The ones where activation succeeds extremely slow, as a result of the instrumentation for simulating malloc() failures combined with a large number of memory operations, particularly when using AddressSanitizer. Splitting up "OOM" tests like these has a disproportionately good impact on the time they take, because the simulated malloc() failure instrumentation repeats the entire test making the first malloc() fail, then making the second malloc() fail, and so on. For allocation failures in the second half of the test, this means we repeat the first half of the test with no malloc() failures a very large number of times, which is not a good use of time, because we already tested it successfully. Even when not using the "OOM" instrumentation, splitting up these tests lets them run in parallel, which is also a major time saving. Needless to say, this speeds up testing considerably. On my modern but unexceptional x86 laptop, in a typical debug build with Meson, the old dispatch test took just over 21 minutes, which drops to about 40 seconds each for the new normal-activation and helper-activation tests (and for most of that time, they're running in parallel, so the wall-clock time taken for the whole test suite is somewhere around a minute). In a debug build with Meson, gcc and AddressSanitizer, the old dispatch test takes longer than my patience will allow, and the new separate tests take about 5-6 minutes each. Reduce their timeout accordingly, but not as far as the default for slow tests (5 minutes) to allow some headroom for AddressSanitizer or slower systems. The failed-helper-activation test is almost instantaneous, and no longer needs to be marked as slow. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'bus')
-rw-r--r--bus/dispatch.c38
-rw-r--r--bus/test.h4
2 files changed, 30 insertions, 12 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 3f985261..118258e4 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -5036,36 +5036,52 @@ bus_dispatch_test_conf_fail (const DBusString *test_data_dir,
}
#endif
+#ifdef ENABLE_TRADITIONAL_ACTIVATION
dbus_bool_t
-bus_dispatch_test (const char *test_data_dir_cstr)
+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);
-#ifdef ENABLE_TRADITIONAL_ACTIVATION
- /* run normal activation tests */
- _dbus_verbose ("Normal activation tests\n");
if (!bus_dispatch_test_conf (&test_data_dir,
- "valid-config-files/debug-allow-all.conf", FALSE))
+ "valid-config-files/debug-allow-all.conf", FALSE))
return FALSE;
+ return TRUE;
+}
+
#ifndef DBUS_WIN
- /* run launch-helper activation tests */
- _dbus_verbose ("Launch helper activation tests\n");
+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,
- "valid-config-files-system/debug-allow-all-pass.conf", TRUE))
+ "valid-config-files-system/debug-allow-all-pass.conf", TRUE))
return FALSE;
+ return TRUE;
+}
+
+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,
- "valid-config-files-system/debug-allow-all-fail.conf"))
+ "valid-config-files-system/debug-allow-all-fail.conf"))
return FALSE;
-#endif
-#endif
return TRUE;
}
+#endif /* !DBUS_WIN */
+#endif /* ENABLE_TRADITIONAL_ACTIVATION */
dbus_bool_t
bus_dispatch_sha1_test (const char *test_data_dir_cstr)
diff --git a/bus/test.h b/bus/test.h
index 6f1f6b0d..a6658cab 100644
--- a/bus/test.h
+++ b/bus/test.h
@@ -36,7 +36,9 @@
typedef dbus_bool_t (* BusConnectionForeachFunction) (DBusConnection *connection,
void *data);
-dbus_bool_t bus_dispatch_test (const char *test_data_dir_cstr);
+dbus_bool_t bus_test_normal_activation (const char *test_data_dir_cstr);
+dbus_bool_t bus_test_helper_activation (const char *test_data_dir_cstr);
+dbus_bool_t bus_test_failed_helper_activation (const char *test_data_dir_cstr);
dbus_bool_t bus_dispatch_sha1_test (const char *test_data_dir_cstr);
dbus_bool_t bus_config_parser_test (const char *test_data_dir_cstr);
dbus_bool_t bus_config_parser_trivial_test (const char *test_data_dir_cstr);