]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: Break out the slow parts of test-bus into their own executables
authorSimon McVittie <smcv@collabora.com>
Mon, 3 Sep 2018 23:57:10 +0000 (16:57 -0700)
committerSimon McVittie <smcv@collabora.com>
Mon, 21 Jan 2019 15:17:36 +0000 (15:17 +0000)
This makes it more convenient to re-run the rest of test-bus as
required when debugging.

Signed-off-by: Simon McVittie <smcv@collabora.com>
cmake/test/CMakeLists.txt
test/Makefile.am
test/bus/dispatch-sha1.c [new file with mode: 0644]
test/bus/dispatch.c [new file with mode: 0644]
test/bus/main.c

index 71d358d3b3b5e6dd9a2d9d0d1d52012f0a898ccf..021438981dd68d4e5f8f025c2d9dba7144a3b093 100644 (file)
@@ -97,6 +97,14 @@ if(DBUS_ENABLE_EMBEDDED_TESTS)
     add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
     set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
 
+    set(SOURCES ${TEST_DIR}/bus/dispatch.c)
+    add_test_executable(test-bus-dispatch "${SOURCES}" dbus-daemon-internal ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
+    set_target_properties(test-bus-dispatch PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
+
+    set(SOURCES ${TEST_DIR}/bus/dispatch-sha1.c)
+    add_test_executable(test-bus-dispatch-sha1 "${SOURCES}" dbus-daemon-internal ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
+    set_target_properties(test-bus-dispatch-sha1 PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
+
     if(NOT WIN32)
         add_test_executable(test-bus-system ${TEST_DIR}/bus/system.c launch-helper-internal)
         add_test_executable(test-bus-launch-helper-oom ${TEST_DIR}/bus/launch-helper-oom.c launch-helper-internal)
index 5d34f2be13d47ab82983ef6f1706af7cfa8b6630..475fb214a8cf9396582ff6ce73fe3fd9fcb3cf6e 100644 (file)
@@ -79,7 +79,11 @@ if !DBUS_WINCE
 uninstallable_test_programs += test-spawn-oom
 endif
 
-uninstallable_test_programs += test-bus
+uninstallable_test_programs += \
+       test-bus \
+       test-bus-dispatch \
+       test-bus-dispatch-sha1 \
+       $(NULL)
 
 if DBUS_UNIX
 uninstallable_test_programs += test-bus-launch-helper-oom
@@ -168,6 +172,12 @@ test_bus_system_LDADD = $(top_builddir)/bus/liblaunch-helper-internal.la
 test_bus_SOURCES = bus/main.c
 test_bus_LDADD = $(top_builddir)/bus/libdbus-daemon-internal.la
 
+test_bus_dispatch_SOURCES = bus/dispatch.c
+test_bus_dispatch_LDADD = $(top_builddir)/bus/libdbus-daemon-internal.la
+
+test_bus_dispatch_sha1_SOURCES = bus/dispatch-sha1.c
+test_bus_dispatch_sha1_LDADD = $(top_builddir)/bus/libdbus-daemon-internal.la
+
 EXTRA_DIST += dbus-test-runner
 
 testexecdir = $(libexecdir)/installed-tests/dbus
diff --git a/test/bus/dispatch-sha1.c b/test/bus/dispatch-sha1.c
new file mode 100644 (file)
index 0000000..6902942
--- /dev/null
@@ -0,0 +1,59 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright 2003-2009 Red Hat, Inc.
+ * Copyright 2011-2018 Collabora Ltd.
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <config.h>
+
+#include "bus/test.h"
+
+#include <dbus/dbus-test-tap.h>
+#include <dbus/dbus-test-wrappers.h>
+
+#include "bus/selinux.h"
+
+#ifndef DBUS_ENABLE_EMBEDDED_TESTS
+#error This file is only relevant for the embedded tests
+#endif
+
+static void
+test_pre_hook (void)
+{
+}
+
+static void
+test_post_hook (void)
+{
+  if (_dbus_getenv ("DBUS_TEST_SELINUX"))
+    bus_selinux_shutdown ();
+}
+
+static DBusTestCase test = { "dispatch-sha1", bus_dispatch_sha1_test };
+
+int
+main (int argc, char **argv)
+{
+  return _dbus_test_main (argc, argv, 1, &test,
+                          (DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
+                           DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
+                           DBUS_TEST_FLAGS_REQUIRE_DATA),
+                          test_pre_hook, test_post_hook);
+}
diff --git a/test/bus/dispatch.c b/test/bus/dispatch.c
new file mode 100644 (file)
index 0000000..49fd802
--- /dev/null
@@ -0,0 +1,59 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright 2003-2009 Red Hat, Inc.
+ * Copyright 2011-2018 Collabora Ltd.
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <config.h>
+
+#include "bus/test.h"
+
+#include <dbus/dbus-test-tap.h>
+#include <dbus/dbus-test-wrappers.h>
+
+#include "bus/selinux.h"
+
+#ifndef DBUS_ENABLE_EMBEDDED_TESTS
+#error This file is only relevant for the embedded tests
+#endif
+
+static void
+test_pre_hook (void)
+{
+}
+
+static void
+test_post_hook (void)
+{
+  if (_dbus_getenv ("DBUS_TEST_SELINUX"))
+    bus_selinux_shutdown ();
+}
+
+static DBusTestCase test = { "dispatch", bus_dispatch_test };
+
+int
+main (int argc, char **argv)
+{
+  return _dbus_test_main (argc, argv, 1, &test,
+                          (DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
+                           DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
+                           DBUS_TEST_FLAGS_REQUIRE_DATA),
+                          test_pre_hook, test_post_hook);
+}
index 67e5c65ce15ad71bf11eafa6076c8c73732acab4..4faaa3316c180d1792aaae0591b2d1624fdcd5b1 100644 (file)
@@ -52,8 +52,6 @@ static DBusTestCase tests[] =
   { "expire-list", bus_expire_list_test },
   { "config-parser", bus_config_parser_test },
   { "signals", bus_signals_test },
-  { "dispatch-sha1", bus_dispatch_sha1_test },
-  { "dispatch", bus_dispatch_test },
   { "activation-service-reload", bus_activation_service_reload_test },
   { "unix-fds-passing", bus_unix_fds_passing_test },
   { NULL }