The jit testsuite detects if
RUN_UNDER_VALGRIND
is present in the
environment (with any value). If it is present, it runs the test client
code under valgrind18,
specifcally, the default
memcheck19
tool with
–leak-check=full20.
It automatically parses the output from valgrind, injecting XFAIL results if
any issues are found, or PASS results if the output is clean. The output
is saved to TESTNAME.exe.valgrind.txt
.
For example, the following invocation verbosely runs the testcase
test-sum-of-squares.c
under valgrind, showing an issue:
$ RUN_UNDER_VALGRIND= \ make check-jit \ RUNTESTFLAGS="-v -v -v jit.exp=test-sum-of-squares.c" (...verbose log contains detailed valgrind errors, if any...) === jit Summary === # of expected passes 28 # of expected failures 2 $ less testsuite/jit/jit.sum (...other results...) XFAIL: jit.dg/test-sum-of-squares.c: test-sum-of-squares.c.exe.valgrind.txt: definitely lost: 8 bytes in 1 blocks XFAIL: jit.dg/test-sum-of-squares.c: test-sum-of-squares.c.exe.valgrind.txt: unsuppressed errors: 1 (...other results...) $ less testsuite/jit/test-sum-of-squares.c.exe.valgrind.txt (...shows full valgrind report for this test case...)
When running under valgrind, it’s best to have configured gcc with
--enable-valgrind-annotations
, which automatically suppresses
various known false positives.