From: Frantisek Sumsal Date: Fri, 30 Apr 2021 11:26:54 +0000 (+0200) Subject: test: fix a yet another pipefail + pipe race X-Git-Tag: v249-rc1~313 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d49b881eafe25c2efd2816d1ad6164c43e5896fa;p=thirdparty%2Fsystemd.git test: fix a yet another pipefail + pipe race Basically the same scenario as in a33e2692e162671f0d97856ad2f49a2620a1ec10, where `awk` exits as soon as it finds a match, thus sending SIGPIPE to `ldd` if it's not fast enough. That, in combination with `set -o pipefail` causes random & unexpected fails, like: ``` No journal files were found. -rw-r----- 1 root root 16777216 Apr 30 10:31 /var/tmp/TEST-01-BASIC_sanitizers-nspawn/system.journal TEST-01-BASIC RUN: Basic systemd setup [OK] systemd is not linked against the ASan DSO gcc does this by default, for clang compile with -shared-libasan make: *** [Makefile:2: clean-again] Error 1 make: Leaving directory '/build/test/TEST-01-BASIC' ``` --- diff --git a/test/test-functions b/test/test-functions index 8bae7a9911e..da1e20f4928 100644 --- a/test/test-functions +++ b/test/test-functions @@ -227,10 +227,10 @@ if [[ "$IS_BUILT_WITH_ASAN" = "yes" ]]; then QEMU_SMP="${QEMU_SMP:-4}" # We need to correctly distinguish between gcc's and clang's ASan DSOs. - if ASAN_RT_NAME="$(ldd "$SYSTEMD" | awk '/libasan.so/ {x=$1; exit} END {print x; exit x==""}')"; then + if ASAN_RT_NAME="$(awk '/libasan.so/ {x=$1; exit} END {print x; exit x==""}' < <(ldd "$SYSTEMD"))"; then ASAN_COMPILER=gcc ASAN_RT_PATH="$(readlink -f "$(${CC:-gcc} --print-file-name "$ASAN_RT_NAME")")" - elif ASAN_RT_NAME="$(ldd "$SYSTEMD" | awk '/libclang_rt.asan/ {x=$1; exit} END {print x; exit x==""}')"; then + elif ASAN_RT_NAME="$(awk '/libclang_rt.asan/ {x=$1; exit} END {print x; exit x==""}' < <(ldd "$SYSTEMD"))"; then ASAN_COMPILER=clang ASAN_RT_PATH="$(readlink -f "$(${CC:-clang} --print-file-name "$ASAN_RT_NAME")")"