diff options
author | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2023-07-12 15:03:28 -0700 |
---|---|---|
committer | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2023-07-13 21:53:36 -0700 |
commit | 9d9f26d8b1a15561af02370f15be0af0d56ac5fa (patch) | |
tree | 3b2d342022f6f33d7560b780b69a56e065de0b48 /gprofng/testsuite | |
parent | a879fdb267171e2dfaccd3047dc5ae6d0f4bdc7e (diff) | |
download | binutils-9d9f26d8b1a15561af02370f15be0af0d56ac5fa.zip binutils-9d9f26d8b1a15561af02370f15be0af0d56ac5fa.tar.gz binutils-9d9f26d8b1a15561af02370f15be0af0d56ac5fa.tar.bz2 |
gprofng: 30602 [2.41] gprofng test hangs on i686-linux-gnu
There were several problems in the gprofng testing:
- we did not catch a timeout for each test.
- we used exit() to stop a failed test. But this stops all other tests.
- we used a time_t (long) type in smalltest.c instead of a long long type.
PR gprofng/30602
* configure.ac: Launch only native testing.
* configure: Rebuild.
* testsuite/config/default.exp: Set TEST_TIMEOUT.
* testsuite/gprofng.display/setpath_map.exp: Use return instead of exit.
* testsuite/gprofng.display/gp-archive.exp: Likewise.
* testsuite/gprofng.display/gp-collect-app_F.exp: Likewise.
* testsuite/gprofng.display/display.exp: Delete an unnecessary test
for native testing.
* testsuite/lib/display-lib.exp (run_native_host_cmd): Add timeout.
* testsuite/lib/smalltest.c: Use a long long type instead of time_t.
Diffstat (limited to 'gprofng/testsuite')
-rw-r--r-- | gprofng/testsuite/config/default.exp | 2 | ||||
-rw-r--r-- | gprofng/testsuite/gprofng.display/display.exp | 7 | ||||
-rw-r--r-- | gprofng/testsuite/gprofng.display/gp-archive.exp | 8 | ||||
-rw-r--r-- | gprofng/testsuite/gprofng.display/gp-collect-app_F.exp | 12 | ||||
-rw-r--r-- | gprofng/testsuite/gprofng.display/setpath_map.exp | 6 | ||||
-rw-r--r-- | gprofng/testsuite/lib/display-lib.exp | 18 | ||||
-rw-r--r-- | gprofng/testsuite/lib/smalltest.c | 10 |
7 files changed, 32 insertions, 31 deletions
diff --git a/gprofng/testsuite/config/default.exp b/gprofng/testsuite/config/default.exp index f76047e..1c862d5 100644 --- a/gprofng/testsuite/config/default.exp +++ b/gprofng/testsuite/config/default.exp @@ -38,6 +38,8 @@ if { "$CHECK_TARGET" == "check-install" } { set ::env(GPROFNG) "$BUILDDIR/src/gprofng" } +set TEST_TIMEOUT 300 + # Create directories where gprofng can find libraries and binaries: remote_exec host "sh -c \"rm -rf tmpdir; mkdir -p tmpdir\"" remote_exec host "sh -c \"mkdir -p lib; rm -f lib/gprofng; ln -s ../libcollector/.libs lib/gprofng\"" diff --git a/gprofng/testsuite/gprofng.display/display.exp b/gprofng/testsuite/gprofng.display/display.exp index 4698795..b021910 100644 --- a/gprofng/testsuite/gprofng.display/display.exp +++ b/gprofng/testsuite/gprofng.display/display.exp @@ -24,13 +24,6 @@ if {[info exists env(LC_ALL)]} { set env(LC_ALL) "C" set pltf [exec uname -i] - -# Native testing only for now. -if { ![istarget $pltf-*-*] - && (![string match i?86 $pltf] || ![istarget i?86-*-*]) } then { - return -} - if { "$pltf" == "aarch64" } { # Use a filter for not leaf functions due to the unwind problem in libgp-collector.so set ::env(ACCT_FILTER) [join { "|egrep -vw 'gpf|tailcallopt|" diff --git a/gprofng/testsuite/gprofng.display/gp-archive.exp b/gprofng/testsuite/gprofng.display/gp-archive.exp index 04871f9..0dd6196 100644 --- a/gprofng/testsuite/gprofng.display/gp-archive.exp +++ b/gprofng/testsuite/gprofng.display/gp-archive.exp @@ -32,7 +32,7 @@ proc check_gp_archive { a_opt } { set out [lindex $output 1] send_log "'$cmd' failed\n" fail $tdir - exit 1 + return -code break } run_native_host_cmd "mv $tdir/t.c $tdir/t.c.1" @@ -42,7 +42,7 @@ proc check_gp_archive { a_opt } { set out [lindex $output 1] send_log "CORRECTSOURCE is not found aafter '$cmd'\n" fail $tdir - exit 1 + return -code break } } @@ -58,7 +58,7 @@ if { [lindex $output 0] != 0 } then { set out [lindex $output 1] send_log "Experiment is not created in $tdir\n" fail $tdir - exit 1 + return } @@ -67,4 +67,4 @@ check_gp_archive src run_native_host_cmd "rm -rf $tdir/exp.er/archives/*; mv $tdir/t.c.1 $tdir/t.c" check_gp_archive usedsrc -pass $dir +pass $tdir diff --git a/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp b/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp index f4aa764..f791b0f 100644 --- a/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp +++ b/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp @@ -37,7 +37,13 @@ proc run_gp_collect_app { subExpCnt F_opt } { set out [lindex $output 1] send_log "Experiment is not created in $tdir\n" fail $tdir - exit 1 + return -code break + } + if {[regexp "ERROR:.*LD_PRELOAD" [lindex $output 1] match]} { + set out [lindex $output 1] + send_log "Experiment is not created in $tdir\n" + xfail $tdir + return -code break } set output [run_native_host_cmd "find $tdir -name '*x1.er' | wc -l"] @@ -46,7 +52,7 @@ proc run_gp_collect_app { subExpCnt F_opt } { set out [lindex $output 1] send_log "Test failed for -F $F_opt. subExp=$subExp. Shold be $subExpCnt\n" fail $tdir - exit 1 + return -code break } return $output } @@ -58,5 +64,5 @@ run_gp_collect_app 3 "on" run_gp_collect_app 1 "=mkd.r" run_gp_collect_app 2 "=mkdir|touch" -pass $dir +pass $tdir diff --git a/gprofng/testsuite/gprofng.display/setpath_map.exp b/gprofng/testsuite/gprofng.display/setpath_map.exp index 698076d..fd0c00b 100644 --- a/gprofng/testsuite/gprofng.display/setpath_map.exp +++ b/gprofng/testsuite/gprofng.display/setpath_map.exp @@ -36,7 +36,7 @@ if { [lindex $output 0] != 0 } then { set out [lindex $output 1] send_log "Experiment is not created in $tdir\n" fail $tdir - exit 1 + return } # Copy the "good" file to $tdir/src. Mark old file as "wrong": @@ -49,7 +49,7 @@ if { [string first "CORRECTSOURCE" [lindex $output 1]] < 0 } then { set out [lindex $output 1] send_log "CORRECTSOURCE is not found in $gprofng display text -setpath $tdir/src -source main $tdir/exp.er\n" fail $tdir - exit 1 + return } # Test -pathmap: @@ -59,7 +59,7 @@ if { [string first "CORRECTSOURCE" [lindex $output 1]] < 0 } then { set out [lindex $output 1] send_log "CORRECTSOURCE is not found in $gprofng display text -pathmap $tdir $tdir/src -source main $tdir/exp.er\n" fail $tdir - exit 1 + return } pass $dir diff --git a/gprofng/testsuite/lib/display-lib.exp b/gprofng/testsuite/lib/display-lib.exp index 0ad81b0..50db4d5 100644 --- a/gprofng/testsuite/lib/display-lib.exp +++ b/gprofng/testsuite/lib/display-lib.exp @@ -21,28 +21,26 @@ # Run the COMMAND on the host and return a list of the form # { exit-status OUTPUT }. proc run_native_host_cmd { command } { - global link_output - global ld + global TEST_TIMEOUT verbose -log "$command" set run_output "" try { - set run_output [exec "sh" "-c" "$command" "2>@1"] + send_log "% timeout $TEST_TIMEOUT sh -c '$command' 2>&1\n" + set run_output [exec "timeout" $TEST_TIMEOUT "sh" "-c" "$command" "2>&1"] set status 0 } trap CHILDSTATUS {results options} { set status [lindex [dict get $options -errorcode] 2] - set run_output $results + set run_output "$results" + if { $status == 124 || $status == 133 } { + send_log " ERROR: TIMEOUT($TEST_TIMEOUT sec.)\n" + } } regsub "\n$" $run_output "" run_output if { [lindex $status 0] != 0 && [string match "" $run_output] } then { append run_output "child process exited abnormally" } - - if [string match "" $run_output] then { - return "" - } - - return [list [lindex $status 0] $run_output] + return [list [lindex $status 0] "$run_output"] } # Run a display test in DIR. diff --git a/gprofng/testsuite/lib/smalltest.c b/gprofng/testsuite/lib/smalltest.c index 49bd395..fe6531e 100644 --- a/gprofng/testsuite/lib/smalltest.c +++ b/gprofng/testsuite/lib/smalltest.c @@ -1,11 +1,13 @@ #include <stdio.h> #include <time.h> -time_t +typedef long long hrtime_t; + +hrtime_t gethrtime (void) { struct timespec tp; - time_t rc = 0; + hrtime_t rc = 0; #ifdef CLOCK_MONOTONIC_RAW int r = clock_gettime (CLOCK_MONOTONIC_RAW, &tp); #else @@ -13,7 +15,7 @@ gethrtime (void) #endif if (r == 0) - rc = ((time_t) tp.tv_sec) * 1e9 + (time_t) tp.tv_nsec; + rc = ((hrtime_t) tp.tv_sec) * 1e9 + (hrtime_t) tp.tv_nsec; return rc; } @@ -23,7 +25,7 @@ int main (int argc, char **argv) { long long count = 0; - time_t start = gethrtime (); + hrtime_t start = gethrtime (); do { |