[PATCH] binutils: don't abort debuginfod.exp when the server cleanup kill fails

Matt Turner <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
Both debuginfod.exp cleanup paths call

  exec kill -INT -[exp_pid]

uncaught, unlike the catch{}-wrapped close/wait that immediately
follows.  Tcl's exec raises an error when the child exits non-zero, so
if the kill fails the error propagates out of the testcase and DejaGnu
aborts the whole file:

  ERROR: tcl error sourcing .../debuginfod.exp.
  ERROR: tcl error code CHILDSTATUS 76409 1
  ERROR: child process exited abnormally
  UNRESOLVED: testcase '.../debuginfod.exp' aborted due to Tcl error

That turns a single FAIL into an aborted testcase, so the objdump and
readelf debuginfod tests that follow never run at all and the failure
is reported as UNRESOLVED rather than as the plain FAIL it is.

This is latent on hosts where the server starts and initialises
normally, since neither path is taken there.  It reproduces on a native
alpha-linux-gnu host, where debuginfod never publishes the

  thread_work_pending{role="scan"} 0

metric the test waits for, so the metric poll times out and the server
init failure path runs.

Wrap both kills in catch, matching the adjacent cleanup calls.  The
FAIL is still reported; only the spurious abort goes away.

While here, kill and reap the server on the port-scan timeout path too,
which returned without any cleanup at all.
---
 binutils/testsuite/binutils-all/debuginfod.exp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git ./binutils/testsuite/binutils-all/debuginfod.exp ./binutils/testsuite/binutils-all/debuginfod.exp
index 3abacf69832..9df419c468e 100644
--- ./binutils/testsuite/binutils-all/debuginfod.exp
+++ ./binutils/testsuite/binutils-all/debuginfod.exp
@@ -113,11 +113,13 @@ while { ! $found } {
       set found 1
     }
     "Failed to bind to port" {
-      exec kill -INT -[exp_pid]
+      catch {exec kill -INT -[exp_pid]}
       catch {close}; catch {wait -i $spawn_id}
     }
     timeout {
       fail "$test (find port timeout)"
+      catch {exec kill -INT -[exp_pid]}
+      catch {close}; catch {wait -i $spawn_id}
       return
     }
   }
@@ -145,7 +147,7 @@ foreach m $metrics {
 
   if { $timelim == 0 } {
     fail "$test (server init timeout)"
-    exec kill -INT -[exp_pid]
+    catch {exec kill -INT -[exp_pid]}
     catch {close}; catch {wait -i $spawn_id}
     return
   }
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.