Stop using grep -q in test pipelines

common.inc sets pipefail, and grep -q exits as soon as it finds a match.
If the producer still has output to write, it dies of SIGPIPE, the
pipeline fails, and a test that gates on the match silently skips or
fails. Plain grep reads its whole input, so the pipeline's status is
grep's own.
This commit is contained in:
Rui Ueyama committed 2026-09-19 23:53:23 +09:00
1 parent 60b97830ca
commit 0ab442dbc6
10 files changed
+15 -15

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ cat <<EOF | $CC -mabi=elfv2 -c -o $t/a.o -xc - 2> /dev/null || skip
int main() {}
EOF
readelf -h $t/a.o | grep -q abiv2 || skip
readelf -h $t/a.o | grep abiv2 || skip
! ./mold -m elf64ppc -o $t/exe $t/a.o 2> $t/log
grep 'unknown machine type' $t/log
+1 -1
View File
@@ -10,7 +10,7 @@
cat <<EOF | $CC -Wa,--gsframe -o $t/probe.o -c -xc - 2>/dev/null || skip
int main() { return 0; }
EOF
readelf --sframe=.sframe $t/probe.o 2>/dev/null | grep -q SFRAME_VERSION_3 || skip
readelf --sframe=.sframe $t/probe.o 2>/dev/null | grep SFRAME_VERSION_3 || skip
# Skip unless libsframe and its header are available.
echo 'int main(){return 0;}' | \
+1 -1
View File
@@ -12,7 +12,7 @@
# objcopy afterwards.
echo | $CC -c -o $t/a.o -xc -
if readelf -h $t/a.o | grep -q ELF64; then
if readelf -h $t/a.o | grep ELF64; then
reloc=BFD_RELOC_64
else
reloc=BFD_RELOC_32
+1 -1
View File
@@ -31,4 +31,4 @@ not grep -q "removing identical section.*caller_local" $t/out
not grep -q "removing identical section.*caller_global" $t/out
# Also check with nm to be sure they have different addresses
nm $t/libtest.so | grep -E 'caller_local|caller_global' | awk '{print $1}' | uniq | wc -l | grep -q 2
nm $t/libtest.so | grep -E 'caller_local|caller_global' | awk '{print $1}' | uniq | wc -l | grep 2
+2 -2
View File
@@ -18,7 +18,7 @@ echo 'int foo() { return 0; }' |
# __divti3 call. Some lower it inline (e.g. POWER10), and 32-bit targets
# don't support __int128 at all.
echo 'volatile long long x, y; __int128 f() { return (__int128)x / y; }' |
$GXX -O2 -S -o - -xc++ - 2> /dev/null | grep -q __divti3 || skip
$GXX -O2 -S -o - -xc++ - 2> /dev/null | grep __divti3 || skip
# GCC emits the function-local static of an inline function as an
# STB_GNU_UNIQUE symbol in a COMDAT group. The non-weak binding is what turns
@@ -44,7 +44,7 @@ extern "C" __int128 __divti3(__int128 a, __int128 b) {
}
EOF
readelf -sW $t/a.o | grep -q 'UNIQUE.*_ZZ4bumpvE3cnt' || skip
readelf -sW $t/a.o | grep 'UNIQUE.*_ZZ4bumpvE3cnt' || skip
ar rcs $t/libutil.a $t/a.o
+2 -2
View File
@@ -16,7 +16,7 @@ seq 1 70000 | sed 's/.*/.section .padding.&,""/' > $t/padding.s
$GCC -S -flto -fno-fat-lto-objects -o $t/a.s $t/a.c
cat $t/padding.s >> $t/a.s
$GCC -c -o $t/a.o $t/a.s
readelf -h $t/a.o | grep -q 'Number of section headers: *0 '
readelf -h $t/a.o | grep 'Number of section headers: *0 '
$GCC -B. -o $t/exe1 -flto $t/a.o
$QEMU $t/exe1
@@ -26,7 +26,7 @@ $QEMU $t/exe1
$GCC -S -flto -ffat-lto-objects -o $t/b.s $t/a.c
cat $t/padding.s >> $t/b.s
$GCC -c -o $t/b.o $t/b.s
readelf -h $t/b.o | grep -q 'Number of section headers: *0 '
readelf -h $t/b.o | grep 'Number of section headers: *0 '
$GCC -B. -o $t/exe2 $t/b.o --verbose |& grep -- -fwpa
$QEMU $t/exe2
+1 -1
View File
@@ -19,4 +19,4 @@ not $CC -B. -o $t/exe3 $t/a.o -Wl,--package-metadata='foo%x' |&
# The string is arbitrary bytes and need not be UTF-8.
$CC -B. -o $t/exe4 $t/a.o -Wl,--package-metadata='%FF%41{}'
readelf -x .note.package $t/exe4 | grep -q ff417b7d
readelf -x .note.package $t/exe4 | grep ff417b7d
+1 -1
View File
@@ -10,7 +10,7 @@ cat <<EOF | $CC -c -g3 -o $t/a.o -xc -
int main() { return FOO; }
EOF
readelf --section-groups $t/a.o | grep -q debug_macro || skip
readelf --section-groups $t/a.o | grep debug_macro || skip
./mold -r --strip-debug -o $t/b.o $t/a.o
readelf --section-groups $t/b.o > $t/log
+3 -3
View File
@@ -10,7 +10,7 @@
cat <<EOF | $CC -Wa,--gsframe -o $t/probe.o -c -xc - 2>/dev/null || skip
int main() { return 0; }
EOF
readelf --sframe=.sframe $t/probe.o 2>/dev/null | grep -q SFRAME_VERSION_3 || skip
readelf --sframe=.sframe $t/probe.o 2>/dev/null | grep SFRAME_VERSION_3 || skip
# Compile two translation units, each with several functions, so that the
# linker has to merge and sort more than one .sframe section.
@@ -35,7 +35,7 @@ grep -q SFRAME_VERSION_3 $t/log
grep -q SFRAME_F_FDE_SORTED $t/log
# A PT_GNU_SFRAME segment must point at the section.
readelf -Wl $t/exe | grep -q GNU_SFRAME
readelf -Wl $t/exe | grep GNU_SFRAME
# Verify that the FDEs really are sorted by function address.
prev=0
@@ -81,7 +81,7 @@ $QEMU $t/comdat
readelf --sframe=.sframe $t/r.o > $t/rlog
grep -q SFRAME_VERSION_3 $t/rlog
[ "$(readelf -SW $t/r.o | grep -cw GNU_SFRAME)" = 1 ]
readelf -SW $t/r.o | grep -q '\.rela\.sframe'
readelf -SW $t/r.o | grep '\.rela\.sframe'
# The relocatable object must link into a working executable that still
# describes every function from the original inputs.
+2 -2
View File
@@ -13,8 +13,8 @@ $CC -o $t/a.o -c -g -gdwarf64 $t/a.c || skip
seq 0 499 | sed 's/.*/void dwarf32_fn_&() {}/' > $t/b.c
$CC -o $t/b.o -c -g -gdwarf32 $t/b.c
readelf -p .debug_str $t/a.o | grep -q dwarf64_fn_0 || skip
readelf -p .debug_str $t/b.o | grep -q dwarf32_fn_0 || skip
readelf -p .debug_str $t/a.o | grep dwarf64_fn_0 || skip
readelf -p .debug_str $t/b.o | grep dwarf32_fn_0 || skip
echo 'int main() {}' | $CC -o $t/c.o -c -xc - -g