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
}

Comments

2 responses to “Dejagnu tips”

  1. Herpes Derpes Avatar
    Herpes Derpes

    I think the cleanup procedure can be shortened to something like this:

    proc cleanup {} {
    file delete $::test_file
    }

    Tcl is a pretty nice language, actually..
    It’s sort of hacky (in a way it’s lisp on strings) but also very easy and usually not hard to get right.
    Enjoy!

    1. Thanks for the tip, I didn’t know that your code was the way to reference globals, or whatever they are called in Tcl.
      The language works well for my tests scripts, its just a bit of a learning curve to start on Tcl and Python in a matter of months.

Leave a Reply to Herpes Derpes Cancel reply

Your email address will not be published. Required fields are marked *