summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-03-02 12:36:16 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-04-16 13:06:29 +0100
commit4f4801346ef5a32c6b5bafc91383f3bb05c201a6 (patch)
tree13e266c03187eb390185982058fe5abd7a13e115 /test
parent536c5eb7cb5b8cd23907cee955ec0bfc64769e29 (diff)
downloaddbus-4f4801346ef5a32c6b5bafc91383f3bb05c201a6.tar.gz
Run most tests under the TAP driver, with a simple adaptor for non-TAP tests
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am44
-rwxr-xr-xtest/glib-tap-test.sh13
-rw-r--r--test/tap-test.sh.in32
3 files changed, 79 insertions, 10 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 2ed90505..4e46e325 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -4,6 +4,9 @@
SUBDIRS= . name-test
DIST_SUBDIRS=name-test
+CLEANFILES =
+EXTRA_DIST =
+
AM_CPPFLAGS = \
-I$(top_srcdir) \
$(DBUS_STATIC_BUILD_CPPFLAGS) \
@@ -33,6 +36,16 @@ libdbus_testutils_la_LIBADD = \
$(top_builddir)/dbus/libdbus-internal.la \
$(NULL)
+TEST_EXTENSIONS = .sh
+
+LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
+LOG_COMPILER = $(srcdir)/glib-tap-test.sh
+SH_LOG_DRIVER = $(LOG_DRIVER)
+SH_LOG_COMPILER = $(SHELL)
+EXTRA_DIST += glib-tap-test.sh
+
+TESTS =
+
if DBUS_ENABLE_EMBEDDED_TESTS
## break-loader removed for now
## these binaries are used in tests but are not themselves tests
@@ -48,21 +61,32 @@ TEST_BINARIES = \
## 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
-TESTS = \
- ../bus/test-bus$(EXEEXT) \
- ../dbus/test-dbus$(EXEEXT) \
- $(NULL)
+## since they depend on stuff from this directory. We wrap them in a
+## simple shell script to get TAP output.
+
+wrap_bus_tests = test-bus.sh
+wrap_dbus_tests = test-dbus.sh
if DBUS_UNIX
-TESTS += ../bus/test-bus-launch-helper$(EXEEXT)
-TESTS += ../bus/test-bus-system$(EXEEXT)
+wrap_bus_tests += test-bus-launch-helper.sh
+wrap_bus_tests += test-bus-system.sh
endif
+TESTS += $(wrap_bus_tests) $(wrap_dbus_tests)
+CLEANFILES += $(wrap_bus_tests) $(wrap_dbus_tests)
+EXTRA_DIST += tap-test.sh.in
+
+$(wrap_bus_tests): test-bus%.sh: ../bus/test-bus%$(EXEEXT) tap-test.sh.in Makefile
+ sed -e 's![@]RUN[@]!$<!' \
+ < $(srcdir)/tap-test.sh.in > $@
+
+$(wrap_dbus_tests): test-dbus%.sh: ../dbus/test-dbus%$(EXEEXT) tap-test.sh.in Makefile
+ sed -e 's![@]RUN[@]!$<!' \
+ < $(srcdir)/tap-test.sh.in > $@
+
else !DBUS_ENABLE_EMBEDDED_TESTS
TEST_BINARIES=
-TESTS=
endif !DBUS_ENABLE_EMBEDDED_TESTS
@@ -95,7 +119,7 @@ manual_paths_LDADD = $(top_builddir)/dbus/libdbus-internal.la
manual_tcp_SOURCES = manual-tcp.c
manual_tcp_LDADD = $(top_builddir)/dbus/libdbus-internal.la
-EXTRA_DIST = dbus-test-runner
+EXTRA_DIST += dbus-test-runner
testexecdir = $(libexecdir)/installed-tests/dbus
testmetadir = $(datadir)/installed-tests/dbus
@@ -460,7 +484,7 @@ imported_data = \
$(NULL)
noinst_DATA = $(imported_data)
-CLEANFILES = \
+CLEANFILES += \
$(noinst_DATA) \
XDG_RUNTIME_DIR \
installable \
diff --git a/test/glib-tap-test.sh b/test/glib-tap-test.sh
new file mode 100755
index 00000000..fcb73383
--- /dev/null
+++ b/test/glib-tap-test.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# Wrapper to make GTest tests output TAP syntax, because Automake's test
+# drivers do not currently support passing the same command-line argument
+# to each test executable. All GTest tests produce TAP output if invoked
+# with the --tap option.
+#
+# Usage: "glib-tap-test.sh test-foo --verbose ..." is equivalent to
+# "test-foo --tap --verbose ..."
+
+set -e
+t="$1"
+shift
+exec "$t" --tap "$@"
diff --git a/test/tap-test.sh.in b/test/tap-test.sh.in
new file mode 100644
index 00000000..743cdf39
--- /dev/null
+++ b/test/tap-test.sh.in
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Wrapper to make an Automake-style test output TAP syntax:
+#
+# - arbitrary stdout/stderr is sent to stderr where it will not be
+# interpreted as TAP
+# - it is treated as a single test-case
+# - exit 77 is a skip
+# - exit 0 is a pass
+# - anything else is a failure
+#
+# Usage: use sed to replace @RUN@ with the shell command-line to be run.
+
+set -e
+
+# we plan to do 1 test-case
+echo "1..1"
+
+e=0
+@RUN@ >&2 || e=$?
+
+case "$e" in
+ (0)
+ echo "ok 1 @RUN@"
+ ;;
+ (77)
+ echo "ok 1 # SKIP @RUN@"
+ ;;
+ (*)
+ echo "not ok 1 @RUN@ (exit status $e)"
+ ;;
+esac