DBUS_VERBOSE rocks, if a bit verbosely

A couple of tips on debugging D-Bus tests:

  • make check is your friend
  • use bus/bus-test test/data for running the bus tests
  • use dbus/dbus-test test/data for running the dbus library tests
  • to get verbose output use DBUS_VERBOSE=1 bus/bus-test test/data &> results.log - don’t let it be piped to stdout or you will be waiting for a long time for your terminal to update and will lose the most important information to your scroll buffer
  • dispatch.c(bus_dispatch_test) is the most important starting point for bus test. Comment out the tests you don’t need when debugging. This will make sure your turnaround times are a bit faster and your output a little more terse (one test gave me > 300 megs of logs in verbose mode)
  • configure options I use to test D-Bus - –enable-tests=yes –enable-verbose-mode=yes –enable-asserts=yes

The verbose output allowed me to find out that my activation failure tests were succeeding once and then failing on the next iteration. After putting in a few more verbose ouputs in strategic locations I was able to determine that on the second pass the bus was still in a state where it was waiting for the service to activate even though it had failed the first time around. It was then determined that at the new point of failure we had added, which can fail if comand line arguments to the activated program has an unterminated quote, we were not taking the pending activation out of the hash. This screwed up the state of bus which still thought it was waiting for the service to activate when in fact the service had failed to activate and should have been taken out of the pending state. Simply taking the pending activation out of the hash fixed the problem and my test now passes.

This is why we write a test suite. This bug would not have been caught otherwise. The two tests took me an hour to write but perhaps save hours of searching if this bug had turned up in the wild with no test cases. Yes they can be a pain to write and not much fun but they are worth every bit of effort that it takes to write them.

Rodrigo’s patch will go in with my fixes and then I am going to focus on fixing a python bug when removing signal handlers and then I should be ready to do the release I planned last week.

[read this post in: ar de es fr it ja ko pt ru zh-CN ]