diff options
author | Simon McVittie <smcv@debian.org> | 2016-01-20 12:19:26 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2016-01-20 12:19:26 +0000 |
commit | c145c7c6b6c62ef097ed33e1abeaa2987b01007d (patch) | |
tree | ed50397d4e6cc41e12a7934771abf5e6feda811a /test | |
parent | 9567e3eab6672705f7259970e8606f4e7adaf991 (diff) |
Use non-recursive make for tests, and make them into installed-tests
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 101 | ||||
-rw-r--r-- | test/TestSuitePythonService.service.in | 2 | ||||
-rw-r--r-- | test/dbus_python_check.py | 69 | ||||
-rwxr-xr-x | test/run-test.sh | 48 | ||||
-rwxr-xr-x | test/test-client.py | 18 | ||||
-rw-r--r-- | test/test-p2p.py | 3 | ||||
-rwxr-xr-x | test/test-service.py | 27 | ||||
-rw-r--r-- | test/test-signals.py | 19 | ||||
-rwxr-xr-x | test/test-standalone.py | 29 | ||||
-rw-r--r-- | test/tmp-session-bus.conf.in | 2 |
10 files changed, 93 insertions, 225 deletions
diff --git a/test/Makefile.am b/test/Makefile.am deleted file mode 100644 index dae9208..0000000 --- a/test/Makefile.am +++ /dev/null @@ -1,101 +0,0 @@ -abs_top_srcdir = @abs_top_srcdir@ -abs_top_builddir = @abs_top_builddir@ - -EXTRA_DIST = \ - cross-test-client.py \ - cross-test-server.py \ - crosstest.py \ - run-test.sh \ - test-client.py \ - test-exception-py2.py \ - test-exception-py3.py \ - test-p2p.py \ - test-service.py \ - test-signals.py \ - test-standalone.py \ - test-unusable-main-loop.py \ - TestSuitePythonService.service.in \ - tmp-session-bus.conf.in \ - with-session-bus.sh \ - $(NULL) - -# If you try to make this noinst, libtool helpfully gives us a static -# library, which doesn't work as a Python extension: so force the install -# target not to work here instead. -pyexec_LTLIBRARIES = dbus_py_test.la - -install: - @echo "Not installing anything from test/" - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - $(DBUS_CFLAGS) \ - $(PYTHON_INCLUDES) \ - $(NULL) -AM_CFLAGS = \ - $(WARN_CFLAGS) \ - $(NULL) -AM_LDFLAGS = \ - -module \ - -avoid-version \ - $(WARN_LDFLAGS) \ - $(NULL) - -dbus_py_test_la_LIBADD = $(DBUS_LIBS) -dbus_py_test_la_SOURCES = \ - dbus_py_test.c \ - $(top_srcdir)/include/dbus-python.h - -AM_TESTS_ENVIRONMENT = \ - export DBUS_TOP_SRCDIR="$(abs_top_srcdir)"; \ - export DBUS_TOP_BUILDDIR="$(abs_top_builddir)"; \ - export DBUS_PYTHON_VERSION='$(PACKAGE_VERSION)'; \ - export PYTHONPATH="$(abs_top_builddir)/test/.libs:$(abs_top_srcdir):$(abs_top_srcdir)/test:$(abs_top_builddir)/.libs"; \ - export PYTHON='$(PYTHON)'; \ - export DBUS_FATAL_WARNINGS=1; \ - $(NULL) - -TEST_EXTENSIONS = .sh .py - -if HAVE_DBUS_RUN_SESSION -LOG_COMPILER = $(DBUS_RUN_SESSION) \ - --config-file=tmp-session-bus.conf \ - -- -else -LOG_COMPILER = \ - $(top_srcdir)/test/with-session-bus.sh \ - --config-file=tmp-session-bus.conf \ - -- -endif - -SH_LOG_COMPILER = $(LOG_COMPILER) $(SHELL) -PY_LOG_COMPILER = $(LOG_COMPILER) $(PYTHON) - -TESTS = \ - run-test.sh \ - test-client.py \ - test-import-repeatedly \ - test-p2p.py \ - test-signals.py \ - test-standalone.py \ - test-unusable-main-loop.py \ - $(NULL) - -if HAVE_PYTHON_3 -TESTS += test-exception-py3.py -else -TESTS += test-exception-py2.py -endif - -check_PROGRAMS = test-import-repeatedly - -test_import_repeatedly_SOURCES = import-repeatedly.c -test_import_repeatedly_CPPFLAGS = $(PYTHON_INCLUDES) -test_import_repeatedly_LDADD = $(PYTHON_LIBS) - -cross-test-server: - $(AM_TESTS_ENVIRONMENT) $(PYTHON) $(top_srcdir)/test/cross-test-server.py -cross-test-client: - $(AM_TESTS_ENVIRONMENT) $(PYTHON) $(top_srcdir)/test/cross-test-client.py - -.PHONY: cross-test-compile cross-test-server cross-test-client diff --git a/test/TestSuitePythonService.service.in b/test/TestSuitePythonService.service.in index 5abdf20..b9a96df 100644 --- a/test/TestSuitePythonService.service.in +++ b/test/TestSuitePythonService.service.in @@ -1,3 +1,3 @@ [D-BUS Service] Name=org.freedesktop.DBus.TestSuitePythonService -Exec=/bin/bash -c "@PYTHON@ @abs_top_srcdir@/test/test-service.py" +Exec=/bin/bash -c "@PYTHON@ @G_TEST_SRCDIR@/test/test-service.py" diff --git a/test/dbus_python_check.py b/test/dbus_python_check.py deleted file mode 100644 index f9ae9df..0000000 --- a/test/dbus_python_check.py +++ /dev/null @@ -1,69 +0,0 @@ -"""dbus_python_check - -Implements the Distutils 'check' command. -""" - -# Copyright (C) 2006 Red Hat Inc. <http://www.redhat.com/> -# created 2006/07/12, John (J5) Palmieri -# -# Permission is hereby granted, free of charge, to any person -# obtaining a copy of this software and associated documentation -# files (the "Software"), to deal in the Software without -# restriction, including without limitation the rights to use, copy, -# modify, merge, publish, distribute, sublicense, and/or sell copies -# of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - -__revision__ = "0.1" - -from distutils.core import Command -from distutils.command.build import build -from distutils.dist import Distribution -import os - -class dbus_python_check (Command): - - # Brief (40-50 characters) description of the command - description = "Runs tests in this package" - - # List of option tuples: long name, short name (None if no short - # name), and help string. - user_options = [('help', '?', - "Shows Help"), - ] - - - def initialize_options (self): - self.dummy = None - - # initialize_options() - - - def finalize_options (self): - pass - # finalize_options() - - def run (self): - b = build(self.distribution) - b.finalize_options() - b.run() - top_builddir = os.path.join (os.getcwd(), b.build_lib) - cmd = 'DBUS_TOP_BUILDDIR="%s" test/run-test.sh'%top_builddir - print cmd - os.system (cmd) - - # run() - -# class check diff --git a/test/run-test.sh b/test/run-test.sh index 2142353..1a3d7ac 100755 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -23,15 +23,25 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +set -e + failed= skipped= -dbus-monitor > "$DBUS_TOP_BUILDDIR"/test/monitor.log & +if ! [ -d "$DBUS_TEST_TMPDIR" ]; then + DBUS_TEST_TMPDIR="$(mktemp -d)" + if ! [ -d "$DBUS_TEST_TMPDIR" ]; then + echo "failed to create temporary directory (install mktemp?)" >&2 + exit 1 + fi +fi + +dbus-monitor > "$DBUS_TEST_TMPDIR"/monitor.log & echo "DBUS_TOP_SRCDIR=$DBUS_TOP_SRCDIR" echo "DBUS_TOP_BUILDDIR=$DBUS_TOP_BUILDDIR" echo "PYTHONPATH=$PYTHONPATH" -echo "PYTHON=$PYTHON" +echo "PYTHON=${PYTHON:=python}" #echo "running the examples" @@ -48,16 +58,16 @@ echo "PYTHON=$PYTHON" echo "running cross-test (for better diagnostics use mjj29's dbus-test)" -$PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-server.py > "$DBUS_TOP_BUILDDIR"/test/cross-server.log & +$PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-server.py > "$DBUS_TEST_TMPDIR"/cross-server.log & +cross_test_server_pid="$!" sleep 1 -$PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-client.py > "$DBUS_TOP_BUILDDIR"/test/cross-client.log -e=$? +$PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-client.py > "$DBUS_TEST_TMPDIR"/cross-client.log || e=$? echo "test-client exit status: $e" if test $e = 77; then echo "cross-test-client exited $e, marking as skipped" skipped=yes -elif grep . "$DBUS_TOP_BUILDDIR"/test/cross-client.log >/dev/null; then +elif grep . "$DBUS_TEST_TMPDIR"/cross-client.log >/dev/null; then echo "OK, cross-test-client produced some output" else echo "cross-test-client produced no output" >&2 @@ -67,37 +77,45 @@ fi if test $e = 77; then echo "test-client exited $e, marking as skipped" skipped=yes -elif grep . "$DBUS_TOP_BUILDDIR"/test/cross-server.log >/dev/null; then +elif grep . "$DBUS_TEST_TMPDIR"/cross-server.log >/dev/null; then echo "OK, cross-test-server produced some output" else echo "cross-test-server produced no output" >&2 failed=yes fi -if grep fail "$DBUS_TOP_BUILDDIR"/test/cross-client.log; then +if grep fail "$DBUS_TEST_TMPDIR"/cross-client.log; then failed=yes else echo " - cross-test client reported no failures" fi -if grep untested "$DBUS_TOP_BUILDDIR"/test/cross-server.log; then +if grep untested "$DBUS_TEST_TMPDIR"/cross-server.log; then failed=yes else echo " - cross-test server reported no untested functions" fi +echo "waiting for cross-test server to exit" +if wait "$cross_test_server_pid"; then + echo "cross-test server: exit status 0" +else + echo "cross-test server: exit status $?" + failed=yes +fi + echo "==== client log ====" -cat "$DBUS_TOP_BUILDDIR"/test/cross-client.log +cat "$DBUS_TEST_TMPDIR"/cross-client.log echo "==== end ====" echo "==== server log ====" -cat "$DBUS_TOP_BUILDDIR"/test/cross-server.log +cat "$DBUS_TEST_TMPDIR"/cross-server.log echo "==== end ====" -rm -f "$DBUS_TOP_BUILDDIR"/test/test-service.log -rm -f "$DBUS_TOP_BUILDDIR"/test/cross-client.log -rm -f "$DBUS_TOP_BUILDDIR"/test/cross-server.log -rm -f "$DBUS_TOP_BUILDDIR"/test/monitor.log +rm -f "$DBUS_TEST_TMPDIR"/test-service.log +rm -f "$DBUS_TEST_TMPDIR"/cross-client.log +rm -f "$DBUS_TEST_TMPDIR"/cross-server.log +rm -f "$DBUS_TEST_TMPDIR"/monitor.log if test -n "$skipped"; then exit 77 diff --git a/test/test-client.py b/test/test-client.py index 1c8d7b4..f04b10c 100755 --- a/test/test-client.py +++ b/test/test-client.py @@ -30,9 +30,6 @@ import time import logging import weakref -builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) -pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) - import dbus import _dbus_bindings import dbus.glib @@ -48,13 +45,18 @@ except ImportError: logging.basicConfig() +if 'DBUS_TEST_UNINSTALLED' in os.environ: + builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) + pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) + pkg = dbus.__file__ -pkg = dbus.__file__ -if not pkg.startswith(pydir): - raise Exception("DBus modules (%s) are not being picked up from the package"%pkg) + if not pkg.startswith(pydir): + raise Exception("DBus modules (%s) are not being picked up from the " + "package" % pkg) -if not _dbus_bindings.__file__.startswith(builddir): - raise Exception("DBus modules (%s) are not being picked up from the package"%_dbus_bindings.__file__) + if not _dbus_bindings.__file__.startswith(builddir): + raise Exception("DBus modules (%s) are not being picked up from the " + "package" % _dbus_bindings.__file__) test_types_vals = [1, 12323231, 3.14159265, 99999999.99, "dude", "123", "What is all the fuss about?", "gob@gob.com", diff --git a/test/test-p2p.py b/test/test-p2p.py index c029c34..84443ee 100644 --- a/test/test-p2p.py +++ b/test/test-p2p.py @@ -28,9 +28,6 @@ import os import unittest import logging -builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) -pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) - import dbus import dbus.glib import dbus.service diff --git a/test/test-service.py b/test/test-service.py index a7bf469..82699d8 100755 --- a/test/test-service.py +++ b/test/test-service.py @@ -27,13 +27,22 @@ import os import logging from time import sleep -builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) -pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) - import dbus -if not dbus.__file__.startswith(pydir): - raise Exception("DBus modules are not being picked up from the package") +if 'DBUS_TEST_UNINSTALLED' in os.environ: + import _dbus_bindings + + builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) + pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) + pkg = dbus.__file__ + + if not pkg.startswith(pydir): + raise Exception("DBus modules (%s) are not being picked up from the " + "package" % pkg) + + if not _dbus_bindings.__file__.startswith(builddir): + raise Exception("DBus modules (%s) are not being picked up from the " + "package" % _dbus_bindings.__file__) import dbus.service import dbus.glib @@ -44,7 +53,13 @@ from gi.repository import GObject from dbus._compat import is_py2, is_py3 -logging.basicConfig(filename=builddir + '/test/test-service.log', filemode='a') +if 'DBUS_TEST_TMPDIR' in os.environ: + logging.basicConfig( + filename=os.environ['DBUS_TEST_TMPDIR'] + '/test-service.log', + filemode='a') +else: + logging.basicConfig() + logging.getLogger().setLevel(1) logger = logging.getLogger('test-service') diff --git a/test/test-signals.py b/test/test-signals.py index dd9e348..100cb57 100644 --- a/test/test-signals.py +++ b/test/test-signals.py @@ -29,9 +29,6 @@ import unittest import time import logging -builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) -pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) - import dbus import _dbus_bindings import dbus.glib @@ -46,14 +43,18 @@ logging.basicConfig() logging.getLogger().setLevel(1) logger = logging.getLogger('test-signals') +if 'DBUS_TEST_UNINSTALLED' in os.environ: + builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) + pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) + pkg = dbus.__file__ -pkg = dbus.__file__ -if not pkg.startswith(pydir): - raise Exception("DBus modules (%s) are not being picked up from the package"%pkg) - -if not _dbus_bindings.__file__.startswith(builddir): - raise Exception("DBus modules (%s) are not being picked up from the package"%_dbus_bindings.__file__) + if not pkg.startswith(pydir): + raise Exception("DBus modules (%s) are not being picked up from the " + "package" % pkg) + if not _dbus_bindings.__file__.startswith(builddir): + raise Exception("DBus modules (%s) are not being picked up from the " + "package" % _dbus_bindings.__file__) NAME = "org.freedesktop.DBus.TestSuitePythonService" IFACE = "org.freedesktop.DBus.TestSuiteInterface" diff --git a/test/test-standalone.py b/test/test-standalone.py index 459a41d..6a68c36 100755 --- a/test/test-standalone.py +++ b/test/test-standalone.py @@ -32,9 +32,6 @@ import sys import os import unittest -builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) -pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) - import _dbus_bindings import dbus import dbus.lowlevel as lowlevel @@ -48,21 +45,29 @@ else: def make_long(n): return long(n) +if 'DBUS_TEST_UNINSTALLED' in os.environ: + builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) + pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) + pkg = dbus.__file__ + + if not pkg.startswith(pydir): + raise Exception("DBus modules (%s) are not being picked up from the " + "package" % pkg) + + if not _dbus_bindings.__file__.startswith(builddir): + raise Exception("DBus modules (%s) are not being picked up from the " + "package" % _dbus_bindings.__file__) + + assert _dbus_bindings.__version__ == os.environ['DBUS_PYTHON_VERSION'], \ + '_dbus_bindings was compiled as version %s but Automake says '\ + 'we should be version %s' \ + % (_dbus_bindings.__version__, os.environ['DBUS_PYTHON_VERSION']) -# Check that we're using the right versions -if not dbus.__file__.startswith(pydir): - raise Exception("DBus modules (%s) are not being picked up from the package"%dbus.__file__) -if not _dbus_bindings.__file__.startswith(builddir): - raise Exception("DBus modules (%s) are not being picked up from the package"%_dbus_bindings.__file__) assert (_dbus_bindings._python_version & 0xffff0000 == sys.hexversion & 0xffff0000), \ '_dbus_bindings was compiled for Python %x but this is Python %x, '\ 'a different major version'\ % (_dbus_bindings._python_version, sys.hexversion) -assert _dbus_bindings.__version__ == os.environ['DBUS_PYTHON_VERSION'], \ - '_dbus_bindings was compiled as version %s but Automake says '\ - 'we should be version %s' \ - % (_dbus_bindings.__version__, os.environ['DBUS_PYTHON_VERSION']) class TestTypes(unittest.TestCase): diff --git a/test/tmp-session-bus.conf.in b/test/tmp-session-bus.conf.in index 3a2c756..f5fd435 100644 --- a/test/tmp-session-bus.conf.in +++ b/test/tmp-session-bus.conf.in @@ -6,7 +6,7 @@ <type>session</type> <listen>unix:tmpdir=/tmp</listen> - <servicedir>@abs_top_builddir@/test</servicedir> + <servicedir>@G_TEST_BUILDDIR@/test</servicedir> <policy context="default"> <!-- Allow everything to be sent --> |