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 25mkdir F 26 27DB=${PWD}/.debuginfod_tmp.sqlite 28tempfiles $DB 29 30export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache 31# This variable is essential and ensures no time-race for claiming ports occurs 32# set base to a unique multiple of 100 not used in any other 'run-debuginfod-*' test 33base=9400 34get_ports 35env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod \ 36 $VERBOSE -F -p $PORT1 -t0 -g0 -d ${DB} F > vlog$PORT1 2>&1 & 37PID1=$! 38tempfiles vlog$PORT1 39errfiles vlog$PORT1 40 41# Wait till the server is ready and an initial scan has been done 42wait_ready $PORT1 'ready' 1 43wait_ready $PORT1 'thread_work_total{role="traverse"}' 1 44 45# Compile a simple program, strip its debuginfo and save the build-id. 46# Also move the debuginfo into another directory so that elfutils 47# cannot find it without debuginfod. 48echo "int main() { return 0; }" > ${PWD}/prog.c 49tempfiles prog.c 50# Create a subdirectory to confound source path names 51mkdir foobar 52gcc -Wl,--build-id -g -o prog ${PWD}/foobar///./../prog.c 53testrun ${abs_top_builddir}/src/strip -g -f prog.debug ${PWD}/prog 54 55mv prog F 56mv prog.debug F 57tempfiles F/prog.debug F/prog 58 59kill -USR1 $PID1 60# Wait till both files are 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 64cp ${DB} ${DB}.backup 65tempfiles ${DB}.backup 66 67kill $PID1 68wait $PID1 69PID1=0 70 71####################################################################### 72## PR27711 73# Test to ensure that the --include="^$" --exclude=".*" options remove all files from a database backup 74# 75env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod \ 76 $VERBOSE -p $PORT2 -t0 -g0 --regex-groom --include="^$" --exclude=".*" -d ${DB}.backup > vlog$PORT2 2>&1 & 77 78#reuse PID1 79PID1=$! 80tempfiles vlog$PORT2 81errfiles vlog$PORT2 82# Server must become ready 83wait_ready $PORT2 'ready' 1 84 85# Wait till the initial groom cycle has been done 86wait_ready $PORT2 'thread_work_total{role="groom"}' 1 87wait_ready $PORT2 'groom{statistic="archive d/e"}' 0 88wait_ready $PORT2 'groom{statistic="archive sdef"}' 0 89wait_ready $PORT2 'groom{statistic="archive sref"}' 0 90wait_ready $PORT2 'groom{statistic="buildids"}' 0 91wait_ready $PORT2 'groom{statistic="file d/e"}' 0 92wait_ready $PORT2 'groom{statistic="file s"}' 0 93wait_ready $PORT2 'groom{statistic="files scanned (#)"}' 0 94wait_ready $PORT2 'groom{statistic="files scanned (mb)"}' 0 95 96kill $PID1 97wait $PID1 98PID1=0 99 100exit 0; 101 102