]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Convert spawn test into a standalone test executable
authorSimon McVittie <smcv@collabora.com>
Fri, 28 Sep 2018 14:53:40 +0000 (15:53 +0100)
committerSimon McVittie <smcv@collabora.com>
Mon, 21 Jan 2019 15:15:16 +0000 (15:15 +0000)
This test is sufficiently well-separated that there's no real need
to embed it in libdbus. Move it into the test directory instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
cmake/dbus/CMakeLists.txt
cmake/test/CMakeLists.txt
dbus/Makefile.am
dbus/dbus-test-main.c
dbus/dbus-test.h
test/Makefile.am
test/internals/spawn-oom.c [moved from dbus/dbus-spawn-test.c with 94% similarity]

index 77b6c10abd45e73a71ac5c8c4c6074a35d53f8ed..d25cc96158c602ba2e5f64a5ff5a1abffbf22e03 100644 (file)
@@ -171,7 +171,6 @@ set (DBUS_UTIL_SOURCES
 if (DBUS_ENABLE_EMBEDDED_TESTS)
        set (DBUS_UTIL_SOURCES 
                ${DBUS_UTIL_SOURCES}
-               ${DBUS_DIR}/dbus-spawn-test.c
                ${DBUS_DIR}/dbus-test-wrappers.c
        )
 endif (DBUS_ENABLE_EMBEDDED_TESTS)
index b505cc6172bae7d74def8a204dd3d01c15f4e02e..8d18119c37102871ec4c81441bf76cebf8975fa6 100644 (file)
@@ -77,6 +77,9 @@ add_test_executable(test-printf ${TEST_DIR}/internals/printf.c dbus-testutils)
 add_helper_executable(test-privserver ${TEST_DIR}/test-privserver.c dbus-testutils)
 add_helper_executable(test-shell-service ${test-shell-service_SOURCES} dbus-testutils)
 add_helper_executable(test-spawn ${test-spawn_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
+if(NOT WINCE)
+    add_test_executable(test-spawn-oom ${TEST_DIR}/internals/spawn-oom.c ${DBUS_INTERNAL_LIBRARIES})
+endif()
 add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
 # the second argument of add_helper_executable() is a whitespace-separated
 # list of source files and the third and subsequent arguments are libraries
index 08fb850ec40a151a4235ca867881bc7f0fddabab..aa0f5ed0b9e013f5e03ea5fc4af2287a0bd9e016 100644 (file)
@@ -270,7 +270,6 @@ DBUS_UTIL_SOURCES=                          \
 
 if DBUS_ENABLE_EMBEDDED_TESTS
 DBUS_UTIL_SOURCES += \
-       dbus-spawn-test.c \
        dbus-test-wrappers.c \
        dbus-test-wrappers.h \
        $(NULL)
index 7a4eda7e67e899dea8207524cad17fa6e8fd7148..76036d9c27b4e895ff918fe693d60aad96b38122 100644 (file)
@@ -56,10 +56,6 @@ static DBusTestCase tests[] =
   { "transport-unix", _dbus_transport_unix_test },
 #endif
 
-#if !defined(DBUS_WINCE)
-  { "spawn", _dbus_spawn_test },
-#endif
-
   { NULL }
 };
 
index 4476a5e5ac2c63207d501bdf714fa064bb7bfef7..29f78915af99607a5fec2b897cf2771d8ade22ff 100644 (file)
@@ -80,7 +80,6 @@ DBUS_PRIVATE_EXPORT
 dbus_bool_t _dbus_data_slot_test         (const char *test_data_dir);
 
 dbus_bool_t _dbus_sysdeps_test           (const char *test_data_dir);
-dbus_bool_t _dbus_spawn_test             (const char *test_data_dir);
 
 DBUS_PRIVATE_EXPORT
 dbus_bool_t _dbus_userdb_test            (const char *test_data_dir);
index 1e7c2db44ec1de58e0add14d298d924a73e351a0..f408a1680b9dde85ad0e0caaa828084aaf5ad5ca 100644 (file)
@@ -58,8 +58,12 @@ EXTRA_DIST += glib-tap-test.sh
 EXTRA_DIST += tap-test.sh.in
 
 TESTS =
+noinst_PROGRAMS =
 
 if DBUS_ENABLE_EMBEDDED_TESTS
+
+uninstallable_test_programs =
+
 ## break-loader removed for now
 ## these binaries are used in tests but are not themselves tests
 TEST_BINARIES = \
@@ -71,6 +75,10 @@ TEST_BINARIES = \
        test-shell-service \
        $(NULL)
 
+if !DBUS_WINCE
+uninstallable_test_programs += test-spawn-oom
+endif
+
 ## These are conceptually part of directories that come earlier in SUBDIRS
 ## order, but we don't want to run them til we arrive in this directory,
 ## since they depend on stuff from this directory. We wrap some of them in a
@@ -85,13 +93,16 @@ endif
 
 TESTS += ../dbus/test-dbus$(EXEEXT)
 
+noinst_PROGRAMS += $(uninstallable_test_programs)
+TESTS += $(uninstallable_test_programs)
+
 else !DBUS_ENABLE_EMBEDDED_TESTS
 
 TEST_BINARIES=
 
 endif !DBUS_ENABLE_EMBEDDED_TESTS
 
-noinst_PROGRAMS= $(TEST_BINARIES)
+noinst_PROGRAMS += $(TEST_BINARIES)
 
 # This helper is meant to crash, so if we're compiling the rest with
 # AddressSanitizer, we need to stop it from catching the SIGSEGV and
@@ -108,6 +119,8 @@ test_shell_SOURCES = shell-test.c
 test_shell_LDADD = libdbus-testutils.la
 test_spawn_SOURCES = spawn-test.c
 test_spawn_LDADD = $(top_builddir)/dbus/libdbus-internal.la
+test_spawn_oom_SOURCES = internals/spawn-oom.c
+test_spawn_oom_LDADD = $(top_builddir)/dbus/libdbus-internal.la
 
 test_assertions_SOURCES = internals/assertions.c
 test_assertions_LDADD = libdbus-testutils.la $(GLIB_LIBS)
similarity index 94%
rename from dbus/dbus-spawn-test.c
rename to test/internals/spawn-oom.c
index 6bc6f025a81963c905ae666e500f1365c56587d1..8551effe8b995ea82eaee00cb8327d16bee0f817 100644 (file)
  */
 #include <config.h>
 
-
-#include "dbus-spawn.h"
-#include "dbus-sysdeps.h"
-#include "dbus-test.h"
+#include "dbus/dbus-internals.h"
+#include "dbus/dbus-spawn.h"
+#include "dbus/dbus-sysdeps.h"
+#include "dbus/dbus-test.h"
+#include "dbus/dbus-test-wrappers.h"
 
 static char *
 get_test_exec (const char *exe,
@@ -265,7 +266,7 @@ check_spawn_and_kill (void        *data,
   return TRUE;
 }
 
-dbus_bool_t
+static dbus_bool_t
 _dbus_spawn_test (const char *test_data_dir)
 {
   if (!_dbus_test_oom_handling ("spawn_nonexistent",
@@ -290,3 +291,14 @@ _dbus_spawn_test (const char *test_data_dir)
 
   return TRUE;
 }
+
+static DBusTestCase test = { "spawn", _dbus_spawn_test };
+
+int
+main (int    argc,
+      char **argv)
+{
+  return _dbus_test_main (argc, argv, 1, &test,
+                          DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS,
+                          NULL, NULL);
+}