[Bug general/29180] New: run-debuginfod-fd-prefetch-caches.sh seems to fail on Ubuntu Focal when elfutils is built with --enable-gcov

2022-05-25 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29180

Bug ID: 29180
   Summary: run-debuginfod-fd-prefetch-caches.sh seems to fail on
Ubuntu Focal when elfutils is built with --enable-gcov
   Product: elfutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: general
  Assignee: unassigned at sourceware dot org
  Reporter: evvers at ya dot ru
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

As far as I understand the most relevant part is
```
2022-05-25T01:03:03.3909087Z traversed_total{type="directory"} 10
2022-05-25T01:03:03.3909315Z traversed_total{type="file"} 32
2022-05-25T01:03:03.3909744Z traversed_total{type="other"} 10 =~
fdcache_prefetch_count ([0-9])+ ]]
2022-05-25T01:03:03.3910032Z + [[ 1 -ne 0 ]]
2022-05-25T01:03:03.3910197Z + err
2022-05-25T01:03:03.3910419Z + trap - ERR
2022-05-25T01:03:03.3910612Z + echo ERROR REPORTS
2022-05-25T01:03:03.3910799Z ERROR REPORTS
```

The full log can be found at
https://gist.github.com/evverx/362aa02f6ec8414d5a4f5bce59fbcd47

Since the test seems to pass on Ubuntu Jammy and Fedora Rawhide I "fixed" it by
skipping the test in https://github.com/evverx/elfutils/pull/85 and not
including it in the coverage report built on Ubuntu Focal.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug debuginfod/28577] Make run-...-fd-prefetch-caches.sh test something

2022-05-25 Thread Noah Sanci via Elfutils-devel
PR28577: Make run-debuginfod-fd-prefetch-caches.sh test
 something

Update to the run-debuginfod-fd-prefetch to make the test more sound.
From b84dd9b2b36812ea299ff189c7e5557863dd82d2 Mon Sep 17 00:00:00 2001
From: Noah Sanci 
Date: Fri, 13 May 2022 14:32:27 -0400
Subject: [PATCH] PR28577: Make run-debuginfod-fd-prefetch-caches.sh test 
  something

Update to the run-debuginfod-fd-prefetch to make the test more
sound.
---
 tests/run-debuginfod-fd-prefetch-caches.sh | 116 +
 1 file changed, 48 insertions(+), 68 deletions(-)

diff --git a/tests/run-debuginfod-fd-prefetch-caches.sh b/tests/run-debuginfod-fd-prefetch-caches.sh
index 66a7a083..50ffc4ac 100755
--- a/tests/run-debuginfod-fd-prefetch-caches.sh
+++ b/tests/run-debuginfod-fd-prefetch-caches.sh
@@ -21,22 +21,22 @@
 # for test case debugging, uncomment:
 set -x
 unset VALGRIND_CMD
+mkdir R Z
 
-mkdir R
-cp -rvp ${abs_srcdir}/debuginfod-rpms R
-if [ "$zstd" = "false" ]; then  # nuke the zstd fedora 31 ones
-rm -vrf R/debuginfod-rpms/fedora31
-fi
-
-FDCACHE_MBS=$((1/1024/1024))
+FDCACHE_MBS=1
 FDCACHE_FDS=1
-PREFETCH_MBS=$((1/1024/1024))
-PREFETCH_FDS=2
+PREFETCH_MBS=1
+PREFETCH_FDS=1
 PREFETCH=1
 # This variable is essential and ensures no time-race for claiming ports occurs
 # set base to a unique multiple of 100 not used in any other 'run-debuginfod-*' test
 base=8800
 get_ports
+cp -rvp ${abs_srcdir}/debuginfod-rpms R
+if [ "$zstd" = "false" ]; then  # nuke the zstd fedora 31 ones
+rm -vrf R/debuginfod-rpms/fedora31
+fi
+cp -rvp ${abs_srcdir}/debuginfod-tars Z
 
 DB=${PWD}/.debuginfod_tmp.sqlite
 tempfiles $DB
@@ -47,88 +47,68 @@ export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache
 ##
 rm -rf $DEBUGINFOD_CACHE_PATH
 rm -rf $DB
+
 # Set mb values to ensure the caches certainly have enough space
 # To store the test files
 env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -p $PORT1 -d $DB \
---fdcache-fds=$FDCACHE_FDS --fdcache-prefetch-fds=$PREFETCH_FDS --fdcache-mintmp 0 -v -g 0 -t 0 -R R \
---fdcache-mbs=50  --fdcache-prefetch-mbs=50 \
---fdcache-prefetch=$PREFETCH  > vlog$PORT1 2>&1 &
+--fdcache-fds=$FDCACHE_FDS --fdcache-prefetch-fds=$PREFETCH_FDS  -v -g 0 -t 0 -R R \
+-Z .tar.bz2=bzcat Z  --fdcache-mbs=50  --fdcache-prefetch-mbs=100 \
+--fdcache-prefetch=$PREFETCH -F > vlog$PORT1 2>&1 &
 PID1=$!
 tempfiles vlog$PORT1
 errfiles vlog$PORT1
+
 # Server must become ready
 wait_ready $PORT1 'ready' 1
 
-cp -rvp ${abs_srcdir}/debuginfod-rpms R
-if [ "$zstd" = "false" ]; then  # nuke the zstd fedora 31 ones
-rm -vrf R/debuginfod-rpms/fedora31
-fi
 kill -USR1 $PID1
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
+wait_ready $PORT1 'thread_work_pending{role="scan"}' 0
+wait_ready $PORT1 'thread_busy{role="scan"}' 0
 # All rpms need to be in the index, except the dummy permission-000 one
 rpms=$(find R -name \*rpm | grep -v nothing | wc -l)
 wait_ready $PORT1 'scanned_files_total{source=".rpm archive"}' $rpms
-kill -USR1 $PID1  # two hits of SIGUSR1 may be needed to resolve .debug->dwz->srefs
-# Wait till both files are in the index and scan/index fully finished
+kill -USR1 $PID1 
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
-export DEBUGINFOD_URLS="http://127.0.0.1:"$PORT1
+wait_ready $PORT1 'thread_work_pending{role="scan"}' 0
+wait_ready $PORT1 'thread_busy{role="scan"}' 0
 
-archive_hits=5
-SHA=f4a1a8062be998ae93b8f1cd744a398c6de6dbb1
-for i in $archive_hits
-do
-  archive_test c36708a78618d597dee15d0dc989f093ca5f9120 /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA
-done
+export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/
+# load prefetch cache
+testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo cee13b2ea505a7f37bd20d271c6bc7e5f8d2dfcb
 metrics=$(curl http://127.0.0.1:$PORT1/metrics)
-regex="fdcache_op_count\{op=\"enqueue\"\} ([0-9]+).*fdcache_op_count\{op=\"evict\"\} ([0-9]+).*"
-enqueue=0
-if [[ $metrics =~ $regex ]]
-then
-   enqueue=${BASH_REMATCH[1]}
-   evict=${BASH_REMATCH[2]}
+regex="fdcache_prefetch_count ([0-9])+"
+# Check to see if prefetch cache is loaded
+if [[ $metrics =~ $regex ]]; then
+  if [[  ${BASH_REMATCH[1]} -ne 1 ]]; then
+err
+  fi
 else
-   err
-fi
-# This is an ad-hoc test than only works when FDCACHE_FDS < "archive_test"s above (5)
-# otherwise there will be no eviction
-if [[ $(( $enqueue-$FDCACHE_FDS )) -ne $evict ]]
-then
-   err
-fi
-# Test prefetch cache
-archive_test bc1febfd03ca05e030f0d205f7659db29f8a4b30 /usr/src/debug/hello-1.0/hello.c $SHA
+  err
+fi 
+# Ensure that searching for the source prefetched finds it in the prefetch cache
+testrun ${abs_top_builddir}/debuginfod/debuginfod-find source cee13b2ea505a7f37bd20d271c6bc7e5f8d2dfcb /usr/src/debug/hello.c
 metrics=$(curl http://127.0.0.1:$PORT1/metrics)
-regex="fdcache_prefetch_count ([0-9])+"
-pf_count=0
-for i in $FDCACHE_FDS
-do
-