summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNoah Sanci <nsanci@redhat.com>2022-06-15 10:07:29 -0400
committerFrank Ch. Eigler <fche@redhat.com>2022-09-06 11:32:13 -0400
commitbbc2ca6d553f0ce3e670303ac9a3c764cf10d779 (patch)
treeb08f81afb310c8c46cffdbeeb8e7881f7401573f /tests
parenta176b6e30aa8983c95b81f18c34a2b5c6a0c907b (diff)
downloadelfutils-bbc2ca6d553f0ce3e670303ac9a3c764cf10d779.tar.gz
PR28284 - Debuginfod header functionality implemented
Debuginfod and debuginfod clients are now equipped to send and receive http headers prefixed with X-DEBUGINFOD and print them in verbose mode for more context Signed-off-by: Noah Sanci <nsanci@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog6
-rwxr-xr-xtests/run-debuginfod-response-headers.sh48
2 files changed, 48 insertions, 6 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index d2952cc9..659bfa19 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2022-07-15 Noah Sanci <nsanci@redhat.com>
+
+ * run-debuginfod-response-headers.sh: Added test
+ to ensure that federated servers pass headers down to
+ queried server.
+
2022-08-04 Sergei Trofimovich <slyich@gmail.com>
* low_high_pc.c (handle_die): Drop redundant 'lx' suffix.
diff --git a/tests/run-debuginfod-response-headers.sh b/tests/run-debuginfod-response-headers.sh
index 62c43887..e5698cc9 100755
--- a/tests/run-debuginfod-response-headers.sh
+++ b/tests/run-debuginfod-response-headers.sh
@@ -73,17 +73,21 @@ rm -rf $DEBUGINFOD_CACHE_PATH
env DEBUGINFOD_URLS="http://127.0.0.1:"$PORT1 LD_LIBRARY_PATH=$ldpath ${abs_top_builddir}/debuginfod/debuginfod-find\
-vvv executable F/prog > vlog-find$PORT1.1 2>&1
tempfiles vlog-find$PORT1.1
-grep 'Content-Length: ' vlog-find$PORT1.1
-grep 'X-DEBUGINFOD-FILE: ' vlog-find$PORT1.1
-grep 'X-DEBUGINFOD-SIZE: ' vlog-find$PORT1.1
+errfiles vlog-find$PORT1.1
+cat vlog-find$PORT1.1
+grep 'Headers:' vlog-find$PORT1.1
+grep 'X-DEBUGINFOD-FILE: prog' vlog-find$PORT1.1
+grep 'X-DEBUGINFOD-SIZE: ' vlog-find$PORT1.1
# Check to see if an executable file located in an archive prints the file's description and archive
env DEBUGINFOD_URLS="http://127.0.0.1:"$PORT1 LD_LIBRARY_PATH=$ldpath ${abs_top_builddir}/debuginfod/debuginfod-find\
-vvv executable c36708a78618d597dee15d0dc989f093ca5f9120 > vlog-find$PORT1.2 2>&1
tempfiles vlog-find$PORT1.2
-grep 'Content-Length: ' vlog-find$PORT1.2
-grep 'X-DEBUGINFOD-FILE: ' vlog-find$PORT1.2
-grep 'X-DEBUGINFOD-SIZE: ' vlog-find$PORT1.2
+errfiles vlog-find$PORT1.2
+cat vlog-find$PORT1.2
+grep 'Headers:' vlog-find$PORT1.2
+grep 'X-DEBUGINFOD-FILE: ' vlog-find$PORT1.2
+grep 'X-DEBUGINFOD-SIZE: ' vlog-find$PORT1.2
grep 'X-DEBUGINFOD-ARCHIVE: ' vlog-find$PORT1.2
# Check that X-DEBUGINFOD-SIZE matches the size of each file
@@ -94,6 +98,38 @@ do
test $st_size -eq $x_debuginfod_size
done
+rm -rf $DEBUGINFOD_CACHE_PATH
+BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
+ -a F/prog | grep 'Build ID' | cut -d ' ' -f 7`
+netcat_dir="buildid/$BUILDID/"
+mkdir -p ${PWD}/$netcat_dir
+cp F/prog ${PWD}/$netcat_dir/executable
+tempfiles F/prog
+
+# Netcat dies after answering the request
+nc -l -p $PORT2 -c 'echo -e "HTTP/1.1 200 OK\nX-DEBUGINFOD-SIZE: ba:d_size\nX-DEBUGINFOD-\rFILE:\=\+ \r213\n\n $(date)"' & < ${PWD}/$netcat_dir"executable" &
+# Wait until the netcat port is in use. Otherwise debuginfod-find can query
+# before netcat is ready.
+SECONDS=0
+nc_start=$SECONDS
+while [ ! $(lsof -i -P -n | grep LISTEN | grep "nc.*$PORT2") ]
+do
+ # If it takes longer than 5 seconds for netcat to start up, then fail
+ duration=$(( SECONDS - nc_start ))
+ if [ $SECONDS -gt 5 ]
+ then
+ err
+ fi
+done
+
+env DEBUGINFOD_URLS="http://127.0.0.1:"$PORT2 LD_LIBRARY_PATH=$ldpath ${abs_top_builddir}/debuginfod/debuginfod-find\
+ -vvv executable $BUILDID > vlog-find$PORT2 2>&1
+errfiles vlog-find$PORT2
+tempfiles vlog-find$PORT2
+cat vlog-find$PORT2 | grep "X-DEBUGINFOD-"
+rm -f "$netcat_dir"executable
+rmdir -p $netcat_dir
+
kill $PID1
wait $PID1
PID1=0