summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNoah Sanci <nsanci@redhat.com>2021-08-10 11:21:35 -0400
committerNoah Sanci <nsanci@redhat.com>2021-09-16 10:21:15 -0400
commitff5056c7d78b925fbd49997dc88183f6c859ac7f (patch)
tree9ab1ff609f41406578a6901a841678f193e94db0 /tests
parent00f0fa77c995684060aa8ea6fe7276ed9b593d11 (diff)
downloadelfutils-ff5056c7d78b925fbd49997dc88183f6c859ac7f.tar.gz
debuginfod: PR27277 - Describe retrieved files when verbose
Allow users, with enough verbosity, to print the HTTP response headers upon retrieving a file. These files may include several custome http response headers such as X-DEBUGINFOD-FILE, X-DEBUGINFOD-SIZE, and X-DEBUGINFOD-ARCHIVE. These headers are added from the daemon, in debuginfod.cxx. E.g output: HTTP/1.1 200 OK Connection: Keep-Alive Content-Length: 4095072 Cache-Control: public Last-Modified: Thu, 09 Sep 2021 19:06:40 GMT X-FILE: debuginfod X-FILE-SIZE: 4095072 Content-Type: application/octet-stream Date: Fri, 10 Sep 2021 16:38:06 GMT https://sourceware.org/bugzilla/show_bug.cgi?id=27277 Signed-off-by: Noah Sanci <nsanci@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am4
-rwxr-xr-xtests/run-debuginfod-response-headers.sh96
3 files changed, 105 insertions, 1 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 3f219320..c73f2534 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -111,6 +111,12 @@
* debuginfod-subr.sh (EXTRA_DIST): Add debuginfod-subr.sh.
+2021-08-20 Noah Sanci <nsanci@redhat.com>
+
+ * run-debuginfod-response-headers.sh: Ensures custom http response
+ headers are used and functional
+ * Makefile.am: Added the above new file to TESTS and EXTRA_DIST
+
2021-08-28 Mark Wielaard <mark@klomp.org>
* run-debuginfod-find.sh: Use ":memory:" for the
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 43c34ce6..54b38954 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -232,7 +232,8 @@ TESTS += run-debuginfod-dlopen.sh \
run-debuginfod-federation-link.sh \
run-debuginfod-federation-metrics.sh \
run-debuginfod-percent-escape.sh \
- run-debuginfod-x-forwarded-for.sh
+ run-debuginfod-x-forwarded-for.sh \
+ run-debuginfod-response-headers.sh
endif
endif
@@ -526,6 +527,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
run-debuginfod-archive-rename.sh \
run-debuginfod-archive-test.sh \
run-debuginfod-percent-escape.sh \
+ run-debuginfod-response-headers.sh \
debuginfod-rpms/fedora30/hello2-1.0-2.src.rpm \
debuginfod-rpms/fedora30/hello2-1.0-2.x86_64.rpm \
debuginfod-rpms/fedora30/hello2-debuginfo-1.0-2.x86_64.rpm \
diff --git a/tests/run-debuginfod-response-headers.sh b/tests/run-debuginfod-response-headers.sh
new file mode 100755
index 00000000..bdb39b4d
--- /dev/null
+++ b/tests/run-debuginfod-response-headers.sh
@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+#
+# Copyright (C) 2019-2021 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/debuginfod-subr.sh # includes set -e
+
+# for test case debugging, uncomment:
+set -x
+
+DB=${PWD}/.debuginfod_tmp.sqlite
+tempfiles $DB
+export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache
+
+# This variable is essential and ensures no time-race for claiming ports occurs
+# set base to a unique multiple of 100 not used in any other 'run-debuginfod-*' test
+base=9500
+get_ports
+mkdir F R
+env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -R -d $DB -p $PORT1 -t0 -g0 -v R F > vlog$PORT1 2>&1 &
+PID1=$!
+tempfiles vlog$PORT1
+errfiles vlog$PORT1
+# Server must become ready
+wait_ready $PORT1 'ready' 1
+export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/ # or without trailing /
+########################################################################
+
+# Compile a simple program, strip its debuginfo and save the build-id.
+# Also move the debuginfo into another directory so that elfutils
+# cannot find it without debuginfod.
+echo "int main() { return 0; }" > ${PWD}/prog.c
+tempfiles prog.c
+# Create a subdirectory to confound source path names
+mkdir foobar
+gcc -Wl,--build-id -g -o prog ${PWD}/foobar///./../prog.c
+
+mv prog F
+
+cp -rvp ${abs_srcdir}/debuginfod-rpms R
+if [ "$zstd" = "false" ]; then # nuke the zstd fedora 31 ones
+ rm -vrf R/debuginfod-rpms/fedora31
+fi
+
+kill -USR1 $PID1
+# Wait till both files are in the index and scan/index fully finished
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
+# All rpms need to be in the index, except the dummy permission-000 one
+rpms=$(find R -name \*rpm | grep -v nothing | wc -l)
+wait_ready $PORT1 'scanned_files_total{source=".rpm archive"}' $rpms
+kill -USR1 $PID1 # two hits of SIGUSR1 may be needed to resolve .debug->dwz->srefs
+# Wait till both files are in the index and scan/index fully finished
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
+
+########################################################################
+## PR27277
+# Make a simple request to the debuginfod server and check debuginfod-find's vlog to see if
+# the custom HTTP headers are received.
+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 'Connection: ' vlog-find$PORT1.1
+grep 'Cache-Control: ' vlog-find$PORT1.1
+grep 'X-DEBUGINFOD-FILE: ' 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 'Connection: ' vlog-find$PORT1.2
+grep 'Cache-Control: ' 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
+
+kill $PID1
+wait $PID1
+PID1=0
+exit 0