debuginfod: Fracture tests/run-debuginfod-find.sh into specific tests

Mark Wielaard mark@klomp.org
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.
run-debuginfod-x-forwarded-for.sh

Two tests run-debuginfod-federation-metrics.sh and run-debuginfod-
federation-sqlite.sh called get_ports twice to get an "invalid" port
number to set DEBUGINFOD_URLS. I changed this to:
export DEBUGINFOD_URLS='http://127.0.0.1:0' # 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/test-subr.sh b/tests/test-subr.sh
index 41e95e31..880d6590 100644
--- a/tests/test-subr.sh
+++ b/tests/test-subr.sh
@@ -314,14 +314,17 @@ archive_test() {
     fi
 }
 
+# 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
   done
 # 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
   done
 
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...

Ideas?

Attached the slightly updated patch, including the new run-debuginfod-
x-forwarded-for.sh, also on 
https://code.wildebeest.org/git/user/mjw/elfutils/commit/?h=debuginfod-fracture-tests

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-debuginfod-Fracture-tests-run-debuginfod-find.sh-int.patch
Type: text/x-patch
Size: 130805 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20210902/18a8521d/attachment-0001.bin>


More information about the Elfutils-devel mailing list