debuginfod: Fracture tests/ into specific tests

Mark Wielaard
Thu Sep 2 13:42:40 GMT 2021

Hi Noah,

I really like this split up of test cases.
I added the new x-forward-ttl testcase to it.

Two tests and run-debuginfod- called get_ports twice to get an "invalid" port
number to set DEBUGINFOD_URLS. I changed this to:
export DEBUGINFOD_URLS='' # Note invalid

The only concern I have is with get_ports. There is a race condition
selecting the random port when lots of debuginfod tests are running. It
could hand out ports that are not yet used to multiple tests.

I only managed to trigger this once, with make check -j256. So it
probably isn't a big race, but getting random failures is bad.

I don't have a good solution for this though. Maybe we could assign an
unique range to each testcase? e.g.

diff --git a/tests/ b/tests/
index 41e95e31..880d6590 100644
--- a/tests/
+++ b/tests/
@@ -314,14 +314,17 @@ archive_test() {
+# takes one argument a "base" port number, this should be unique between
+# tests to select (two) random port number between $base..$base+100.
 get_ports() {
+  base=$1
   while true; do
-    PORT1=`expr '(' $RANDOM % 1000 ')' + 9000`
+    PORT1=`expr '(' $RANDOM % 100 ')' + $base`
     ss -atn | fgrep ":$PORT1" || break
 # Some tests will use two servers, so assign the second var
   while true; do
-    PORT2=`expr '(' $RANDOM % 1000 ')' + 9000`
+    PORT2=`expr '(' $RANDOM % 100 ')' + $base`
     ss -atn | fgrep ":$PORT2" && $PORT1 -ne $PORT2 || break
And then add a unique base to each get_port call (8000, 8100, 8200,
...). We would to be careful to never assign the same unique range to
each test though. Which requires the programmer to check all other
tests. But maybe that isn't such a big deal? git grep ^get_port tests
would give you all the currently used port ranges...


Attached the slightly updated patch, including the new run-debuginfod-, also on


-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-patch
Size: 130805 bytes
Desc: not available
URL: <>

More information about the Elfutils-devel mailing list