diff options
author | Simon McVittie <smcv@collabora.com> | 2018-12-05 14:09:00 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2018-12-05 14:09:00 +0000 |
commit | a59eb6e944b2dd12f810ae85fd926d19cf7bea08 (patch) | |
tree | 5b739e1361a1755c0269e728342ce132c40c5b7a /test/name-test | |
parent | 9d721e57edce87a94e6573bbe4e76f28b53bdbd3 (diff) | |
parent | 1191262f5ebb881f9a07862f0b7b9176c502edc1 (diff) | |
download | dbus-a59eb6e944b2dd12f810ae85fd926d19cf7bea08.tar.gz |
Merge branch 'unpythonize' into 'master'
Translate Python-based tests to C
See merge request dbus/dbus!37
Reviewed-by: pwithnall
Diffstat (limited to 'test/name-test')
-rw-r--r-- | test/name-test/Makefile.am | 3 | ||||
-rwxr-xr-x | test/name-test/run-test-systemserver.sh | 18 | ||||
-rwxr-xr-x | test/name-test/run-test.sh | 18 | ||||
-rw-r--r-- | test/name-test/test-activation-forking.py | 60 | ||||
-rwxr-xr-x | test/name-test/test-wait-for-echo.py | 41 |
5 files changed, 5 insertions, 135 deletions
diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 8269feff..ea63e579 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -37,7 +37,6 @@ AM_TESTS_ENVIRONMENT = \ export DBUS_TOP_BUILDDIR=@abs_top_builddir@; \ export DBUS_TOP_SRCDIR=@abs_top_srcdir@; \ export PATH="@abs_top_builddir@/bus:$$PATH"; \ - export PYTHON=@PYTHON@; \ export DBUS_TEST_DATA=@abs_top_builddir@/test/data; \ export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \ export DBUS_TEST_DBUS_LAUNCH=@abs_top_builddir@/tools/dbus-launch$(EXEEXT); \ @@ -60,7 +59,7 @@ TESTS += \ endif endif -EXTRA_DIST=run-test.sh run-test-systemserver.sh test-wait-for-echo.py test-activation-forking.py +EXTRA_DIST=run-test.sh run-test-systemserver.sh if DBUS_ENABLE_EMBEDDED_TESTS diff --git a/test/name-test/run-test-systemserver.sh b/test/name-test/run-test-systemserver.sh index b4a04984..d8515a8c 100755 --- a/test/name-test/run-test-systemserver.sh +++ b/test/name-test/run-test-systemserver.sh @@ -68,22 +68,8 @@ dbus_send_test () { rm -f output.tmp } -py_test () { - t="$1" - shift - if test "x$PYTHON" = "x:"; then - interpret_result 77 "$t" "(Python interpreter not found)" - else - e=0 - echo "# running test $t" - $PYTHON "$DBUS_TOP_SRCDIR/test/name-test/$t" "$@" >&2 || e=$? - interpret_result "$e" "$t" "$@" - fi -} - test_num=1 -# TAP syntax: we plan to run 2 tests -echo "1..2" +# TAP syntax: we plan to run 1 test +echo "1..1" dbus_send_test test-expected-echo-fail 1 DBus.Error --print-reply --dest=org.freedesktop.DBus.TestSuiteEchoService /org/freedesktop/TestSuite org.freedesktop.TestSuite.Echo string:hi -py_test test-wait-for-echo.py diff --git a/test/name-test/run-test.sh b/test/name-test/run-test.sh index 092ec69f..9c6a55cc 100755 --- a/test/name-test/run-test.sh +++ b/test/name-test/run-test.sh @@ -53,22 +53,8 @@ c_test () { interpret_result "$e" "$t" "$@" } -py_test () { - t="$1" - shift - if test "x$PYTHON" = "x:"; then - interpret_result 77 "$t" "(Python interpreter not found)" - else - e=0 - echo "# running test $t" - $PYTHON "$DBUS_TOP_SRCDIR/test/name-test/$t" "$@" >&2 || e=$? - interpret_result "$e" "$t" "$@" - fi -} - test_num=1 -# TAP test plan: we will run 2 tests -echo "1..2" +# TAP test plan: we will run 1 test +echo "1..1" -py_test test-activation-forking.py c_test test-autolaunch diff --git a/test/name-test/test-activation-forking.py b/test/name-test/test-activation-forking.py deleted file mode 100644 index 44bc1a6e..00000000 --- a/test/name-test/test-activation-forking.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -import os,sys - -try: - from gi.repository 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 - -bus = dbus.SessionBus() -bus_iface = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus') - -o = bus.get_object('org.freedesktop.DBus.TestSuiteForkingEchoService', '/org/freedesktop/TestSuite') -i = dbus.Interface(o, 'org.freedesktop.TestSuite') - -# Start it up -reply = i.Echo("hello world") -print("TestSuiteForkingEchoService initial reply OK") - -def ignore(*args, **kwargs): - pass - -# Now monitor for exits, when that happens, start it up again. -# The goal here is to try to hit any race conditions in activation. -counter = 0 -def on_forking_echo_owner_changed(name, old, new): - global counter - global o - global i - if counter > 10: - print("Activated 10 times OK, TestSuiteForkingEchoService pass") - loop.quit() - return - counter += 1 - if new == '': - o = bus.get_object('org.freedesktop.DBus.TestSuiteForkingEchoService', '/org/freedesktop/TestSuite') - i = dbus.Interface(o, 'org.freedesktop.TestSuite') - i.Echo("counter %r" % counter) - i.Exit(reply_handler=ignore, error_handler=ignore) - -bus_iface.connect_to_signal('NameOwnerChanged', on_forking_echo_owner_changed, arg0='org.freedesktop.DBus.TestSuiteForkingEchoService') - -i.Exit(reply_handler=ignore, error_handler=ignore) - -def check_counter(): - if counter == 0: - print("Failed to get NameOwnerChanged for TestSuiteForkingEchoService") - sys.exit(1) -GObject.timeout_add(15000, check_counter) - -loop.run() -sys.exit(0) diff --git a/test/name-test/test-wait-for-echo.py b/test/name-test/test-wait-for-echo.py deleted file mode 100755 index d1b9e0c4..00000000 --- a/test/name-test/test-wait-for-echo.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -import os,sys - -try: - import dbus - import dbus.mainloop.glib - from gi.repository import GObject -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) |