From d01a0b2d75b434a2dcc9606e44ce59d61f6b7dec Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Mar 2015 12:36:16 +0000 Subject: [PATCH 7/9] Run most tests under the TAP driver, with a simple adaptor for non-TAP tests --- .gitignore | 1 + configure.ac | 4 ++++ test/Makefile.am | 37 ++++++++++++++++++++++++++++--------- test/glib-tap-test.sh | 6 ++++++ test/tap-test.sh.in | 20 ++++++++++++++++++++ 5 files changed, 59 insertions(+), 9 deletions(-) create mode 100755 test/glib-tap-test.sh create mode 100644 test/tap-test.sh.in diff --git a/.gitignore b/.gitignore index 90de139..351ae75 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,5 @@ tags /lcov.html/ /lcov.info /lcov.info.tmp +/tap-driver.sh /test-driver diff --git a/configure.ac b/configure.ac index 92ffad9..40546d7 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,10 @@ COMPILER_COVERAGE COMPILER_OPTIMISATIONS PKG_PROG_PKG_CONFIG +# TAP test driver support +AC_PROG_AWK +AC_REQUIRE_AUX_FILE([tap-driver.sh]) + # This must come before we set up compiler warnings because it assumes # non-use of -Werror=missing-prototypes gl_VISIBILITY diff --git a/test/Makefile.am b/test/Makefile.am index b1ed5c9..7a23efd 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,6 +4,8 @@ SUBDIRS= . name-test DIST_SUBDIRS=name-test +EXTRA_DIST = + AM_CPPFLAGS = \ -I$(top_srcdir) \ $(DBUS_STATIC_BUILD_CPPFLAGS) \ @@ -33,6 +35,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 +60,28 @@ 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 +$(wrap_bus_tests): test-bus%.sh: ../bus/test-bus%$(EXEEXT) tap-test.sh.in + sed -e 's![@]RUN[@]!$ $@ + +$(wrap_dbus_tests): test-dbus%.sh: ../dbus/test-dbus%$(EXEEXT) tap-test.sh.in + sed -e 's![@]RUN[@]!$ $@ + else !DBUS_ENABLE_EMBEDDED_TESTS TEST_BINARIES= -TESTS= endif !DBUS_ENABLE_EMBEDDED_TESTS @@ -95,7 +114,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 diff --git a/test/glib-tap-test.sh b/test/glib-tap-test.sh new file mode 100755 index 0000000..ab2d10a --- /dev/null +++ b/test/glib-tap-test.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +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 0000000..2971379 --- /dev/null +++ b/test/tap-test.sh.in @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +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 -- 2.1.4