diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/name-test/Makefile.am | 4 | ||||
-rwxr-xr-x | test/name-test/run-test-systemserver.sh | 50 | ||||
-rwxr-xr-x | test/name-test/test-wait-for-echo.py | 41 | ||||
-rw-r--r-- | test/name-test/tmp-session-like-system.conf | 91 |
4 files changed, 184 insertions, 2 deletions
diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 17e05bec..10a2536d 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -5,12 +5,12 @@ INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_TEST_C ## TESTS if DBUS_BUILD_TESTS TESTS_ENVIRONMENT=DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ -TESTS=run-test.sh +TESTS=run-test.sh run-test-systemserver.sh else TESTS= endif -EXTRA_DIST=run-test.sh +EXTRA_DIST=run-test.sh run-test-systemserver.sh test-wait-for-echo.py if DBUS_BUILD_TESTS diff --git a/test/name-test/run-test-systemserver.sh b/test/name-test/run-test-systemserver.sh new file mode 100755 index 00000000..34dd6487 --- /dev/null +++ b/test/name-test/run-test-systemserver.sh @@ -0,0 +1,50 @@ +#! /bin/sh +die() +{ + if ! test -z "$DBUS_SESSION_BUS_PID" ; then + echo "killing message bus "$DBUS_SESSION_BUS_PID >&2 + kill -9 $DBUS_SESSION_BUS_PID + fi + echo $SCRIPTNAME: $* >&2 + + exit 1 +} + +SCRIPTNAME=$0 +MODE=$1 + +## so the tests can complain if you fail to use the script to launch them +DBUS_TEST_NAME_RUN_TEST_SCRIPT=1 +export DBUS_TEST_NAME_RUN_TEST_SCRIPT + +SOURCE_CONFIG_FILE=$DBUS_TOP_SRCDIR/test/name-test/tmp-session-like-system.conf +export SOURCE_CONFIG_FILE +# Rerun ourselves with tmp session bus if we're not already +if test -z "$DBUS_TEST_NAME_IN_SYS_RUN_TEST"; then + DBUS_TEST_NAME_IN_SYS_RUN_TEST=1 + export DBUS_TEST_NAME_IN_SYS_RUN_TEST + exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE +fi + +if test -n "$DBUS_TEST_MONITOR"; then + dbus-monitor --session & +fi + +echo "running test-expected-echo-fail" +${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/tools/dbus-send --print-reply --dest=org.freedesktop.DBus.TestSuiteEchoService /org/freedesktop/TestSuite org.freedesktop.TestSuite.Echo string:hi >echo-error-output.tmp 2>&1 +if ! grep -q 'DBus.Error' echo-error-output.tmp; then + echo "Didn't get expected failure; output was:" + echo "=====" + cat echo-error-output.tmp + echo "=====" + exit 1 +fi + +echo "running test echo signal" +if ! python ./test-wait-for-echo.py; then + echo "Failed test-wait-for-echo" + exit 1 +fi + + +exit 0 diff --git a/test/name-test/test-wait-for-echo.py b/test/name-test/test-wait-for-echo.py new file mode 100755 index 00000000..bd09e459 --- /dev/null +++ b/test/name-test/test-wait-for-echo.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +import os,sys + +try: + import gobject + import dbus + import dbus.mainloop.glib +except: + print "Failed import, aborting test" + sys.exit(0) + +dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) +loop = gobject.MainLoop() + +exitcode = 0 + +def handle_noreceipt(): + print "Failed to get signal" + global exitcode + exitcode = 1 + loop.quit() + +gobject.timeout_add(7000, handle_noreceipt) + +bus = dbus.SessionBus() + +def sighandler(*args, **kwargs): + print "got signal" + loop.quit() + +bus.add_signal_receiver(sighandler, dbus_interface='org.freedesktop.TestSuite', signal_name='Foo') + +o = bus.get_object('org.freedesktop.DBus.TestSuiteEchoService', '/org/freedesktop/TestSuite') +i = dbus.Interface(o, 'org.freedesktop.TestSuite') +def nullhandler(*args, **kwargs): + pass +i.EmitFoo(reply_handler=nullhandler, error_handler=nullhandler) + +loop.run() +sys.exit(exitcode) diff --git a/test/name-test/tmp-session-like-system.conf b/test/name-test/tmp-session-like-system.conf new file mode 100644 index 00000000..29ab115f --- /dev/null +++ b/test/name-test/tmp-session-like-system.conf @@ -0,0 +1,91 @@ +<!-- This configuration file controls the per-user-login-session message bus. + Add a session-local.conf and edit that rather than changing this + file directly. --> + +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <!-- Our well-known bus type, don't change this --> + <type>session</type> + + <!-- If we fork, keep the user's original umask to avoid affecting + the behavior of child processes. --> + <keep_umask/> + + <syslog/> + + <listen>unix:tmpdir=/tmp</listen> + + <standard_session_servicedirs /> + + <!-- intended to match system bus --> + <policy context="default"> + <!-- All users can connect to system bus --> + <allow user="*"/> + + <!-- Holes must be punched in service configuration files for + name ownership and sending method calls --> + <deny own="*"/> + <deny send_type="method_call"/> + + <!-- Signals and reply messages (method returns, errors) are allowed + by default --> + <allow send_type="signal"/> + <allow send_requested_reply="true" send_type="method_return"/> + <allow send_requested_reply="true" send_type="error"/> + + <!-- All messages may be received by default --> + <allow receive_type="method_call"/> + <allow receive_type="method_return"/> + <allow receive_type="error"/> + <allow receive_type="signal"/> + + <!-- Allow anyone to talk to the message bus --> + <allow send_destination="org.freedesktop.DBus"/> + <!-- But disallow some specific bus services --> + <deny send_destination="org.freedesktop.DBus" + send_interface="org.freedesktop.DBus" + send_member="UpdateActivationEnvironment"/> + + <!-- Specific to the test suite --> + <allow own="org.freedesktop.DBus.TestSuiteEchoService"/> + <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService" + send_interface="org.freedesktop.DBus.Introspectable"/> + <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService" + send_interface="org.freedesktop.TestSuite" + send_member="EmitFoo"/> + </policy> + + <policy context="default"> + <allow own="org.freedesktop.DBus.TestSuiteEchoService"/> + <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService" + send_interface="org.freedesktop.DBus.Introspectable"/> + <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService" + send_interface="org.freedesktop.TestSuite" + send_member="EmitFoo"/> + </policy> + + <!-- For the session bus, override the default relatively-low limits + with essentially infinite limits, since the bus is just running + as the user anyway, using up bus resources is not something we need + to worry about. In some cases, we do set the limits lower than + "all available memory" if exceeding the limit is almost certainly a bug, + having the bus enforce a limit is nicer than a huge memory leak. But the + intent is that these limits should never be hit. --> + + <!-- the memory limits are 1G instead of say 4G because they can't exceed 32-bit signed int max --> + <limit name="max_incoming_bytes">1000000000</limit> + <limit name="max_outgoing_bytes">1000000000</limit> + <limit name="max_message_size">1000000000</limit> + <limit name="service_start_timeout">120000</limit> + <limit name="auth_timeout">240000</limit> + <limit name="max_completed_connections">100000</limit> + <limit name="max_incomplete_connections">10000</limit> + <limit name="max_connections_per_user">100000</limit> + <limit name="max_pending_service_starts">10000</limit> + <limit name="max_names_per_connection">50000</limit> + <limit name="max_match_rules_per_connection">50000</limit> + <limit name="max_replies_per_connection">50000</limit> + <limit name="reply_timeout">300000</limit> + +</busconfig> |