]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests/backtrace-subr.sh: Avoid valgrind track-fds in check_native_core
authorAaron Merey <amerey@redhat.com>
Fri, 31 Jan 2025 01:17:28 +0000 (20:17 -0500)
committerAaron Merey <amerey@redhat.com>
Fri, 7 Feb 2025 22:13:51 +0000 (17:13 -0500)
valgrind --track-fds=yes might incorrectly report an error due to the use
of inherited file descriptors in check_native_core.

Prevent this false positive by temporarily removing "--track-fds=yes" from
$VALGRIND_CMD for the duration of the testrun in check_native_core.

Signed-off-by: Aaron Merey <amerey@redhat.com>
tests/backtrace-subr.sh

index b63e38144bf506af8fd2e20c9b5ce7a29de70aca..0a5b38f888f18deefd1ddac7be6614bd6c25e6d3 100644 (file)
@@ -187,7 +187,9 @@ check_native_core()
   fi
 
   if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
-    VALGRIND_CMD="$SAVED_VALGRIND_CMD"
+    # Restore $VALGRIND_CMD but disable --track-fds for the following testrun.
+    # Valgrind --track-fds might complain about an inherited fd.
+    VALGRIND_CMD=$(sed 's/--track-fds=yes//g' <<< "$SAVED_VALGRIND_CMD")
     export VALGRIND_CMD
   fi
 
@@ -195,6 +197,12 @@ check_native_core()
   # - see function check_err.
   tempfiles $core{,.{bt,err}}
   (set +ex; testrun ${abs_builddir}/backtrace -e ${abs_builddir}/$child --core=$core 1>$core.bt 2>$core.err; true)
+
+  if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
+    VALGRIND_CMD="$SAVED_VALGRIND_CMD"
+    export VALGRIND_CMD
+  fi
+
   cat $core.{bt,err}
   check_native_unsupported $core.err $child-$core
   check_all $core.{bt,err} $child-$core