summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-11-14 17:53:31 +0000
committerSimon McVittie <smcv@collabora.com>2017-11-15 12:12:43 +0000
commit3baad75ca94173f44bb65c941694ab7a765eeed6 (patch)
tree3ebd58cfc22b0f5e13bae4c5d6a5dc65f0ac69fe
parentea43f3db48ad1ac01b47a2eab6b4567fbd968c45 (diff)
test-bus*: Output TAP directly
Reviewed-by: Philip Withnall <withnall@endlessm.com> Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103601
-rw-r--r--bus/test-launch-helper.c26
-rw-r--r--bus/test-main.c121
-rw-r--r--bus/test-system.c22
-rw-r--r--test/Makefile.am12
4 files changed, 48 insertions, 133 deletions
diff --git a/bus/test-launch-helper.c b/bus/test-launch-helper.c
index 3555958b8..71856d68f 100644
--- a/bus/test-launch-helper.c
+++ b/bus/test-launch-helper.c
@@ -35,25 +35,6 @@
#error This file is only relevant for the embedded tests on Unix
#endif
-static void
-check_memleaks (const char *name)
-{
- dbus_shutdown ();
-
- _dbus_test_diag ("%s: checking for memleaks", name);
- if (_dbus_get_malloc_blocks_outstanding () != 0)
- {
- _dbus_test_fatal ("%d dbus_malloc blocks were not freed",
- _dbus_get_malloc_blocks_outstanding ());
- }
-}
-
-static void
-test_post_hook (const char *name)
-{
- check_memleaks (name);
-}
-
#ifdef ACTIVATION_LAUNCHER_DO_OOM
/* returns true if good things happen, or if we get OOM */
@@ -123,9 +104,10 @@ main (int argc, char **argv)
(char *) "org.freedesktop.DBus.TestSuiteEchoService"))
_dbus_test_fatal ("OOM test failed");
- test_post_hook (argv[0]);
+ /* ... otherwise it must have passed */
+ _dbus_test_ok ("%s", argv[0]);
- _dbus_test_diag ("%s: Success", argv[0]);
+ _dbus_test_check_memleaks (argv[0]);
- return 0;
+ return _dbus_test_done_testing ();
}
diff --git a/bus/test-main.c b/bus/test-main.c
index bf37751c3..400ea423f 100644
--- a/bus/test-main.c
+++ b/bus/test-main.c
@@ -40,20 +40,9 @@
# include <dbus/dbus-sysdeps-unix.h>
#endif
-static void
-check_memleaks (const char *name)
-{
- dbus_shutdown ();
-
- _dbus_test_diag ("%s: checking for memleaks", name);
- if (_dbus_get_malloc_blocks_outstanding () != 0)
- {
- _dbus_test_fatal ("%d dbus_malloc blocks were not freed",
- _dbus_get_malloc_blocks_outstanding ());
- }
-}
-
+static const char *only;
static DBusInitialFDs *initial_fds = NULL;
+static DBusString test_data_dir;
static void
test_pre_hook (void)
@@ -67,27 +56,43 @@ test_pre_hook (void)
initial_fds = _dbus_check_fdleaks_enter ();
}
-static const char *progname = "";
-
static void
-test_post_hook (void)
+test_post_hook (const char *name)
{
if (_dbus_getenv ("DBUS_TEST_SELINUX"))
bus_selinux_shutdown ();
- check_memleaks (progname);
+ _dbus_test_check_memleaks (name);
_dbus_check_fdleaks_leave (initial_fds);
initial_fds = NULL;
}
+static void
+test_one (const char *name,
+ dbus_bool_t (*func) (const DBusString *))
+{
+ if (only != NULL && strcmp (only, name) != 0)
+ {
+ _dbus_test_skip ("%s - Only intending to run %s", name, only);
+ return;
+ }
+
+ _dbus_test_diag ("Running test: %s", name);
+
+ test_pre_hook ();
+
+ if (func (&test_data_dir))
+ _dbus_test_ok ("%s", name);
+ else
+ _dbus_test_not_ok ("%s", name);
+
+ test_post_hook (name);
+}
+
int
main (int argc, char **argv)
{
const char *dir;
- const char *only;
- DBusString test_data_dir;
-
- progname = argv[0];
if (argc > 1 && strcmp (argv[1], "--tap") != 0)
dir = argv[1];
@@ -112,72 +117,18 @@ main (int argc, char **argv)
if (!_dbus_threads_init_debug ())
_dbus_test_fatal ("OOM initializing debug threads");
- if (only == NULL || strcmp (only, "expire-list") == 0)
- {
- test_pre_hook ();
- _dbus_test_diag ("%s: Running expire list test", argv[0]);
- if (!bus_expire_list_test (&test_data_dir))
- _dbus_test_fatal ("expire list test failed");
- test_post_hook ();
- }
-
- if (only == NULL || strcmp (only, "config-parser") == 0)
- {
- test_pre_hook ();
- _dbus_test_diag ("%s: Running config file parser test", argv[0]);
- if (!bus_config_parser_test (&test_data_dir))
- _dbus_test_fatal ("parser test failed");
- test_post_hook ();
- }
-
- if (only == NULL || strcmp (only, "signals") == 0)
- {
- test_pre_hook ();
- _dbus_test_diag ("%s: Running signals test", argv[0]);
- if (!bus_signals_test (&test_data_dir))
- _dbus_test_fatal ("signals test failed");
- test_post_hook ();
- }
-
- if (only == NULL || strcmp (only, "dispatch-sha1") == 0)
- {
- test_pre_hook ();
- _dbus_test_diag ("%s: Running SHA1 connection test", argv[0]);
- if (!bus_dispatch_sha1_test (&test_data_dir))
- _dbus_test_fatal ("sha1 test failed");
- test_post_hook ();
- }
-
- if (only == NULL || strcmp (only, "dispatch") == 0)
- {
- test_pre_hook ();
- _dbus_test_diag ("%s: Running message dispatch test", argv[0]);
- if (!bus_dispatch_test (&test_data_dir))
- _dbus_test_fatal ("dispatch test failed");
- test_post_hook ();
- }
-
- if (only == NULL || strcmp (only, "activation-service-reload") == 0)
- {
- test_pre_hook ();
- _dbus_test_diag ("%s: Running service files reloading test", argv[0]);
- if (!bus_activation_service_reload_test (&test_data_dir))
- _dbus_test_fatal ("service reload test failed");
- test_post_hook ();
- }
+ test_one ("expire-list", bus_expire_list_test);
+ test_one ("config-parser", bus_config_parser_test);
+ test_one ("signals", bus_signals_test);
+ test_one ("dispatch-sha1", bus_dispatch_sha1_test);
+ test_one ("dispatch", bus_dispatch_test);
+ test_one ("activation-service-reload", bus_activation_service_reload_test);
#ifdef HAVE_UNIX_FD_PASSING
- if (only == NULL || strcmp (only, "unix-fds-passing") == 0)
- {
- test_pre_hook ();
- _dbus_test_diag ("%s: Running unix fd passing test", argv[0]);
- if (!bus_unix_fds_passing_test (&test_data_dir))
- _dbus_test_fatal ("unix fd passing test failed");
- test_post_hook ();
- }
+ test_one ("unix-fds-passing", bus_unix_fds_passing_test);
+#else
+ _dbus_test_skip ("fd-passing not supported on this platform");
#endif
- _dbus_test_diag ("%s: Success", argv[0]);
-
- return 0;
+ return _dbus_test_done_testing ();
}
diff --git a/bus/test-system.c b/bus/test-system.c
index a434b6fa8..d4311b00a 100644
--- a/bus/test-system.c
+++ b/bus/test-system.c
@@ -35,19 +35,6 @@
#endif
static void
-check_memleaks (const char *name)
-{
- dbus_shutdown ();
-
- _dbus_test_diag ("%s: checking for memleaks", name);
- if (_dbus_get_malloc_blocks_outstanding () != 0)
- {
- _dbus_test_fatal ("%d dbus_malloc blocks were not freed",
- _dbus_get_malloc_blocks_outstanding ());
- }
-}
-
-static void
test_pre_hook (void)
{
}
@@ -56,7 +43,7 @@ static const char *progname = "";
static void
test_post_hook (void)
{
- check_memleaks (progname);
+ _dbus_test_check_memleaks (progname);
}
int
@@ -84,9 +71,10 @@ main (int argc, char **argv)
_dbus_test_diag ("%s: Running config file parser (trivial) test", argv[0]);
if (!bus_config_parser_trivial_test (&test_data_dir))
_dbus_test_fatal ("OOM creating parser");
- test_post_hook ();
- _dbus_test_diag ("%s: Success", argv[0]);
+ /* All failure modes for this test are currently fatal */
+ _dbus_test_ok ("%s", argv[0]);
+ test_post_hook ();
- return 0;
+ return _dbus_test_done_testing ();
}
diff --git a/test/Makefile.am b/test/Makefile.am
index 2721a4a90..719e8653f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -73,20 +73,14 @@ TEST_BINARIES = \
## since they depend on stuff from this directory. We wrap some of them in a
## simple shell script to get TAP output.
-wrap_bus_tests = test-bus.sh
+TESTS += ../bus/test-bus$(EXEEXT)
if DBUS_UNIX
-wrap_bus_tests += test-bus-launch-helper.sh
-wrap_bus_tests += test-bus-system.sh
+TESTS += ../bus/test-bus-launch-helper$(EXEEXT)
+TESTS += ../bus/test-bus-system$(EXEEXT)
endif
-TESTS += $(wrap_bus_tests)
TESTS += ../dbus/test-dbus$(EXEEXT)
-CLEANFILES += $(wrap_bus_tests)
-
-$(wrap_bus_tests): test-bus%.sh: ../bus/test-bus%$(EXEEXT) tap-test.sh.in Makefile
- sed -e 's![@]RUN[@]!$<!' \
- < $(srcdir)/tap-test.sh.in > $@
else !DBUS_ENABLE_EMBEDDED_TESTS