From c66e2f6c2cff71d046f465def6d851143d62f2af Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Tue, 3 May 2022 20:50:39 +0000 Subject: [PATCH 1/2] tests: make it possible to install valgrind --- test/test-functions | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/test-functions b/test/test-functions index 3748210527..404e2b077f 100644 --- a/test/test-functions +++ b/test/test-functions @@ -752,17 +752,17 @@ install_valgrind() { local valgrind_bins valgrind_libs valgrind_dbg_and_supp - valgrind_bins="$(strace -e execve valgrind /bin/true 2>&1 >/dev/null | perl -lne 'print $1 if /^execve\("([^"]+)"/')" - image_install "$valgrind_bins" + readarray -t valgrind_bins < <(strace -e execve valgrind /bin/true 2>&1 >/dev/null | perl -lne 'print $1 if /^execve\("([^"]+)"/') + image_install "${valgrind_bins[@]}" - valgrind_libs="$(LD_DEBUG=files valgrind /bin/true 2>&1 >/dev/null | perl -lne 'print $1 if m{calling init: (/.*vgpreload_.*)}')" - image_install "$valgrind_libs" + readarray -t valgrind_libs < <(LD_DEBUG=files valgrind /bin/true 2>&1 >/dev/null | perl -lne 'print $1 if m{calling init: (/.*vgpreload_.*)}') + image_install "${valgrind_libs[@]}" - valgrind_dbg_and_supp="$( + readarray -t valgrind_dbg_and_supp < <( strace -e open valgrind /bin/true 2>&1 >/dev/null | perl -lne 'if (my ($fname) = /^open\("([^"]+).*= (?!-)\d+/) { print $fname if $fname =~ /debug|\.supp$/ }' - )" - image_install "$valgrind_dbg_and_supp" + ) + image_install "${valgrind_dbg_and_supp[@]}" } create_valgrind_wrapper() { From 8e78dca982e37c7714e78f775bf2d3128172df1e Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Tue, 3 May 2022 20:51:56 +0000 Subject: [PATCH 2/2] tests: make valgrind_wrapper track file descriptors --- test/test-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-functions b/test/test-functions index 404e2b077f..365f535bf0 100644 --- a/test/test-functions +++ b/test/test-functions @@ -772,7 +772,7 @@ create_valgrind_wrapper() { #!/usr/bin/env bash mount -t proc proc /proc -exec valgrind --leak-check=full --log-file=/valgrind.out $ROOTLIBDIR/systemd "\$@" +exec valgrind --leak-check=full --track-fds=yes --log-file=/valgrind.out $ROOTLIBDIR/systemd "\$@" EOF chmod 0755 "$valgrind_wrapper" }