Dejagnu tips

Both the procps and psmisc projects use Dejagnu for their testing.  It’s interesting to try to understand how it all works and learning a new language TCL.  One of the big problems with Dejagnu is its documentation which is very sparse. So here are two things I’ve picked up along the way for a reference for myself and others.

Locale

We recently had a bug report on the procps list where tests for w failed for someone when the headers were shown.  After a some further debugging it was a locale problem, where the testsuite was looking for a number like 3.14 but the tester was seeing 3,14. There are many ways around this but for us it was to set the locale, with the following line in config/unix.exp after suggestions by Mike Frysinger should fix it.

set env(LC_ALL) "C"

Cleaning Up
The documentation on this function is awesome! A title “Cleanup Procedure” and one line “cleanup()”.
That’s all you get. The cleanup proc or function is called at the end of the testing. I use it
to remove temporary files and things like that.

proc cleanup { } {
        global test_file
        exec rm $test_file
}