1da0c48c4Sopenharmony_ci#!/usr/bin/env bash 2da0c48c4Sopenharmony_ci# 3da0c48c4Sopenharmony_ci# Copyright (C) 2019-2021 Red Hat, Inc. 4da0c48c4Sopenharmony_ci# This file is part of elfutils. 5da0c48c4Sopenharmony_ci# 6da0c48c4Sopenharmony_ci# This file is free software; you can redistribute it and/or modify 7da0c48c4Sopenharmony_ci# it under the terms of the GNU General Public License as published by 8da0c48c4Sopenharmony_ci# the Free Software Foundation; either version 3 of the License, or 9da0c48c4Sopenharmony_ci# (at your option) any later version. 10da0c48c4Sopenharmony_ci# 11da0c48c4Sopenharmony_ci# elfutils is distributed in the hope that it will be useful, but 12da0c48c4Sopenharmony_ci# WITHOUT ANY WARRANTY; without even the implied warranty of 13da0c48c4Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14da0c48c4Sopenharmony_ci# GNU General Public License for more details. 15da0c48c4Sopenharmony_ci# 16da0c48c4Sopenharmony_ci# You should have received a copy of the GNU General Public License 17da0c48c4Sopenharmony_ci# along with this program. If not, see <http://www.gnu.org/licenses/>. 18da0c48c4Sopenharmony_ci 19da0c48c4Sopenharmony_ci. $srcdir/debuginfod-subr.sh 20da0c48c4Sopenharmony_ci 21da0c48c4Sopenharmony_ci# for test case debugging, uncomment: 22da0c48c4Sopenharmony_ciset -x 23da0c48c4Sopenharmony_ciunset VALGRIND_CMD 24da0c48c4Sopenharmony_ciDB=${PWD}/.debuginfod_tmp.sqlite 25da0c48c4Sopenharmony_citempfiles $DB 26da0c48c4Sopenharmony_ciexport DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache 27da0c48c4Sopenharmony_ci# This variable is essential and ensures no time-race for claiming ports occurs 28da0c48c4Sopenharmony_ci# set base to a unique multiple of 100 not used in any other 'run-debuginfod-*' test 29da0c48c4Sopenharmony_cibase=8000 30da0c48c4Sopenharmony_ciget_ports 31da0c48c4Sopenharmony_cienv LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -p $PORT1 -d $DB \ 32da0c48c4Sopenharmony_ci -t0 -g0 -v ${PWD} > vlog$PORT1 2>&1 & 33da0c48c4Sopenharmony_ciPID1=$! 34da0c48c4Sopenharmony_citempfiles vlog$PORT1 35da0c48c4Sopenharmony_cierrfiles vlog$PORT1 36da0c48c4Sopenharmony_ci# Server must become ready 37da0c48c4Sopenharmony_ciwait_ready $PORT1 'ready' 1 38da0c48c4Sopenharmony_ciexport DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/ # or without trailing / 39da0c48c4Sopenharmony_ci 40da0c48c4Sopenharmony_ci# Check thread comm names 41da0c48c4Sopenharmony_cips -q $PID1 -e -L -o '%p %c %a' | grep groom 42da0c48c4Sopenharmony_cips -q $PID1 -e -L -o '%p %c %a' | grep scan 43da0c48c4Sopenharmony_cips -q $PID1 -e -L -o '%p %c %a' | grep traverse 44da0c48c4Sopenharmony_ci 45da0c48c4Sopenharmony_ci######################################################################## 46da0c48c4Sopenharmony_ci# PR25628 47da0c48c4Sopenharmony_cirm -rf $DEBUGINFOD_CACHE_PATH # clean it from previous tests 48da0c48c4Sopenharmony_ci 49da0c48c4Sopenharmony_ci# The query is designed to fail, while the empty file should be created. 50da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo 01234567 || true 51da0c48c4Sopenharmony_ciif [ ! -f $DEBUGINFOD_CACHE_PATH/01234567/debuginfo ]; then 52da0c48c4Sopenharmony_ci echo "could not find cache in $DEBUGINFOD_CACHE_PATH" 53da0c48c4Sopenharmony_ci err 54da0c48c4Sopenharmony_cifi 55da0c48c4Sopenharmony_ci 56da0c48c4Sopenharmony_ciif [ `stat -c "%s" $DEBUGINFOD_CACHE_PATH/01234567/debuginfo` != 0 ]; then 57da0c48c4Sopenharmony_ci echo "The cache $DEBUGINFOD_CACHE_PATH/01234567/debuginfo is not empty" 58da0c48c4Sopenharmony_ci err 59da0c48c4Sopenharmony_cifi 60da0c48c4Sopenharmony_ci 61da0c48c4Sopenharmony_cibytecount_before=`curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_count{code="404",type="debuginfo"}'` 62da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo 01234567 || true 63da0c48c4Sopenharmony_cibytecount_after=`curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_count{code="404",type="debuginfo"}'` 64da0c48c4Sopenharmony_ciif [ "$bytecount_before" != "$bytecount_after" ]; then 65da0c48c4Sopenharmony_ci echo "http_responses_transfer_bytes_count{code="404",type="debuginfo"} has changed." 66da0c48c4Sopenharmony_ci err 67da0c48c4Sopenharmony_cifi 68da0c48c4Sopenharmony_ci 69da0c48c4Sopenharmony_ci# set cache_miss_s to 0 and sleep 1 to make the mtime expire. 70da0c48c4Sopenharmony_ciecho 0 > $DEBUGINFOD_CACHE_PATH/cache_miss_s 71da0c48c4Sopenharmony_cisleep 1 72da0c48c4Sopenharmony_cibytecount_before=`curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_count{code="404",type="debuginfo"}'` 73da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo 01234567 || true 74da0c48c4Sopenharmony_cibytecount_after=`curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_count{code="404",type="debuginfo"}'` 75da0c48c4Sopenharmony_ciif [ "$bytecount_before" == "$bytecount_after" ]; then 76da0c48c4Sopenharmony_ci echo "http_responses_transfer_bytes_count{code="404",type="debuginfo"} should be incremented." 77da0c48c4Sopenharmony_ci err 78da0c48c4Sopenharmony_cifi 79da0c48c4Sopenharmony_ci 80da0c48c4Sopenharmony_cikill $PID1 81da0c48c4Sopenharmony_ciwait $PID1 82da0c48c4Sopenharmony_ciPID1=0 83da0c48c4Sopenharmony_ciexit 0 84