From 3020ee184f929bd381be590fefe50b33e7798c17 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 20 Jul 2016 12:00:34 +0100 Subject: [PATCH 01/10] test: add a regression test for eval "$(dbus-launch --sh-syntax)" Signed-off-by: Simon McVittie --- test/Makefile.am | 27 +++++++++++++++++-- test/test-dbus-launch-eval.sh | 63 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100755 test/test-dbus-launch-eval.sh diff --git a/test/Makefile.am b/test/Makefile.am index 0efd204..ed2947a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -127,6 +127,7 @@ EXTRA_DIST += dbus-test-runner testexecdir = $(libexecdir)/installed-tests/dbus testmetadir = $(datadir)/installed-tests/dbus +dist_testexec_SCRIPTS = testexec_PROGRAMS = testmeta_DATA = @@ -139,6 +140,8 @@ installable_manual_tests = \ manual-dir-iter \ manual-tcp \ $(NULL) +dist_installable_test_scripts = \ + $(NULL) if DBUS_WIN installable_manual_tests += manual-paths @@ -164,6 +167,14 @@ if DBUS_UNIX installable_tests += \ test-sd-activation \ $(NULL) + +# Testing dbus-launch relies on special code in that binary. +if DBUS_ENABLE_EMBEDDED_TESTS +dist_installable_test_scripts += \ + test-dbus-launch-eval.sh \ + $(NULL) +endif DBUS_ENABLE_EMBEDDED_TESTS + endif DBUS_UNIX installable_manual_tests += \ @@ -171,14 +182,21 @@ installable_manual_tests += \ $(NULL) endif DBUS_WITH_GLIB -installable_test_meta = $(installable_tests:=.test) -installable_test_meta_with_config = $(installable_tests:=_with_config.test) +installable_test_meta = \ + $(dist_installable_test_scripts:=.test) \ + $(installable_tests:=.test) \ + $(NULL) +installable_test_meta_with_config = \ + $(dist_installable_test_scripts:=_with_config.test) \ + $(installable_tests:=_with_config.test) \ + $(NULL) installcheck_tests = installcheck_environment = \ export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \ export DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT); \ export DBUS_TEST_DBUS_LAUNCH=$(DESTDIR)$(bindir)/dbus-launch$(EXEEXT); \ + export DBUS_TEST_DBUS_SEND=$(DESTDIR)$(bindir)/dbus-send$(EXEEXT); \ export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \ export DBUS_TEST_DATADIR=$(DESTDIR)$(datadir); \ ${NULL} @@ -188,6 +206,7 @@ AM_TESTS_ENVIRONMENT = \ export DBUS_FATAL_WARNINGS=1; \ export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \ export DBUS_TEST_DBUS_LAUNCH=@abs_top_builddir@/tools/dbus-launch$(EXEEXT); \ + export DBUS_TEST_DBUS_SEND=@abs_top_builddir@/tools/dbus-send$(EXEEXT); \ export DBUS_TEST_DATA=@abs_top_builddir@/test/data; \ export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \ $(NULL) @@ -274,12 +293,16 @@ test_fdpass_LDADD = \ $(GLIB_LIBS) \ $(NULL) +TESTS += $(dist_installable_test_scripts) +installcheck_tests += $(dist_installable_test_scripts) + if DBUS_ENABLE_MODULAR_TESTS TESTS += $(installable_tests) installcheck_tests += $(installable_tests) if DBUS_ENABLE_INSTALLED_TESTS testexec_PROGRAMS += $(installable_tests) $(installable_manual_tests) + dist_testexec_SCRIPTS += $(dist_installable_test_scripts) testmeta_DATA += $(installable_test_meta) testmeta_DATA += $(installable_test_meta_with_config) diff --git a/test/test-dbus-launch-eval.sh b/test/test-dbus-launch-eval.sh new file mode 100755 index 0000000..7b5a66d --- /dev/null +++ b/test/test-dbus-launch-eval.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# Copyright © 2016 Collabora Ltd. +# +# 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. + +set -e + +export DBUS_DEBUG_OUTPUT=1 +echo "# dbus-daemon binary: ${DBUS_TEST_DAEMON:=dbus-daemon}" +echo "# dbus-launch binary: ${DBUS_TEST_DBUS_LAUNCH:=dbus-launch}" +echo "# dbus-send binary: ${DBUS_TEST_DBUS_SEND:=dbus-send}" + +if test -n "$DBUS_TEST_DATA"; then + echo "# test data: $DBUS_TEST_DATA" + config="--config-file=$DBUS_TEST_DATA/valid-config-files/session.conf" +elif test -n "$DBUS_TEST_DATADIR"; then + echo "# datadir: $DBUS_TEST_DATADIR" + config="--config-file=$DBUS_TEST_DATADIR/dbus-1/session.conf" +else + echo "# using standard session bus configuration" + # add a harmless command-line argument + config="--sh-syntax" +fi + +echo "1..1" + +unset DBUS_SESSION_BUS_ADDRESS +unset DBUS_SESSION_BUS_PID + +eval "$(${DBUS_TEST_DBUS_LAUNCH} --sh-syntax "$config")" + +test -n "$DBUS_SESSION_BUS_ADDRESS" +env | grep '^DBUS_SESSION_BUS_ADDRESS=' + +test -n "$DBUS_SESSION_BUS_PID" +test "x$(env | grep '^DBUS_SESSION_BUS_PID=')" = "x" +kill -0 "$DBUS_SESSION_BUS_PID" + +${DBUS_TEST_DBUS_SEND} --session --dest=org.freedesktop.DBus \ + --type=method_call --print-reply / org.freedesktop.DBus.ListNames >&2 + +kill "$DBUS_SESSION_BUS_PID" + +echo "ok 1 - normal dbus-launch" -- 2.8.1