gprofng: 30602 [2.41] gprofng test hangs on i686-linux-gnu
[binutils-gdb.git] / gprofng / testsuite / lib / display-lib.exp
index 0ad81b09bf046c2fec7e636b8228c47e10c03673..50db4d5055ab5a2948792620f61b1d2d9c7b9ecb 100644 (file)
 # 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.