currently, if a testcase use dg-output, then absolute file path will occur in the test summary reported by dejagnu which is bad. because the summary should only contain the test name and it's better to exclude all local test machine info from the report.
dg-output eventually calls dejagnu generic function "dg-test" in /usr/share/dejagnu/dg.exp, which has the following code: fail "$name output pattern test, is ${output}, should match $texttmp" the ${output} is the warning or error messages given by gcc which is in absolute path. I noticed in asan's local test method "asan-gtest", ${output} has been removed. to make sure all testcase invoking dg-output don't contain absolute path in their test summary, we need to do some post processing of gcc's output. patch attached truncate any testcase name from absolute path into relative path, and in the following logical: 1. if the testcase name is something like gcc-top/gcc/testcase/g++.dg/ubsan/k.c, then truncate into: g++.dg/ubsan/k.c (gcc-top/gcc/testcase/ removed) 2. if the testcase name is not in testcase subdirectory, for example gcc-top/gcc/libsanitizer/sanitizer_common/sanitizer_allocator.cc then truncate into: gcc/libsanitizer/sanitizer_common/sanitizer_allocator.cc (gcc-top/ removed) for example, the following test fail report: FAIL: c-c++-common/ubsan/float-cast-overflow-2.c -O0 output pattern test, is ^[[1m/work/Jiong/LOCAL-TEST/r217291/src/gcc/libsanitizer/ubsan/ubsan_handlers.cc:300: ^[[1m^[[31m runtime error: ^[[1m^[[0m^[[1mvalue 1.70141e+38 is outside the range of representable values of type '__int128'^[[1m^[[0m^M will become: FAIL: c-c++-common/ubsan/float-cast-overflow-2.c -O0 output pattern test, is ^[[1mgcc/libsanitizer/ubsan/ubsan_handlers.cc:300: ^[[1m^[[31m runtime error: ^[[1m^[[0m^[[1mvalue 1.70141e+38 is outside the range of representable values of type '__int128'^[[1m^[[0m^M The revision number contained in the file path in the old FAIL summary, the next day if only the revision number changed, the diff script will think a new pattern failed. I think remove those local info could keep the test info clean, and easier for post processing. currently, only sanitizer tess (asan/tsan/ubsan) and a couple of fortran test will invoke dg-output. pass x86-64 c/c++ regression. pass aarch64-none-linux-gnu c/c++ regression. ok for trunk? Thanks. gcc/testsuite/ * lib/gcc-dg.exp (${tool}_load): Truncate gcc output. * lib/prune.exp (prune_gcc_output): New absolute path to relative path truncation pattern.
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index a0d1e7d..8168a77 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -281,6 +281,8 @@ if { [info procs ${tool}_load] != [list] \ } set result [list $status [lindex $result 1]] } + + set result [list [lindex $result 0] [prune_gcc_output [lindex $result 1]]] return $result } } diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp index 679d894..b8b4417 100644 --- a/gcc/testsuite/lib/prune.exp +++ b/gcc/testsuite/lib/prune.exp @@ -22,6 +22,8 @@ if ![info exists TEST_ALWAYS_FLAGS] { set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret -fdiagnostics-color=never $TEST_ALWAYS_FLAGS" proc prune_gcc_output { text } { + global srcdir + #send_user "Before:$text\n" regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|substitution|program|subroutine|block-data)\[^\n\]*" $text "" text @@ -65,6 +67,11 @@ proc prune_gcc_output { text } { # Ignore harmless warnings from Xcode 4.0. regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind for\[^\n\]*" $text "" text + # Truncate absolute file path into relative path. + set topdir "[file dirname [file dirname [file dirname $srcdir]]]" + regsub -all "$srcdir\/" $text "" text + regsub -all "$topdir\/" $text "" text + #send_user "After:$text\n" return $text