From 0619541234f2300dfe368aa15cd593618390de44 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 8 Feb 2025 18:30:33 +0900 Subject: [PATCH] Simplify --- test/arch-arm-range-extension-thunk.sh | 3 +-- test/arch-arm-tlsdesc.sh | 3 +-- test/arch-x86_64-gnu-linkonce.sh | 2 +- test/arch-x86_64-incompatible-libs.sh | 3 +-- test/arch-x86_64-incompatible-libs2.sh | 8 +++----- test/arch-x86_64-incompatible-obj.sh | 3 +-- test/arch-x86_64-note-property2.sh | 2 +- test/common.inc | 2 +- test/defsym2.sh | 2 +- test/demangle.sh | 8 ++++---- test/dynamic.sh | 2 +- test/glibc-2.22-bug.sh | 2 +- test/lto-gcc.sh | 3 +-- test/lto-llvm.sh | 3 +-- test/many-sections.sh | 2 +- test/nocopyreloc.sh | 2 +- test/relocatable-many-sections.sh | 2 +- test/run.sh | 4 ++-- test/section-align.sh | 2 +- test/shuffle-sections-seed.sh | 2 +- test/shuffle-sections.sh | 2 +- test/unresolved-symbols.sh | 6 +++--- test/warn-unresolved-symbols.sh | 2 +- test/z-defs.sh | 6 +++--- 24 files changed, 34 insertions(+), 42 deletions(-) diff --git a/test/arch-arm-range-extension-thunk.sh b/test/arch-arm-range-extension-thunk.sh index 191b1c51fc..80689976c3 100755 --- a/test/arch-arm-range-extension-thunk.sh +++ b/test/arch-arm-range-extension-thunk.sh @@ -1,8 +1,7 @@ #!/bin/bash . $(dirname $0)/common.inc -echo 'int main() {}' | $CC -c -o /dev/null -xc - -O0 -mthumb >& /dev/null \ - || skip +echo 'int main() {}' | $CC -c -o /dev/null -xc - -O0 -mthumb >& /dev/null || skip cat < $t/a.c #include diff --git a/test/arch-arm-tlsdesc.sh b/test/arch-arm-tlsdesc.sh index f737f18666..6f0ffc2bf3 100755 --- a/test/arch-arm-tlsdesc.sh +++ b/test/arch-arm-tlsdesc.sh @@ -3,8 +3,7 @@ is_musl && skip -echo 'int main() {}' | $GCC -c -o /dev/null -xc - -O0 -mthumb >& /dev/null \ - || skip +echo 'int main() {}' | $GCC -c -o /dev/null -xc - -O0 -mthumb >& /dev/null || skip cat < $t/a.c extern _Thread_local int foo; diff --git a/test/arch-x86_64-gnu-linkonce.sh b/test/arch-x86_64-gnu-linkonce.sh index c27e2993d3..5bcf196a5c 100755 --- a/test/arch-x86_64-gnu-linkonce.sh +++ b/test/arch-x86_64-gnu-linkonce.sh @@ -21,5 +21,5 @@ EOF $CC -B. -o $t/exe $t/a.o $t/b.o $t/c.o $OBJDUMP -d $t/exe >& /dev/null || skip -$OBJDUMP -d $t/exe | grep -A1 '<__x86.get_pc_thunk.bx>:' | \ +$OBJDUMP -d $t/exe | grep -A1 '<__x86.get_pc_thunk.bx>:' | grep -Fq 'puts$plt' diff --git a/test/arch-x86_64-incompatible-libs.sh b/test/arch-x86_64-incompatible-libs.sh index 3661d82bd7..07944a726b 100755 --- a/test/arch-x86_64-incompatible-libs.sh +++ b/test/arch-x86_64-incompatible-libs.sh @@ -1,8 +1,7 @@ #!/bin/bash . $(dirname $0)/common.inc -echo 'int main() {}' | $CC -m32 -o $t/exe -xc - >& /dev/null \ - || skip +echo 'int main() {}' | $CC -m32 -o $t/exe -xc - >& /dev/null || skip cat <& /dev/null \ - || skip +echo 'int main() {}' | $CC -m32 -o $t/exe -xc - >& /dev/null || skip cat < $t/script/libfoo.so -$CC -B. -o $t/exe -L$t/lib32 -L$t/lib64 -lfoo $t/e.o -Wl,-rpath $t/lib64 \ - >& $t/log +$CC -B. -o $t/exe -L$t/lib32 -L$t/lib64 -lfoo $t/e.o -Wl,-rpath $t/lib64 |& + grep -q 'lib32/libfoo.so: skipping incompatible file' -grep -q 'lib32/libfoo.so: skipping incompatible file' $t/log $QEMU $t/exe | grep -q 'Hello world' diff --git a/test/arch-x86_64-incompatible-obj.sh b/test/arch-x86_64-incompatible-obj.sh index 54ab978cc6..5c2aeb59b7 100755 --- a/test/arch-x86_64-incompatible-obj.sh +++ b/test/arch-x86_64-incompatible-obj.sh @@ -1,8 +1,7 @@ #!/bin/bash . $(dirname $0)/common.inc -echo 'int main() {}' | $CC -m32 -o $t/exe -xc - >& /dev/null \ - || skip +echo 'int main() {}' | $CC -m32 -o $t/exe -xc - >& /dev/null || skip cat < /dev/null || \ + $CC -shared -fPIC -xc -o $t/tlsdesc.so $tlsdesc_opt - 2> /dev/null || return 1 echo 'int y(); int main() { y(); }' | $CC -xc -c -o $t/tlsdesc.o - $CC -o $t/tlsdesc $t/tlsdesc.o $t/tlsdesc.so diff --git a/test/defsym2.sh b/test/defsym2.sh index b768c2be9e..ee98e07aac 100755 --- a/test/defsym2.sh +++ b/test/defsym2.sh @@ -6,4 +6,4 @@ void foo() {} EOF $CC -B. -o $t/b.so -shared -Wl,-defsym=bar=foo $t/a.o -nm -D $t/b.so | grep -q 'bar' || false +nm -D $t/b.so | grep -q 'bar' diff --git a/test/demangle.sh b/test/demangle.sh index 59e552dfa0..a377ec6b1b 100755 --- a/test/demangle.sh +++ b/test/demangle.sh @@ -8,13 +8,13 @@ int main() { } EOF -not $CC -B. -o $t/exe $t/a.o -Wl,-no-demangle |& \ +not $CC -B. -o $t/exe $t/a.o -Wl,-no-demangle |& grep -q 'undefined symbol: _Z3fooii$' -not $CC -B. -o $t/exe $t/a.o -Wl,-demangle |& \ +not $CC -B. -o $t/exe $t/a.o -Wl,-demangle |& grep -Eq 'undefined symbol: foo\(int, int\)$' -not $CC -B. -o $t/exe $t/a.o |& \ +not $CC -B. -o $t/exe $t/a.o |& grep -Eq 'undefined symbol: foo\(int, int\)$' cat <& /dev/null \ - || skip +echo 'int main() {}' | $GCC -B. -flto -o /dev/null -xc - >& /dev/null || skip cat < diff --git a/test/lto-llvm.sh b/test/lto-llvm.sh index f32c661252..beec21af24 100755 --- a/test/lto-llvm.sh +++ b/test/lto-llvm.sh @@ -3,8 +3,7 @@ [ $MACHINE = $(uname -m) ] || skip -echo 'int main() {}' | clang -B. -flto -o /dev/null -xc - >& /dev/null \ - || skip +echo 'int main() {}' | clang -B. -flto -o /dev/null -xc - >& /dev/null || skip cat < diff --git a/test/many-sections.sh b/test/many-sections.sh index b0ee2bbaaa..df0f79dabc 100755 --- a/test/many-sections.sh +++ b/test/many-sections.sh @@ -1,7 +1,7 @@ #!/bin/bash . $(dirname $0)/common.inc -seq 1 100000 | sed 's/.*/.section .data.\0,"aw"\n.word 0\n/g' | \ +seq 1 100000 | sed 's/.*/.section .data.\0,"aw"\n.word 0\n/g' | $CC -c -xassembler -o $t/a.o - cat <<'EOF' | $CC -c -xc -o $t/b.o - diff --git a/test/nocopyreloc.sh b/test/nocopyreloc.sh index 8046adb053..3745a721f5 100755 --- a/test/nocopyreloc.sh +++ b/test/nocopyreloc.sh @@ -29,5 +29,5 @@ EOF $CC -B. -no-pie -o $t/exe $t/a.so $t/b.o $QEMU $t/exe | grep -q '3 5' -not $CC -B. -o $t/exe $t/a.so $t/b.o -no-pie -Wl,-z,nocopyreloc |& \ +not $CC -B. -o $t/exe $t/a.so $t/b.o -no-pie -Wl,-z,nocopyreloc |& grep -q 'recompile with -fPIC' diff --git a/test/relocatable-many-sections.sh b/test/relocatable-many-sections.sh index 1ead16020f..3f1b89ac78 100755 --- a/test/relocatable-many-sections.sh +++ b/test/relocatable-many-sections.sh @@ -4,7 +4,7 @@ # OneTBB isn't tsan-clean nm mold | grep -q '__tsan_init' && skip -seq 1 80000 | sed 's/.*/.section .data.\0,"aw"\n.word 0\n/g' | \ +seq 1 80000 | sed 's/.*/.section .data.\0,"aw"\n.word 0\n/g' | $CC -c -xassembler -o $t/a.o - cat <<'EOF' | $CC -c -xc -o $t/b.o - diff --git a/test/run.sh b/test/run.sh index 4d106e4950..1ee9ab8824 100755 --- a/test/run.sh +++ b/test/run.sh @@ -34,7 +34,7 @@ chmod 755 $t/ld $t/ld.lld $t/ld.gold $t/foo.ld ./mold -run $t/ld --version | grep -q mold ./mold -run $t/ld.lld --version | grep -q mold ./mold -run $t/ld.gold --version | grep -q mold -./mold -run $t/foo.ld --version | grep -q mold && false +./mold -run $t/foo.ld --version | not grep -q mold cat <<'EOF' > $t/sh #!/bin/sh @@ -49,4 +49,4 @@ chmod 755 $t/sh ./mold -run $t/sh $t/ld --version | grep -q mold ./mold -run $t/sh $t/ld.lld --version | grep -q mold ./mold -run $t/sh $t/ld.gold --version | grep -q mold -./mold -run $t/sh $t/foo.ld --version | grep -q mold && false +./mold -run $t/sh $t/foo.ld --version | not grep -q mold diff --git a/test/section-align.sh b/test/section-align.sh index 85853c9785..5fe52fd01b 100755 --- a/test/section-align.sh +++ b/test/section-align.sh @@ -12,5 +12,5 @@ readelf -WS $t/exe1 | grep -q '\.foo.* 8192$' $CC -B. -o $t/exe2 $t/a.o -Wl,--section-align=.foo=256 readelf -WS $t/exe2 | grep -q '\.foo.* 256$' -not $CC -B. -o $t/exe3 $t/a.o -Wl,--section-align=.foo=3 |& \ +not $CC -B. -o $t/exe3 $t/a.o -Wl,--section-align=.foo=3 |& grep -q 'must be a power of 2' diff --git a/test/shuffle-sections-seed.sh b/test/shuffle-sections-seed.sh index 0aa0025536..c5396c61c2 100755 --- a/test/shuffle-sections-seed.sh +++ b/test/shuffle-sections-seed.sh @@ -10,7 +10,7 @@ EOF # Create a lot of sections to lower the probability that # we get the identical output as a result of shuffling. -for i in `seq 1 1000`; do echo "void fn$i() {}"; done | \ +for i in `seq 1 1000`; do echo "void fn$i() {}"; done | $CC -o $t/b.o -ffunction-sections -c -xc - $CC -B. -o $t/exe1 $t/a.o $t/b.o diff --git a/test/shuffle-sections.sh b/test/shuffle-sections.sh index c25f8f186a..a551a21fc1 100755 --- a/test/shuffle-sections.sh +++ b/test/shuffle-sections.sh @@ -10,7 +10,7 @@ EOF # Create a lot of sections to lower the probability that # we get the identical output as a result of shuffling. -for i in `seq 1 1000`; do echo "void fn$i() {}"; done | \ +for i in `seq 1 1000`; do echo "void fn$i() {}"; done | $CC -o $t/b.o -ffunction-sections -c -xc - $CC -B. -o $t/exe1 $t/a.o $t/b.o diff --git a/test/unresolved-symbols.sh b/test/unresolved-symbols.sh index 94cf4c196d..e728f524ae 100755 --- a/test/unresolved-symbols.sh +++ b/test/unresolved-symbols.sh @@ -8,7 +8,7 @@ EOF not $CC -B. -o $t/exe $t/a.o |& grep -q 'undefined.*foo' -not $CC -B. -o $t/exe $t/a.o -Wl,-unresolved-symbols=report-all |& \ +not $CC -B. -o $t/exe $t/a.o -Wl,-unresolved-symbols=report-all |& grep -q 'undefined.*foo' $CC -B. -o $t/exe $t/a.o -Wl,-unresolved-symbols=ignore-all @@ -18,8 +18,8 @@ readelf --dyn-syms $t/exe | not grep -w foo $CC -B. -o $t/exe $t/a.o -Wl,-unresolved-symbols=report-all \ -Wl,--warn-unresolved-symbols |& grep -q 'undefined.*foo' -$CC -B. -o $t/exe $t/a.o -Wl,-unresolved-symbols=ignore-in-object-files |& \ +$CC -B. -o $t/exe $t/a.o -Wl,-unresolved-symbols=ignore-in-object-files |& not grep -q 'undefined.*foo' -not $CC -B. -o $t/exe $t/a.o -Wl,-unresolved-symbols=ignore-in-shared-libs |& \ +not $CC -B. -o $t/exe $t/a.o -Wl,-unresolved-symbols=ignore-in-shared-libs |& grep -q 'undefined.*foo' diff --git a/test/warn-unresolved-symbols.sh b/test/warn-unresolved-symbols.sh index 9dccf94295..519f7fbdc7 100755 --- a/test/warn-unresolved-symbols.sh +++ b/test/warn-unresolved-symbols.sh @@ -10,7 +10,7 @@ EOF not $CC -B. -o $t/exe $t/a.o |& grep -q 'undefined symbol:.*foo' -$CC -B. -o $t/exe $t/a.o -Wl,-warn-unresolved-symbols |& \ +$CC -B. -o $t/exe $t/a.o -Wl,-warn-unresolved-symbols |& grep -q 'undefined symbol:.*foo' not $CC -B. -o $t/exe $t/a.o -Wl,-warn-unresolved-symbols \ diff --git a/test/z-defs.sh b/test/z-defs.sh index 04a9d90259..a9381dfecf 100755 --- a/test/z-defs.sh +++ b/test/z-defs.sh @@ -9,11 +9,11 @@ EOF $CC -B. -shared -o $t/b.so $t/a.o $CC -B. -shared -o $t/b.so $t/a.o -Wl,-z,undefs -not $CC -B. -shared -o $t/b.so $t/a.o -Wl,-z,defs |& \ +not $CC -B. -shared -o $t/b.so $t/a.o -Wl,-z,defs |& grep -q 'undefined symbol:.* foo' -not $CC -B. -shared -o $t/b.so $t/a.o -Wl,-no-undefined |& \ +not $CC -B. -shared -o $t/b.so $t/a.o -Wl,-no-undefined |& grep -q 'undefined symbol:.* foo' -$CC -B. -shared -o $t/c.so $t/a.o -Wl,-z,defs -Wl,--warn-unresolved-symbols |& \ +$CC -B. -shared -o $t/c.so $t/a.o -Wl,-z,defs -Wl,--warn-unresolved-symbols |& grep -q 'undefined symbol:.* foo$'