[Ltrace-devel] Valgrind in testsuite and new vocabulary for testsuite

Petr Machata pmachata at redhat.com
Sat Oct 6 21:55:44 UTC 2012


Hi there,

on branch pmachata/valgrind are two testsuite fixlets and a patch for
running testsuite under valgrind.  This is enabled by --enable-valgrind
passed to configure.  The code was essentially cut'n'pasted from
elfutils, original author is Mark Wielaard.  I consider this
uncontroversial and will merge soon, unless I hear objections.

Plugging this into expect, I somehow got fed up with the mess that the
test suite is in.  The heaps of duplicated code, the hidden state
carried from one run to another, there's a lot that irks me.  I used to
blame TCL for this, but after hacking on this, I think it's just the way
we do things.

I went through several iterations of fixing (parts of) testsuite and
figuring out what would be the best way to express test cases.  I'm
pretty comfortable with the following (main-internal.exp):

	set bin [ltraceCompile {} [ltraceSource c {
	    __attribute__((noinline)) void this(void) {}
	    __attribute__((noinline)) void that(void) {}
	    int main(int i) {
		for (i = 0; i < 12; ++i) {
		    this();
		    that();
		}
	    }
	}]]

	ltraceMatch [ltraceRun -L -xthis -- $bin] {
	    {{this\(.*\)} == 12}
	    {that == 0}
	}

	ltraceDone

As you can see, we can now embed sources directly into the expect
script.  The notation is not much more compact, but there's less hidden
state and hopefully less cargo-culting necessary to write a new test
case.  It's also all in one place, no external source files necessary.

Notably, all the duplicated checks for ELF from incompatible
architecture, unsupported hash format and other things (various tests
did different checks) are gone.  They might still come back in some
form, but this time they will be an implementation detail of ltrace.exp.
Currently DejaGNU fails loudly if any such case happens, which is
perhaps less user-friendly.

It is still possible to write stuff the old way, and likely always will
be, I'm not about to convert the almost 200 tests that we do.  I would
like to convert parameters.exp, where I hope to somehow script the
correlation between program, library, config file, and the script,
because it's annoying to update it all every time I want to add a new
test.  But otherwise this is mostly for newly added tests.

This is on pmachata/testsuite.  Comments welcome.

Thanks,
PM



More information about the Ltrace-devel mailing list