testsuite/run_dump_test improvement

Fangrui Song maskray@google.com
Tue May 5 03:54:45 GMT 2020


Hi all, may the force be with you!

I have known check-gas, check-ld and check-binutils for a while, as well
as "many tests are organized as these *.d files", but I know very little
about the underlying test framework. TIL
binutils/testsuite/lib/binutils-common.exp run_dump_test is the core
that runs as, ld, and checks the output of a dump program matches the
expected patterns in the .d file (or #dump:).

Here is my first complaint: the test framework is undocumented.

2) Can we write comments in *.d?

3) Can we allow free-form shell commands instead of specialized directives?

It is mythical what can and what can't be used in `#foo:`.
OK, a user can figure out this with trial and error. Then,
why can't we have multiple dump programs? Frequently we need to check
multiple properties of an output and a single dump program just does not
work well.  The limitation led to some ad-hoc directives like `#map:`.
For example, ld-ifunc/ifunc-1-x86.d says

   #ld: -shared -Map tmpdir/ifunc-1-x86.map --hash-style=sysv
   #objdump: -dw
   #target: x86_64-*-* i?86-*-*
   #map: ifunc-1-x86.map
   
   #...
   [ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*(\+0x[0-9a-f]+|)@plt>
   #pass

If we allow free-form shell commands and use line prefixes to differentiate the two output streams (objdump -d output and ld -Map output):

   ## Test local ifunc are dumped in the link map.
   #RUN: ld: -shared -Map tmpdir/ifunc-1-x86.map --hash-style=sysv %s -o %t
   #RUN: objdump -dw %t | check  # by default, CHECK is the prefix
   #RUN: cat tmpdir/ifunc-1-x86.map | check MAP

   #CHECK: [ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*(\+0x[0-9a-f]+|)@plt>
   #CHECK-N: if there is a next line
   #CHECK-N: likewise.
   #CHECK:   skip arbitrary lines
   #CHECK-N: if there is a next line

   #MAP: Local IFUNC function ...

4) It may be nice for the pattern matching tool to recognize a substring by default.
Let {{^}}, {{$}}, or some other metacharacters to denote that "the full line should be matched"

5) It may be nice to use more descriptive filenames than *-1.d, *-2.d, or prXXXXX.d
   prXXXXX can be mentioned as comments if we allow 2)

   As it stands, many tests require guesswork before you open them in an editor.

6) Parallelism

   runtest --tool ld --srcdir ../../ld/testsuite/ took more than 2 hours
   to run on my machine. I'd expect a few seconds for a more pleasant experience.

7) Run an individual test, rather than runtest ...

I figured out that I can run partial tests with:

   # my build directory is $srcdir/Debug
   cd Debug/ld
   runtest --tool ld --srcdir ../../ld/testsuite export-dynamic-symbol.exp

but it would be convenient to be able to run just one test.


Cheers


More information about the Binutils mailing list