• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  # includes set -e
20# for test case debugging, uncomment:
21set -x
22unset VALGRIND_CMD
23# This variable is essential and ensures no time-race for claiming ports occurs
24# set base to a unique multiple of 100 not used in any other 'run-debuginfod-*' test
25base=10000
26get_ports
27DB=${PWD}/.debuginfod_tmp.sqlite
28tempfiles $DB
29mkdir F
30env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE \
31    -F -R -d $DB -p $PORT1 -t0 -g0 -v R ${PWD}/F > vlog$PORT1 2>&1 &
32PID1=$!
33tempfiles vlog$PORT1
34errfiles vlog$PORT1
35# Server must become ready
36wait_ready $PORT1 'ready' 1
37# And initial scan should be done
38wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
39
40# Build a non-stripped binary
41echo "int main() { return 0; }" > ${PWD}/F/p++r\$\#o^^g.c
42gcc -Wl,--build-id -g -o ${PWD}/F/p++r\$\#o^^g ${PWD}/F/p++r\$\#o^^g.c
43BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
44          -a ${PWD}/F/p++r\\$\#o^^g | grep 'Build ID' | cut -d ' ' -f 7`
45tempfiles ${PWD}/F/p++r\$\#o^^g.c ${PWD}/F/p++r\$\#o^^g
46kill -USR1 $PID1
47# Now there should be 1 files in the index
48wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
49wait_ready $PORT1 'thread_work_pending{role="scan"}' 0
50wait_ready $PORT1 'thread_busy{role="scan"}' 0
51rm -rf $DEBUGINFOD_CACHE_PATH # clean it from previous tests
52ls F
53env DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache DEBUGINFOD_URLS="http://127.0.0.1:$PORT1" \
54    LD_LIBRARY_PATH=$ldpath ${abs_top_builddir}/debuginfod/debuginfod-find -vvv source F/p++r\$\#o^^g ${abs_builddir}/F/p++r\$\#o^^g.c > vlog1 2>&1 || true
55tempfiles vlog1
56grep 'F/p%2B%2Br%24%23o%5E%5Eg.c' vlog1
57
58kill $PID1
59wait $PID1
60PID1=0
61exit 0
62