1#!/usr/bin/env bash 2# 3# Copyright (C) 2019-2021 Red Hat, Inc. 4# This file is part of elfutils. 5# 6# This file is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 3 of the License, or 9# (at your option) any later version. 10# 11# elfutils is distributed in the hope that it will be useful, but 12# WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19. $srcdir/debuginfod-subr.sh 20 21# for test case debugging, uncomment: 22set -x 23unset VALGRIND_CMD 24# This variable is essential and ensures no time-race for claiming ports occurs 25# set base to a unique multiple of 100 not used in any other 'run-debuginfod-*' test 26base=8200 27get_ports 28DB=${PWD}/.debuginfod_tmp.sqlite 29export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache 30export DEBUGINFOD_TIMEOUT=10 31tempfiles $DEBUGINFOD_CACHE_PATH $DB 32# Clean old dirictories 33mkdir R ${PWD}/F 34env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE \ 35 -F -R -d $DB -p $PORT1 -t0 -g0 -v R ${PWD}/F > vlog$PORT1 2>&1 & 36 37PID1=$! 38tempfiles vlog$PORT1 39errfiles vlog$PORT1 40# Server must become ready 41wait_ready $PORT1 'ready' 1 42# Check thread comm names 43ps -q $PID1 -e -L -o '%p %c %a' | grep groom 44ps -q $PID1 -e -L -o '%p %c %a' | grep scan 45ps -q $PID1 -e -L -o '%p %c %a' | grep traverse 46 47# wait till the initial scan is done before triggering a new one 48# and before dropping new file into the scan dirs 49wait_ready $PORT1 'thread_work_total{role="traverse"}' 1 50# Same for the initial groom cycle, we don't want it to be done 51# half way initializing the file setup 52wait_ready $PORT1 'thread_work_total{role="groom"}' 1 53 54cp -rvp ${abs_srcdir}/debuginfod-rpms R 55if [ "$zstd" = "false" ]; then # nuke the zstd fedora 31 ones 56 rm -vrf R/debuginfod-rpms/fedora31 57fi 58 59kill -USR1 $PID1 60# Now there should be 1 files in the index 61wait_ready $PORT1 'thread_work_total{role="traverse"}' 2 62wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 63wait_ready $PORT1 'thread_busy{role="scan"}' 0 64 65# common source file sha1 66SHA=f4a1a8062be998ae93b8f1cd744a398c6de6dbb1 67 68######################################################################## 69## PR26810: Now rename some files in the R directory, then rescan, so 70# there are two copies of the same buildid in the index, one for the 71# no-longer-existing file name, and one under the new name. 72 73# run a groom cycle to force server to drop its fdcache 74kill -USR2 $PID1 # groom cycle 75wait_ready $PORT1 'thread_work_total{role="groom"}' 2 76# move it around a couple of times to make it likely to hit a nonexistent entry during iteration 77mv R/debuginfod-rpms/rhel7 R/debuginfod-rpms/rhel7renamed 78kill -USR1 $PID1 # scan cycle 79wait_ready $PORT1 'thread_work_total{role="traverse"}' 3 80wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 81wait_ready $PORT1 'thread_busy{role="scan"}' 0 82mv R/debuginfod-rpms/rhel7renamed R/debuginfod-rpms/rhel7renamed2 83kill -USR1 $PID1 # scan cycle 84wait_ready $PORT1 'thread_work_total{role="traverse"}' 4 85wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 86wait_ready $PORT1 'thread_busy{role="scan"}' 0 87mv R/debuginfod-rpms/rhel7renamed2 R/debuginfod-rpms/rhel7renamed3 88kill -USR1 $PID1 # scan cycle 89wait_ready $PORT1 'thread_work_total{role="traverse"}' 5 90wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 91wait_ready $PORT1 'thread_busy{role="scan"}' 0 92 93export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1 94 95# retest rhel7 96archive_test bc1febfd03ca05e030f0d205f7659db29f8a4b30 /usr/src/debug/hello-1.0/hello.c $SHA 97archive_test f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2 /usr/src/debug/hello-1.0/hello.c $SHA 98 99egrep '(libc.error.*rhel7)|(bc1febfd03ca)|(f0aa15b8aba)' vlog$PORT1 100 101kill $PID1 102wait $PID1 103PID1=0 104exit 0; 105