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 | |
parent | 9567e3eab6672705f7259970e8606f4e7adaf991 (diff) | |
download | dbus-python-c145c7c6b6c62ef097ed33e1abeaa2987b01007d.tar.gz |
Use non-recursive make for tests, and make them into installed-tests
-rw-r--r-- | Makefile.am | 180 | ||||
-rw-r--r-- | configure.ac | 11 | ||||
-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 |
12 files changed, 277 insertions, 232 deletions
diff --git a/Makefile.am b/Makefile.am index 7b273ce..3467a68 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,11 @@ abs_top_srcdir = @abs_top_srcdir@ abs_top_builddir = @abs_top_builddir@ +installed_testdir = ${libexecdir}/installed-tests/${PACKAGE_TARNAME} +installed_test_testdir = ${installed_testdir}/test +installed_test_metadir = ${datadir}/installed-tests/${PACKAGE_TARNAME} ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = test - CLEANFILES = EXTRA_DIST = \ dbus-python.pc.in \ @@ -24,6 +25,8 @@ EXTRA_DIST = \ m4/am-check-pymod.m4 \ m4/am-check-python-headers.m4 \ m4/dbus-py-add-rst2htmlflag.m4 \ + test/TestSuitePythonService.service.in \ + test/tmp-session-bus.conf.in \ tools/check-coding-style.mk \ tools/check-c-style.sh \ tools/check-py-style.sh \ @@ -70,6 +73,12 @@ pyexec_LTLIBRARIES = \ _dbus_glib_bindings.la \ $(NULL) +if ENABLE_INSTALLED_TESTS +installed_test_LTLIBRARIES = dbus_py_test.la +else +noinst_LTLIBRARIES = dbus_py_test.la +endif + _dbus_bindings_la_LDFLAGS = \ $(pymod_ldflags) \ -export-symbols-regex \(PyInit__\|init_\)dbus_bindings \ @@ -124,6 +133,17 @@ _dbus_glib_bindings_la_SOURCES = \ _dbus_glib_bindings/module.c \ $(NULL) +# unconditionally add an -rpath to force Libtool to build a shared library +dbus_py_test_la_LDFLAGS = \ + $(pymod_ldflags) \ + $(AM_LDFLAGS) \ + -rpath $(installed_testdir) \ + $(NULL) +dbus_py_test_la_LIBADD = $(DBUS_LIBS) +dbus_py_test_la_SOURCES = \ + test/dbus_py_test.c \ + $(top_srcdir)/include/dbus-python.h + # === dbus package === nobase_python_PYTHON = \ @@ -166,10 +186,162 @@ dbusinclude_HEADERS = include/dbus-python.h # === Tests === cross-test-compile: all + cross-test-server: - @$(MAKE) -C test cross-test-server + $(AM_TESTS_ENVIRONMENT) $(PYTHON) $(top_srcdir)/test/cross-test-server.py cross-test-client: - @$(MAKE) -C test cross-test-client + $(AM_TESTS_ENVIRONMENT) $(PYTHON) $(top_srcdir)/test/cross-test-client.py + +AM_TESTS_ENVIRONMENT = \ + export DBUS_TOP_SRCDIR="$(abs_top_srcdir)"; \ + export DBUS_TOP_BUILDDIR="$(abs_top_builddir)"; \ + export DBUS_TEST_TMPDIR="$(abs_top_builddir)/test"; \ + export DBUS_TEST_UNINSTALLED=1; \ + export DBUS_PYTHON_VERSION='$(PACKAGE_VERSION)'; \ + export PYTHONPATH="$(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=$(top_builddir)/test/tmp-session-bus.conf \ + -- +installed_log_compiler = $(DBUS_RUN_SESSION) \ + --config-file=$(installed_testdir)/test/tmp-session-bus.conf \ + -- +else +LOG_COMPILER = $(top_srcdir)/test/with-session-bus.sh \ + --config-file=$(top_builddir)/test/tmp-session-bus.conf \ + -- +installed_log_compiler = $(installed_testdir)/test/with-session-bus.sh \ + --config-file=$(installed_testdir)/test/tmp-session-bus.conf \ + -- +endif + +installed_log_compiler += \ + env \ + PYTHON=$(PYTHON) \ + PYTHONPATH=$(installed_testdir):$${PYTHONPATH} \ + DBUS_TOP_SRCDIR=$(installed_testdir) \ + DBUS_TOP_BUILDDIR=$(installed_testdir) \ + $(NULL) + +SH_LOG_COMPILER = $(LOG_COMPILER) $(SHELL) +PY_LOG_COMPILER = $(LOG_COMPILER) $(PYTHON) + +dist_test_sh = \ + test/run-test.sh \ + $(NULL) + +dist_test_py = \ + test/test-client.py \ + test/test-p2p.py \ + test/test-signals.py \ + test/test-standalone.py \ + test/test-unusable-main-loop.py \ + $(NULL) + +dist_test_extra_scripts = \ + test/cross-test-client.py \ + test/cross-test-server.py \ + test/crosstest.py \ + test/test-service.py \ + test/with-session-bus.sh \ + $(NULL) + +if HAVE_PYTHON_3 +dist_test_py += test/test-exception-py3.py +else +dist_test_py += test/test-exception-py2.py +endif + +test_programs = \ + test/test-import-repeatedly \ + $(NULL) + +test_test_import_repeatedly_SOURCES = test/import-repeatedly.c +test_test_import_repeatedly_CPPFLAGS = $(PYTHON_INCLUDES) +test_test_import_repeatedly_LDADD = $(PYTHON_LIBS) + +TESTS = \ + $(dist_test_py) \ + $(dist_test_sh) \ + $(test_programs) \ + $(NULL) + +noinst_DATA = \ + test/TestSuitePythonService.service \ + test/tmp-session-bus.conf \ + $(NULL) +CLEANFILES += $(noinst_DATA) + +installed_test_test_data = \ + test/installable/TestSuitePythonService.service \ + test/installable/tmp-session-bus.conf \ + $(NULL) +CLEANFILES += $(installed_test_test_data) + +$(noinst_DATA): test/%: test/%.in + @$(MKDIR_P) $(dir $@) + $(AM_V_GEN)$(SED) \ + -e 's|[@]PYTHON[@]|$(PYTHON)|g' \ + -e 's|[@]G_TEST_SRCDIR[@]|$(abs_top_srcdir)|g' \ + -e 's|[@]G_TEST_BUILDDIR[@]|$(abs_top_builddir)|g' \ + $< > $@ + +$(installed_test_test_data): test/installable/%: test/%.in + @$(MKDIR_P) $(dir $@) + $(AM_V_GEN)$(SED) \ + -e 's|[@]PYTHON[@]|$(PYTHON)|g' \ + -e 's|[@]G_TEST_SRCDIR[@]|$(installed_testdir)|g' \ + -e 's|[@]G_TEST_BUILDDIR[@]|$(installed_testdir)|g' \ + $< > $@ + +if ENABLE_INSTALLED_TESTS +nobase_installed_test_PROGRAMS = $(test_programs) +nobase_dist_installed_test_SCRIPTS = \ + $(dist_test_py) \ + $(dist_test_sh) \ + $(dist_test_extra_scripts) \ + $(NULL) +installed_test_test_DATA = $(installed_test_test_data) +installed_test_meta_DATA = $(installed_test_metadata) +else +noinst_PROGRAMS = $(test_programs) +dist_noinst_SCRIPTS = \ + $(dist_test_py) \ + $(dist_test_sh) \ + $(dist_test_extra_scripts) \ + $(NULL) +endif + +installed_test_metadata = \ + $(patsubst %,%.test,$(dist_test_py)) \ + $(patsubst %,%.test,$(dist_test_sh)) \ + $(patsubst %,%.test,$(test_programs)) \ + $(NULL) +CLEANFILES += $(installed_test_metadata) + +$(patsubst %,%.test,$(dist_test_py)): %.test: Makefile + $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ + echo 'Type=session' >> $@.tmp; \ + echo 'Exec=$(installed_log_compiler) $(PYTHON) $(installed_testdir)/$*' >> $@.tmp; \ + mv $@.tmp $@) + +$(patsubst %,%.test,$(dist_test_sh)): %.test: Makefile + $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ + echo 'Type=session' >> $@.tmp; \ + echo 'Exec=$(installed_log_compiler) $(installed_testdir)/$*' >> $@.tmp; \ + mv $@.tmp $@) + +$(patsubst %,%.test,$(test_programs)): %.test: Makefile + $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ + echo 'Type=session' >> $@.tmp; \ + echo 'Exec=$(installed_log_compiler) $(installed_testdir)/$*$(EXEEXT)' >> $@.tmp; \ + mv $@.tmp $@) # === Documentation === diff --git a/configure.ac b/configure.ac index 01c40b4..ad8ad68 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,7 @@ m4_define([_LT_AC_TAGCONFIG],[]) AC_PROG_LIBTOOL AM_PROG_CC_C_O AC_C_INLINE +AC_PROG_MKDIR_P AM_PATH_PYTHON([2.6]) @@ -86,6 +87,13 @@ AS_IF([test "${PYTHON_LIBS+set}" = set], AC_SUBST([PYTHON_LIBS]) +AC_ARG_ENABLE([installed-tests], + [AC_HELP_STRING([--enable-installed tests], + [install test programs and helpers for as-installed testing])], + [], + [enable_installed_tests=no]) +AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], [test "_$enable_installed_tests" = _yes]) + dnl Building documentation AC_MSG_CHECKING([whether you want to build HTML docs]) @@ -223,8 +231,5 @@ AC_CONFIG_FILES([ Makefile dbus-python.pc dbus/_version.py - test/Makefile - test/tmp-session-bus.conf - test/TestSuitePythonService.service ]) AC_OUTPUT 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 --> |