]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests: Don't fail run-debuginfod-fd-prefetch-caches.sh if grep -c fails
authorMark Wielaard <mark@klomp.org>
Thu, 9 Sep 2021 19:51:51 +0000 (21:51 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 9 Sep 2021 20:53:05 +0000 (22:53 +0200)
The set -o errtrace made run-debuginfod-fd-prefetch-caches.sh
fail. On some systems. Add set -o functrace to make it fail consistently.

The failure is because the grep -c for in the log file fails (it
returns zero). Fix this by using || true. But this is only a
workaround. It makes the test pass, but only because all values are
always zero. The test doesn't currently test anything.

Also make sure that err and cleanup are only executed once.

Signed-off-by: Mark Wielaard <mark@klomp.org>
tests/ChangeLog
tests/debuginfod-subr.sh
tests/run-debuginfod-fd-prefetch-caches.sh

index 05b31fd8d2359e691f27c6ac45e3596cb04f66b6..caee93d394afe3475f7344290f73ec62f065c239 100644 (file)
@@ -1,3 +1,10 @@
+2021-09-09  Mark Wielaard  <mark@klomp.org>
+
+       * debuginfod-subr.sh: set -o functrace.
+       (cleanup): Disable trap 0.
+       (err): Disable trap ERR.
+       * run-debuginfod-fd-prefetch-caches.sh: Use || true when grep -c fails.
+
 2021-09-09  Mark Wielaard  <mark@klomp.org>
 
        * debuginfod-subr.sh: set -o errtrace.
index c21b7b8a6ebbbe4a4a5ffb257cb321d6f08d5985..59033f35980e7386c0a031c28192f915593e02e9 100755 (executable)
@@ -17,6 +17,7 @@
 # sourced from run-debuginfod-*.sh tests (must be bash scripts)
 
 # We trap ERR and like commands that fail in function to also trap
+set -o functrace
 set -o errtrace
 
 . $srcdir/test-subr.sh  # includes set -e
@@ -30,6 +31,9 @@ echo "zstd=$zstd bsdtar=`bsdtar --version`"
 
 cleanup()
 {
+  # No more cleanups after this cleanup
+  trap - 0
+
   if [ $PID1 -ne 0 ]; then kill $PID1 || : ; wait $PID1 || :; fi
   if [ $PID2 -ne 0 ]; then kill $PID2 || : ; wait $PID2 || :; fi
   rm -rf F R D L Z ${PWD}/foobar ${PWD}/mocktree ${PWD}/.client_cache* ${PWD}/tmp*
@@ -41,6 +45,9 @@ trap cleanup 0
 
 errfiles_list=
 err() {
+    # Don't trap any new errors from now on
+    trap - ERR
+
     echo ERROR REPORTS
     for port in $PORT1 $PORT2
     do
index 61fee9e94aae77f10273a872217fad1f0f8f2e62..7fbf7b20a6e87f59dc50dc1f584ae7085c5a0678 100755 (executable)
@@ -51,10 +51,14 @@ grep 'prefetch fds ' vlog$PORT1 #$PREFETCH_FDS
 grep 'prefetch mbs ' vlog$PORT1 #$PREFETCH_MBS
 # search the vlog to find what metric counts should be and check the correct metrics
 # were incrimented
-wait_ready $PORT1 'fdcache_op_count{op="enqueue"}' $( grep -c 'interned.*front=1' vlog$PORT1 )
-wait_ready $PORT1 'fdcache_op_count{op="evict"}' $( grep -c 'evicted a=.*' vlog$PORT1 )
-wait_ready $PORT1 'fdcache_op_count{op="prefetch_enqueue"}' $( grep -c 'interned.*front=0' vlog$PORT1 )
-wait_ready $PORT1 'fdcache_op_count{op="prefetch_evict"}' $( grep -c 'evicted from prefetch a=.*front=0' vlog$PORT1 || true )
+enqueue_nr=$(grep -c 'interned.*front=1' vlog$PORT1 || true)
+wait_ready $PORT1 'fdcache_op_count{op="enqueue"}' $enqueue_nr
+evict_nr=$(grep -c 'evicted a=.*' vlog$PORT1 || true)
+wait_ready $PORT1 'fdcache_op_count{op="evict"}' $evict_nr
+prefetch_enqueue_nr=$(grep -c 'interned.*front=0' vlog$PORT1 || true)
+wait_ready $PORT1 'fdcache_op_count{op="prefetch_enqueue"}' $prefetch_enqueue_nr
+prefetch_evict_nr=$(grep -c 'evicted from prefetch a=.*front=0' vlog$PORT1 || true)
+wait_ready $PORT1 'fdcache_op_count{op="prefetch_evict"}' $prefetch_evict_nr
 
 kill $PID1
 wait $PID1