diff options
author | Aaron Merey <amerey@redhat.com> | 2020-01-15 10:18:27 -0500 |
---|---|---|
committer | Aaron Merey <amerey@redhat.com> | 2020-01-15 10:18:27 -0500 |
commit | a37859278e25f3a5236fe0c44c244a8c5498849a (patch) | |
tree | 7309239b87cb8a9c81ec63c4c22a36da850e31c3 | |
parent | fdc05223e26e3f1535186ed4f3628914c461f946 (diff) | |
download | binutils-gdb-a37859278e25f3a5236fe0c44c244a8c5498849a.tar.gz |
binutils/testsuite: improve server init checks in debuginfod.exp
-rw-r--r-- | binutils/testsuite/binutils-all/debuginfod.exp | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/binutils/testsuite/binutils-all/debuginfod.exp b/binutils/testsuite/binutils-all/debuginfod.exp index 596fcf58df8..01eabab2dee 100644 --- a/binutils/testsuite/binutils-all/debuginfod.exp +++ b/binutils/testsuite/binutils-all/debuginfod.exp @@ -73,12 +73,21 @@ if { ![binutils_assemble $srcdir/$subdir/linkdebug.s tmpdir/linkdebug.debug] } { } # Find an unused port -set port [exec sh -c "while true; do PORT=`expr '(' \$RANDOM % 1000 ')' + 9000`; ss -atn | fgrep \":\$PORT\" || break; done; echo \$PORT"] +set port 0 +for {set timelim 10} {!$port && $timelim != 0 } {incr timelim -1} { + sleep 0.5 + set port [exec sh -c "while true; do PORT=`expr '(' \$RANDOM % 1000 ')' + 9000`; ss -atn | fgrep \":\$PORT\" || break; done; echo \$PORT"] +} + +if { !$port } { + untested "$test (can't find open port)" + return +} -# Specify the directory that files retrieved from the server are written to. set cache [file join [pwd] "tmpdir/.debuginfod_cache"] +set db [file join [pwd] "tmpdir/.debuginfod.db"] -set ::env(DEBUGINFOD_URLS) http://127.0.0.1:$port +set ::env(DEBUGINFOD_URLS) "" set ::env(DEBUGINFOD_TIMEOUT) 30 set ::env(DEBUGINFOD_CACHE_PATH) $cache @@ -88,8 +97,9 @@ file mkdir tmpdir/dbg file rename -force tmpdir/testprog.debug tmpdir/dbg file rename -force tmpdir/linkdebug.debug tmpdir/dbg -# Remove an old cache if it exists +# Remove old cache and db if they exist. file delete -force $cache +file delete -force $db # Check whether objdump and readelf are configured with debuginfod. # To check this we attempt to follow a broken debuglink. If configured @@ -114,30 +124,39 @@ proc sigint_handler {} { trap sigint_handler INT # Start a debuginfod server. -set debuginfod_pid [exec debuginfod -p $port -F tmpdir/dbg 2>/dev/null &] +set debuginfod_pid [exec debuginfod -vvvv -d $db -p $port -F tmpdir/dbg >/dev/null 2>&1 &] if { !$debuginfod_pid } { fail "$test (server init)" return } -# Wait for debuginfod indicate it's ready. -set ready 0 -for {set timelim 30} {$timelim != 0} {incr timelim -1} { +set metrics [list "ready 1" \ + "thread_work_total{role=\"traverse\"} 1" \ + "thread_work_pending{role=\"scan\"} 0" \ + "thread_busy{role=\"scan\"} 0" \ + "groom{statistic=\"buildids\"} 2"] + +# Check server metrics to confirm init has completed. +foreach m $metrics { + set timelim 20 + while { $timelim != 0 } { sleep 1 - set want ".*ready 1.*" + catch {exec curl -s http://127.0.0.1:$port/metrics} got - if { [regexp $want $got] } { - set ready 1 + if { [regexp $m $got] } { break } -} -if { !$ready } { - fail "$test (server ready)" + incr timelim -1 + } + + if { $timelim == 0 } { + fail "$test (server init timeout)" catch {exec kill -INT $debuginfod_pid} return + } } # Test whether prog can fetch separate debuginfo using debuginfod @@ -171,6 +190,8 @@ proc test_fetch_debugaltlink { prog progargs } { } } +set ::env(DEBUGINFOD_URLS) http://127.0.0.1:$port + if { [regexp ".*DEBUGINFOD.*" $conf_objdump] } { test_fetch_debuglink $OBJDUMP "-W" test_fetch_debugaltlink $OBJDUMP "-WK" |