Debugging individual tests
From SambaWiki
Debugging individual tests in Samba4
There are many ways to debug failing tests in Samba4. This will give some of the more useful techniques.
using selftest-vars.sh
It can be useful to run Samba in a normal shell but under the selftest environment. One way to do that is this:
- start two shells
- in both shells, cd to the source4 directory of a built tree
- in one of the shells, run at least one selftest. I usually just do "make quicktest". You don't need to wait for it to complete
- in both shells run
. scripting/devel/selftest-vars.sh
That sets up all the environment variables normally used in the selftest system
- in the first shell, run
bin/samba -i -M single -d2
that starts a copy of Samba, using the selftest vars
- in the second shell, run the failing command from the "expanded command" log, for example:
./selftest/../../nsswitch/tests/test_wbinfo.sh SAMBADOMAIN Administrator localdcpass member
- it should run just as in a normal selftest
Now you can reproduce the error, you often want to run just one part of it. Try this:
bash -x ./selftest/../../nsswitch/tests/test_wbinfo.sh SAMBADOMAIN Administrator localdcpass member 2>&1 |less
that allows you to see the individual shell commands. You can then see the failure. Then you may run that individual command like this:
bin/wbinfo -u
then to narrow it down, use valgrind
valgrind -q bin/wbinfo -u
using waf test --valgrind
You can also ask the test system to use valgrind either on the client tools or on the server. To run valgrind on the client tools, use this (assuming you are wanting to test "blackbox.wbinfo")
waf test --tests=blackbox.wbinfo --valgrind
Note that not all tests are setup to use valgrind. Some tests forget to add the $VALGRIND prefix to commands. Please fix them when you run across them.
You run valgrind on the server, use this:
waf test --tests=blackbox.wbinfo --valgrind-server
that will start a xterm with a valgrind running in it, and test against that.

