summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@redhat.com>2019-10-27 15:26:38 -0400
committerFrank Ch. Eigler <fche@redhat.com>2019-10-27 15:26:38 -0400
commite1e56b3a2eec04e8360bbc9b644abfde672c78ee (patch)
treee120ce11f2f832437f80c77ac29b8757b4be5889
parentcf1b4aa2035e2623cf9f9fda44716311d11255ab (diff)
downloadelfutils-debuginfod.pre20191028.tar.gz
debuginfod testsuite: simplify, include SIGUSR2/groomingdebuginfod.pre20191028
-rwxr-xr-xtests/run-debuginfod-find.sh265
-rw-r--r--tests/testfile-debuginfod-0.rpm.bz2bin286808 -> 310454 bytes
-rw-r--r--tests/testfile-debuginfod-1.rpm.bz2bin751886 -> 684919 bytes
-rw-r--r--tests/testfile-debuginfod-2.rpm.bz2bin642802 -> 641788 bytes
4 files changed, 110 insertions, 155 deletions
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
index 37385a0b..2facef2c 100755
--- a/tests/run-debuginfod-find.sh
+++ b/tests/run-debuginfod-find.sh
@@ -14,14 +14,19 @@
# 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/test-subr.sh
+set -x
+. $srcdir/test-subr.sh # includes set -e
+
+# These are released Fedora 30 i686 main,-debuginfo,-debugsource rpms from koji
+# https://koji.fedoraproject.org/koji/buildinfo?buildID=1355903
testfiles testfile-debuginfod-0.rpm testfile-debuginfod-1.rpm testfile-debuginfod-2.rpm
-EXPECT_FAIL=0
-EXPECT_PASS=1
DB=${PWD}/.debuginfod_tmp.sqlite
export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache
+# clean up trash if we were aborted early
+trap 'set +e; kill $PID1 $PID2; rm -rf F R ${PWD}/.client_cache*; exit_cleanup; exit 0' 0 1 2 3 5 9 15
+
# find an unused port number
while true; do
PORT1=`expr '(' $RANDOM % 1000 ')' + 9000`
@@ -35,91 +40,124 @@ done
# it runs in a subshell, with different pid, so not helpful.
#
# So we gather the LD_LIBRARY_PATH with this cunning trick:
-
ldpath=`testrun sh -c 'echo $LD_LIBRARY_PATH'`
+mkdir F R
+tempfiles F R
+env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod -vvvv -d $DB \
+-p $PORT1 -t0 -g0 R F &
+PID1=$!
+sleep 3
+export DEBUGINFOD_URLS=http://localhost:$PORT1/ # or without trailing /
+
+# We use -t0 and -g0 here to turn off time-based scanning & grooming.
+# For testing purposes, we just sic SIGUSR1 / SIGUSR2 at the process.
+
+########################################################################
+
# 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
gcc -g -o prog ${PWD}/prog.c
${abs_top_builddir}/src/strip -g -f prog.debug ${PWD}/prog
BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
-a prog | grep 'Build ID' | cut -d ' ' -f 7`
-mkdir debug exec src
-mv prog exec/
-mv prog.debug debug/
-mv testfile-debuginfod-0.rpm debug/
+mv prog F
+mv prog.debug F
+kill -USR1 $PID1
+sleep 3 # give enough time for scanning pass
-# hardcode the buildid of an executable from testfile-debuginfod-0.rpm
-BUILDID_RPM0=43a3c5fa7e4a7469b2cf3c25d316ea898d9857fd
+########################################################################
-env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod -vvv -d $DB \
--p $PORT1 -t 2 ./debug ./exec ./src &
-PID1=$!
-sleep 3
-
-export DEBUGINFOD_URLS=http://localhost:$PORT1/ # or without trailing /
+# Test whether elfutils, via the debuginfod client library dlopen hooks,
+# is able to fetch debuginfo from the local debuginfod.
+testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog 1
-# Test whether the elfutils client is able to fetch the file from the local debuginfod.
-testrun ${abs_builddir}/debuginfod_build_id_find -e exec/prog $EXPECT_PASS
+########################################################################
-# Test whether debuginfod-find is able to fetch files from the local debuginfod's rpm and
-# directory search paths.
-rm -rf $DEBUGINFOD_CACHE_PATH
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID}/debuginfo
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID}/executable
-EOF
+# Test whether debuginfod-find is able to fetch those files.
+rm -rf $DEBUGINFOD_CACHE_PATH # clean it from previous tests
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID`
+cmp $filename F/prog.debug
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID ${PWD}/prog.c <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID}/$(echo source${PWD}/prog.c | sed -e 's\[/.]\#\g')
-EOF
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID`
+cmp $filename F/prog
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID_RPM0 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM0}/executable
-EOF
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID ${PWD}/prog.c`
+cmp $filename ${PWD}/prog.c
+########################################################################
# Add artifacts to the search paths and test whether debuginfod finds them while already running.
-mv testfile-debuginfod-1.rpm exec/
-mv testfile-debuginfod-2.rpm src/
-BUILDID_RPM1=d2db118e196b604976f95277ea64eb710c1486d0
-SRC_PATH_RPM2=/usr/src/debug/elfutils-0.177-1.fc30.x86_64/src/readelf.c
+# Build another, non-stripped binary
echo "int main() { return 0; }" > ${PWD}/prog2.c
+tempfiles prog2.c
gcc -g -o prog2 ${PWD}/prog2.c
- ${abs_top_builddir}/src/strip -g -f prog2.debug prog2
BUILDID2=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
-a prog2 | grep 'Build ID' | cut -d ' ' -f 7`
-mv prog2 exec/
-mv prog2.debug debug/
+mv prog2 F
+kill -USR1 $PID1
+sleep 3
-tempfiles prog*
+# Rerun same tests for the prog2 binary
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID2`
+cmp $filename F/prog2
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2`
+cmp $filename F/prog2
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c`
+cmp $filename ${PWD}/prog2.c
+
+mv testfile-debuginfod-0.rpm R
+mv testfile-debuginfod-1.rpm R
+mv testfile-debuginfod-2.rpm R
+kill -USR1 $PID1
+sleep 10
+kill -USR1 $PID1 # two hits of SIGUSR1 may be needed to resolve .debug->dwz->srefs
+sleep 10
+
+RPM_BUILDID=5cae7f84186d4ff6c462c32324a764f7a38c3b80 # ./usr/bin/eu-readelf
+RPM_SOURCE_PATH=/usr/src/debug/elfutils-0.177-1.fc30.i386/src/readelf.c
+RPM_EXECUTABLE_SHA1SUM=9e4c79dd91a4646d95dfbf091b133e1a21ab2d4c
+RPM_DEBUGINFO_SHA1SUM=6b638fa2abc5ff0d4d6c438d904092d20cc71827
+RPM_SOURCE_SHA1SUM=a5bde2a096f6d8f8221456c9380d3532235d7980
+
+# Run similar tests against contents of the test RPMs ... except we can't (don't want to)
+# compare the returned binary to the one in the RPM(s), so we cheat a bit, just use a
+# sha1sum comparison
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $RPM_BUILDID`
+hash=`cat $filename | sha1sum | awk '{print $1}'`
+test $hash = $RPM_EXECUTABLE_SHA1SUM
+
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $RPM_BUILDID`
+hash=`cat $filename | sha1sum | awk '{print $1}'`
+test $hash = $RPM_DEBUGINFO_SHA1SUM
+
+filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $RPM_BUILDID $RPM_SOURCE_PATH`
+hash=`cat $filename | sha1sum | awk '{print $1}'`
+test $hash = $RPM_SOURCE_SHA1SUM
+
+########################################################################
+
+# Drop some of the artifacts, run a groom cycle; confirm that
+# debuginfod has forgotten them, but remembers others
+
+rm R/testfile-*
+kill -USR2 $PID1 # groom cycle
sleep 3
+rm -rf $DEBUGINFOD_CACHE_PATH # clean it from previous tests
-testrun ${abs_builddir}/debuginfod_build_id_find -e exec/prog2 $EXPECT_PASS
+testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $RPM_BUILDID && false || true
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID2}/executable
-EOF
+testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID2}/$(echo source${PWD}/prog2.c | sed -e 's\[/.]\#\g')
-EOF
+########################################################################
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID_RPM1 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM1}/debuginfo
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID_RPM1 $SRC_PATH_RPM2 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM1}/$(echo source${SRC_PATH_RPM2} | sed -e 's\[/.]\#\g')
-EOF
+# Federation mode
# find another unused port
while true; do
@@ -127,130 +165,48 @@ while true; do
ss -atn | fgrep ":$PORT2" || break
done
-# start another server and test federation
export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache2
-env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod -vvv -d ${DB}_2 -p $PORT2 &
+mkdir -p $DEBUGINFOD_CACHE_PATH
+# NB: inherits the DEBUGINFOD_URLS to the first server
+env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod -d ${DB}_2 -p $PORT2 &
PID2=$!
sleep 3
# have clients contact the new server
export DEBUGINFOD_URLS=http://localhost:$PORT2
+testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog 1
-# test whether the new server fetches files from the original.
-testrun ${abs_builddir}/debuginfod_build_id_find -e exec/prog $EXPECT_PASS
+# test parallel queries in client
+export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache3
+mkdir -p $DEBUGINFOD_CACHE_PATH
+export DEBUGINFOD_URLS="BAD http://localhost:$PORT1 localhost:$PORT1 http://localhost:$PORT2 DNE"
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID2 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID2}/debuginfo
-EOF
+testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog2 1
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID_RPM1 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM1}/debuginfo
-EOF
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID}/executable
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID_RPM0 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM0}/executable
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID2}/$(echo source${PWD}/prog2.c | sed -e 's\[/.]\#\g')
-EOF
-
-# test parallel queries.
-rm -rf ${PWD}/.client_cache*
-export DEBUGINFOD_URLS="http://localhost:$PORT1 localhost:$PORT1 http://localhost:$PORT2 DNE"
-
-testrun ${abs_builddir}/debuginfod_build_id_find -e exec/prog $EXPECT_PASS
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID2 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID2}/debuginfo
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID_RPM1 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM1}/debuginfo
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID}/executable
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID_RPM0 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM0}/executable
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID2}/$(echo source${PWD}/prog2.c | sed -e 's\[/.]\#\g')
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID_RPM1 $SRC_PATH_RPM2 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM1}/$(echo source${SRC_PATH_RPM2} | sed -e 's\[/.]\#\g')
-EOF
+########################################################################
# Run the tests again without the servers running. The target file should
# be found in the cache.
+
kill -INT $PID1 $PID2
sleep 5
tempfiles .debuginfod_*
-testrun ${abs_builddir}/debuginfod_build_id_find -e exec/prog $EXPECT_PASS
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID2 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID2}/debuginfo
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID_RPM1 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM1}/debuginfo
-EOF
+testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog2 1
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID}/executable
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID_RPM0 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM0}/executable
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID2}/$(echo source${PWD}/prog2.c | sed -e 's\[/.]\#\g')
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID_RPM1 $SRC_PATH_RPM2 <<EOF
-${DEBUGINFOD_CACHE_PATH}/${BUILDID_RPM1}/$(echo source${SRC_PATH_RPM2} | sed -e 's\[/.]\#\g')
-EOF
+########################################################################
# Trigger a cache clean and run the tests again. The clients should be unable to
# find the target.
echo 0 > $DEBUGINFOD_CACHE_PATH/cache_clean_interval_s
echo 0 > $DEBUGINFOD_CACHE_PATH/max_unused_age_s
-testrun ${abs_builddir}/debuginfod_build_id_find -e exec/prog $EXPECT_FAIL
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID2 <<EOF
-Server query failed: No route to host
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID_RPM1 <<EOF
-Server query failed: No route to host
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID <<EOF
-Server query failed: No route to host
-EOF
-
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID_RPM0 <<EOF
-Server query failed: No route to host
-EOF
+testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog 1
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog.c <<EOF
-Server query failed: No route to host
-EOF
+testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID2 && false || true
-testrun_compare ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID_RPM1 $SRC_PATH_RPM2 <<EOF
-Server query failed: No route to host
-EOF
+########################################################################
# Ensure debuginfod-find can be safely called with no arguments.
# Use a relative path to prevent automatic line breaks in the output
@@ -261,5 +217,4 @@ Usage: ../../debuginfod/debuginfod-find debuginfo BUILDID
or: ../../debuginfod/debuginfod-find source BUILDID /FILENAME
EOF
-rm -rf debug exec src ${PWD}/.client_cache*
exit 0
diff --git a/tests/testfile-debuginfod-0.rpm.bz2 b/tests/testfile-debuginfod-0.rpm.bz2
index 106a54ad..f0a5313e 100644
--- a/tests/testfile-debuginfod-0.rpm.bz2
+++ b/tests/testfile-debuginfod-0.rpm.bz2
Binary files differ
diff --git a/tests/testfile-debuginfod-1.rpm.bz2 b/tests/testfile-debuginfod-1.rpm.bz2
index 33ea7128..ccc02712 100644
--- a/tests/testfile-debuginfod-1.rpm.bz2
+++ b/tests/testfile-debuginfod-1.rpm.bz2
Binary files differ
diff --git a/tests/testfile-debuginfod-2.rpm.bz2 b/tests/testfile-debuginfod-2.rpm.bz2
index d7f3b45d..7996b7be 100644
--- a/tests/testfile-debuginfod-2.rpm.bz2
+++ b/tests/testfile-debuginfod-2.rpm.bz2
Binary files differ