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 30tempfiles $DEBUGINFOD_CACHE_PATH $DB 31# Clean old dirictories 32mkdir R ${PWD}/F 33env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE \ 34 -F -R -d $DB -p $PORT1 -t0 -g0 -v R ${PWD}/F > vlog$PORT1 2>&1 & 35 36PID1=$! 37tempfiles vlog$PORT1 38errfiles vlog$PORT1 39# Server must become ready 40wait_ready $PORT1 'ready' 1 41# Check thread comm names 42ps -q $PID1 -e -L -o '%p %c %a' | grep groom 43ps -q $PID1 -e -L -o '%p %c %a' | grep scan 44ps -q $PID1 -e -L -o '%p %c %a' | grep traverse 45 46# wait till the initial scan is done before triggering a new one 47# and before dropping new file into the scan dirs 48wait_ready $PORT1 'thread_work_total{role="traverse"}' 1 49# Same for the initial groom cycle, we don't want it to be done 50# half way initializing the file setup 51wait_ready $PORT1 'thread_work_total{role="groom"}' 1 52 53cp -rvp ${abs_srcdir}/debuginfod-rpms R 54if [ "$zstd" = "false" ]; then # nuke the zstd fedora 31 ones 55 rm -vrf R/debuginfod-rpms/fedora31 56fi 57 58kill -USR1 $PID1 59# Now there should be 1 files in the index 60wait_ready $PORT1 'thread_work_total{role="traverse"}' 2 61wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 62wait_ready $PORT1 'thread_busy{role="scan"}' 0 63 64# common source file sha1 65SHA=f4a1a8062be998ae93b8f1cd744a398c6de6dbb1 66 67######################################################################## 68## PR26810: Now rename some files in the R directory, then rescan, so 69# there are two copies of the same buildid in the index, one for the 70# no-longer-existing file name, and one under the new name. 71 72# run a groom cycle to force server to drop its fdcache 73kill -USR2 $PID1 # groom cycle 74wait_ready $PORT1 'thread_work_total{role="groom"}' 2 75# move it around a couple of times to make it likely to hit a nonexistent entry during iteration 76mv R/debuginfod-rpms/rhel7 R/debuginfod-rpms/rhel7renamed 77kill -USR1 $PID1 # scan cycle 78wait_ready $PORT1 'thread_work_total{role="traverse"}' 3 79wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 80wait_ready $PORT1 'thread_busy{role="scan"}' 0 81mv R/debuginfod-rpms/rhel7renamed R/debuginfod-rpms/rhel7renamed2 82kill -USR1 $PID1 # scan cycle 83wait_ready $PORT1 'thread_work_total{role="traverse"}' 4 84wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 85wait_ready $PORT1 'thread_busy{role="scan"}' 0 86mv R/debuginfod-rpms/rhel7renamed2 R/debuginfod-rpms/rhel7renamed3 87kill -USR1 $PID1 # scan cycle 88wait_ready $PORT1 'thread_work_total{role="traverse"}' 5 89wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 90wait_ready $PORT1 'thread_busy{role="scan"}' 0 91 92export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1 93 94# retest rhel7 95archive_test bc1febfd03ca05e030f0d205f7659db29f8a4b30 /usr/src/debug/hello-1.0/hello.c $SHA 96archive_test f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2 /usr/src/debug/hello-1.0/hello.c $SHA 97 98grep -E '(libc.error.*rhel7)|(bc1febfd03ca)|(f0aa15b8aba)' vlog$PORT1 99 100kill $PID1 101wait $PID1 102PID1=0 103exit 0; 104