From af86d22e02fe1366e5cb99c99a155ea2a196d2ac Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 11 Mar 2011 13:24:08 +0000 Subject: [PATCH 19/19] Add a regression test that can reproduce fd.o #34393 The number of messages is arbitrary; the more messages, the more likely the crash is. 2000 messages seem to cause it reliably on this laptop, but I've set it to 10000 to be safe. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34393 --- test/data/valid-config-files/incoming-limit.conf | 18 +++++++++ test/dbus-daemon.c | 42 +++++++++++++++++---- 2 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 test/data/valid-config-files/incoming-limit.conf diff --git a/test/data/valid-config-files/incoming-limit.conf b/test/data/valid-config-files/incoming-limit.conf new file mode 100644 index 0000000..abfab3f --- /dev/null +++ b/test/data/valid-config-files/incoming-limit.conf @@ -0,0 +1,18 @@ + + + + session + unix:tmpdir=/tmp + + + + + + + + + + + 1 + diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index 04955e0..433b858 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -167,12 +167,19 @@ echo_filter (DBusConnection *connection, return DBUS_HANDLER_RESULT_HANDLED; } +typedef struct { + const char *bug_ref; + guint min_messages; + const char *config_file; +} Config; + static void setup (Fixture *f, - gconstpointer context G_GNUC_UNUSED) + gconstpointer context) { + const Config *config = context; gchar *dbus_daemon; - gchar *config; + gchar *config_arg; gchar *address; f->ge = NULL; @@ -182,22 +189,28 @@ setup (Fixture *f, dbus_daemon = g_strdup (g_getenv ("DBUS_TEST_DAEMON")); - if (g_getenv ("DBUS_TEST_USE_INSTALLED") != NULL) + if (config != NULL && config->config_file != NULL) + { + g_assert (g_getenv ("DBUS_TEST_DATA") != NULL); + config_arg = g_strdup_printf ("--config-file=%s/%s", + g_getenv ("DBUS_TEST_DATA"), config->config_file); + } + else if (g_getenv ("DBUS_TEST_USE_INSTALLED") != NULL) { - config = g_strdup ("--session"); + config_arg = g_strdup ("--session"); } else { g_assert (g_getenv ("DBUS_TEST_DATA") != NULL); - config = g_strdup_printf ( + config_arg = g_strdup_printf ( "--config-file=%s/valid-config-files/session.conf", g_getenv ("DBUS_TEST_DATA")); } - address = spawn_dbus_daemon (dbus_daemon, config, &f->daemon_pid); + address = spawn_dbus_daemon (dbus_daemon, config_arg, &f->daemon_pid); g_free (dbus_daemon); - g_free (config); + g_free (config_arg); f->left_conn = connect_to_bus (address); f->right_conn = connect_to_bus (address); @@ -224,16 +237,23 @@ pc_count (DBusPendingCall *pc, static void test_echo (Fixture *f, - gconstpointer context G_GNUC_UNUSED) + gconstpointer context) { + const Config *config = context; guint count = 2000; guint sent; guint received = 0; double elapsed; + if (config != NULL && config->bug_ref != NULL) + g_test_bug (config->bug_ref); + if (g_test_perf ()) count = 100000; + if (config != NULL) + count = MAX (config->min_messages, count); + add_echo_filter (f); g_test_timer_start (); @@ -307,6 +327,10 @@ teardown (Fixture *f, g_spawn_close_pid (f->daemon_pid); } +static Config limited_config = { + "34393", 10000, "valid-config-files/incoming-limit.conf" +}; + int main (int argc, char **argv) @@ -315,6 +339,8 @@ main (int argc, g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); g_test_add ("/echo/session", Fixture, NULL, setup, test_echo, teardown); + g_test_add ("/echo/limited", Fixture, &limited_config, + setup, test_echo, teardown); return g_test_run (); } -- 1.7.4.1