SwirlyMyself

2009-02-12T13:55:37+00:00

Reliability testing for python-dbus applications

In the Openmoko community, a lot of programs are written in python and use services provided over D-Bus. But I’m under the impression that not enough programmers consider that D-Bus is a remote protocol, and the other side might fail to respond any time. The code then works find if nothing goes wrong, but does not handle problems well. Understandably, it is hard to get this error checking right if you can’t really test it, as usually the D-Bus services do not fail. This is particularly annoying on a phone, because it might just be the program responsible for popping up the on screen keyboard that just failed.

Therefore I started to write a little python module called python_test.py that replaces some D-Bus functions in the python bindings (SystemBus.get_object and Connection.call_blocking at the moment) and makes them fail with a certain probability. You can add "import dbus_test" to your program (and adjust $PYTHON_PATH) and run it a few times, to see which error conditions are caught and which cause your problem to fail. If you come across failures that the script does not yet generate, they can easily be added.

Not sure yet if I am going to extend and maintain this, but I’m open to suggestions and additions. Maybe this (or something similar) should be provided by python-dbus directly.

Comments

SyntaxError: Non-ASCII character '\xc2' in file /home/lindi/dbus_test.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

$ locale
LANG=
LC_CTYPE=fi_FI
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
#1 Timo Lindfors am 2009-02-13T07:15:50+00:00
Thanks for the pointer, I’ve added the utf8 encoding mark to the script.
#2 Joachim Breitner (Homepage) am 2009-02-13T13:23:20+00:00

Have something to say? You can post a comment by sending an e-Mail to me at <mail@joachim-breitner.de>, and I will include it here.