So I’m mucking around with DejaGNU, trying to build a sensible test suite for filtergen (and by sensible, I don’t mean sensible, but instead “sufficiently different to that of GCC that the documentation and examples are really not helping”).
Basically, I can’t get my test program to be executed properly; stdout is some basic verification output to confirm that my scanner and parser are behaving correctly, whilst stderr captures all the warnings and errors – but the harness doesn’t like this: every time a message gets to stderr, the harness crashes. This seems to contradict the behaviour expected from reading /usr/share/dejagnu/dg.exp
and this message, in which one expects to be able to test the warnings, errors, and output of a program.
So eventually, after pouring over gcc testsuite libraries, trying to work out how it all sticks together, I find myself in /usr/share/dejagnu/remote.exp
, looking at local_exec
, and I see this gem:
# Tcl's exec is a pile of crap. It does two very inappropriate things
# firstly, it has no business returning an error if the program being
# executed happens to write to stderr. Secondly, it appends its own
# error messages to the output of the command if the process exits with
# non-zero status.
EUREKA!
The rest of this function is comic gold; here’s another beautiful piece of prose (though certainly not the best nor the limit of entertainment one can find in this function).
# Uuuuuuugh. Now I'm getting really sick.
# If we didn't get an EOF, we have to kill the poor defenseless program.
# However, Tcl has no kill primitive, so we have to execute an external
# command in order to execute the execution. (English. Gotta love it.)