From ae56b57efc58362ce930f138903bf73175a36278 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 25 Sep 2025 09:15:39 -0700 Subject: [PATCH 1/4] [compiler-rt] Fix some tests to work with lit internal shell. This is part of our work to migrate lit tests to use internal shell by default (performance improvements). --- compiler-rt/test/fuzzer/fork-sigusr.test | 6 +++--- compiler-rt/test/fuzzer/sigint.test | 7 ++++--- compiler-rt/test/fuzzer/sigusr.test | 6 +++--- compiler-rt/test/msan/allocator_mapping.cpp | 3 ++- compiler-rt/test/nsan/Posix/allocator_mapping.cpp | 3 ++- compiler-rt/test/tsan/ignore_lib0.cpp | 8 ++++---- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/compiler-rt/test/fuzzer/fork-sigusr.test b/compiler-rt/test/fuzzer/fork-sigusr.test index 088e63cae4311..54fcb818793b8 100644 --- a/compiler-rt/test/fuzzer/fork-sigusr.test +++ b/compiler-rt/test/fuzzer/fork-sigusr.test @@ -1,14 +1,14 @@ # Check that libFuzzer honors SIGUSR1/SIGUSR2 # Disabled on Windows which does not have SIGUSR1/SIGUSR2. -REQUIRES: shell UNSUPPORTED: darwin, target={{.*windows.*}}, target=aarch64{{.*}} RUN: rm -rf %t RUN: mkdir -p %t RUN: %cpp_compiler %S/SleepOneSecondTest.cpp -o %t/ForkSIGUSR -RUN: %run %t/ForkSIGUSR -fork=3 -ignore_crashes=1 2>%t/log & export PID=$! +RUN: bash -c "nohup %run %t/ForkSIGUSR -fork=3 -ignore_crashes=1 2>%t/log &" | env +RUN: ps auxx | grep ForkSIGUSR | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 RUN: sleep 3 -RUN: kill -SIGUSR2 $PID +RUN: kill -SIGUSR2 %{readfile:%t2} RUN: sleep 6 RUN: cat %t/log | FileCheck %s --dump-input=fail diff --git a/compiler-rt/test/fuzzer/sigint.test b/compiler-rt/test/fuzzer/sigint.test index ac482d79b8e28..a64f37db46697 100644 --- a/compiler-rt/test/fuzzer/sigint.test +++ b/compiler-rt/test/fuzzer/sigint.test @@ -1,4 +1,4 @@ -REQUIRES: shell, msan +REQUIRES: msan UNSUPPORTED: target=arm{{.*}} # Check that libFuzzer exits gracefully under SIGINT with MSan. @@ -6,9 +6,10 @@ RUN: rm -rf %t RUN: mkdir -p %t RUN: %msan_compiler %S/SleepOneSecondTest.cpp -o %t/LFSIGINT -RUN: %run %t/LFSIGINT 2> %t/log & export PID=$! +RUN: bash -c "nohup %run %t/LFSIGINT 2> %t/log &" | env +RUN: ps auxx | grep LFSIGINT | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 RUN: sleep 2 -RUN: kill -SIGINT $PID +RUN: kill -SIGINT %{readfile:%t2} RUN: sleep 3 RUN: cat %t/log | FileCheck %s diff --git a/compiler-rt/test/fuzzer/sigusr.test b/compiler-rt/test/fuzzer/sigusr.test index c8a77ac63a6d7..0db6ce8e8b366 100644 --- a/compiler-rt/test/fuzzer/sigusr.test +++ b/compiler-rt/test/fuzzer/sigusr.test @@ -1,15 +1,15 @@ # FIXME: Disabled on Windows for now because of reliance on posix only features # (eg: export, "&", pkill). -REQUIRES: shell UNSUPPORTED: darwin, target={{.*windows.*}} # Check that libFuzzer honors SIGUSR1/SIGUSR2 RUN: rm -rf %t RUN: mkdir -p %t RUN: %cpp_compiler %S/SleepOneSecondTest.cpp -o %t/LFSIGUSR -RUN: %run %t/LFSIGUSR 2> %t/log & export PID=$! +RUN: bash -c "nohup %run %t/LFSIGUSR 2> %t/log &"| env +RUN: ps auxx | grep LFSIGUSR | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 RUN: sleep 2 -RUN: kill -SIGUSR1 $PID +RUN: kill -SIGUSR1 %{readfile:%t2} RUN: sleep 3 RUN: cat %t/log | FileCheck %s diff --git a/compiler-rt/test/msan/allocator_mapping.cpp b/compiler-rt/test/msan/allocator_mapping.cpp index e7a12da489152..aa48863861ecb 100644 --- a/compiler-rt/test/msan/allocator_mapping.cpp +++ b/compiler-rt/test/msan/allocator_mapping.cpp @@ -3,7 +3,8 @@ // mapping the heap early, in __msan_init. // // RUN: %clangxx_msan -O0 %s -o %t_1 -// RUN: %clangxx_msan -O0 -DHEAP_ADDRESS=$(%run %t_1) %s -o %t_2 && %run %t_2 +// RUN: %run %t_1 > %t_3 +// RUN: %clangxx_msan -O0 -DHEAP_ADDRESS=%{readfile:%t_3} %s -o %t_2 && %run %t_2 // // This test only makes sense for the 64-bit allocator. The 32-bit allocator // does not have a fixed mapping. Exclude platforms that use the 32-bit diff --git a/compiler-rt/test/nsan/Posix/allocator_mapping.cpp b/compiler-rt/test/nsan/Posix/allocator_mapping.cpp index 3a3e655e259d0..8be5008686385 100644 --- a/compiler-rt/test/nsan/Posix/allocator_mapping.cpp +++ b/compiler-rt/test/nsan/Posix/allocator_mapping.cpp @@ -2,7 +2,8 @@ /// Test that a module constructor can not map memory over the NSan heap /// (without MAP_FIXED, of course). // RUN: %clangxx_nsan -O0 %s -o %t_1 -// RUN: %clangxx_nsan -O0 -DHEAP_ADDRESS=$(%run %t_1) %s -o %t_2 && %run %t_2 +// RUN: %run %t_1 > %t_3 +// RUN: %clangxx_nsan -O0 -DHEAP_ADDRESS=%{readfile:%t_3} %s -o %t_2 && %run %t_2 #include #include diff --git a/compiler-rt/test/tsan/ignore_lib0.cpp b/compiler-rt/test/tsan/ignore_lib0.cpp index cba58c6177038..c25439a49fe93 100644 --- a/compiler-rt/test/tsan/ignore_lib0.cpp +++ b/compiler-rt/test/tsan/ignore_lib0.cpp @@ -4,11 +4,12 @@ // RUN: %clangxx_tsan -O1 -fno-builtin %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib0.so // RUN: %clangxx_tsan -O1 %s -L%t-dir -lignore_lib0 %link_libcxx_tsan -o %t // RUN: echo running w/o suppressions: -// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP +// RUN: bash -c env | grep LD_LIBRARY_PATH | sed s/.*LD_LIBRARY_PATH=// > %t2 +// RUN: env LD_LIBRARY_PATH=%t-dir:%{readfile:%t2} %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP // RUN: echo running with suppressions: -// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP +// RUN: env LD_LIBRARY_PATH=%t-dir:%{readfile:%t2} %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP // RUN: echo running with generic suppression of noninstrumented code: -// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %env_tsan_opts=ignore_noninstrumented_modules=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP +// RUN: env LD_LIBRARY_PATH=%t-dir:%{readfile:%t2} %env_tsan_opts=ignore_noninstrumented_modules=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP // Tests that interceptors coming from a library specified in called_from_lib // suppression are ignored. @@ -37,4 +38,3 @@ int main() { // CHECK-WITHSUPP-NOT: WARNING: ThreadSanitizer: data race // CHECK-WITHSUPP: OK - From a383410815828392ee5f117207ad74656e536650 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 25 Sep 2025 13:07:42 -0700 Subject: [PATCH 2/4] Add comment re ' | env'; remove extra 'x' from 'ps' options. --- compiler-rt/test/fuzzer/fork-sigusr.test | 5 ++++- compiler-rt/test/fuzzer/sigint.test | 5 ++++- compiler-rt/test/fuzzer/sigusr.test | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/compiler-rt/test/fuzzer/fork-sigusr.test b/compiler-rt/test/fuzzer/fork-sigusr.test index 54fcb818793b8..aa177d8043eb5 100644 --- a/compiler-rt/test/fuzzer/fork-sigusr.test +++ b/compiler-rt/test/fuzzer/fork-sigusr.test @@ -5,8 +5,11 @@ RUN: rm -rf %t RUN: mkdir -p %t RUN: %cpp_compiler %S/SleepOneSecondTest.cpp -o %t/ForkSIGUSR +# The line below needs the " | env" at the end, in order to make the +# script continue executing, rather than waiting (forever) for the +# 'nohup run...' command to finish. RUN: bash -c "nohup %run %t/ForkSIGUSR -fork=3 -ignore_crashes=1 2>%t/log &" | env -RUN: ps auxx | grep ForkSIGUSR | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 +RUN: ps aux | grep ForkSIGUSR | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 RUN: sleep 3 RUN: kill -SIGUSR2 %{readfile:%t2} RUN: sleep 6 diff --git a/compiler-rt/test/fuzzer/sigint.test b/compiler-rt/test/fuzzer/sigint.test index a64f37db46697..71bdfc0e577f0 100644 --- a/compiler-rt/test/fuzzer/sigint.test +++ b/compiler-rt/test/fuzzer/sigint.test @@ -6,8 +6,11 @@ RUN: rm -rf %t RUN: mkdir -p %t RUN: %msan_compiler %S/SleepOneSecondTest.cpp -o %t/LFSIGINT +# The line below needs the " | env" at the end, in order to make the +# script continue executing, rather than waiting (forever) for the +# 'nohup run...' command to finish. RUN: bash -c "nohup %run %t/LFSIGINT 2> %t/log &" | env -RUN: ps auxx | grep LFSIGINT | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 +RUN: ps aux | grep LFSIGINT | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 RUN: sleep 2 RUN: kill -SIGINT %{readfile:%t2} RUN: sleep 3 diff --git a/compiler-rt/test/fuzzer/sigusr.test b/compiler-rt/test/fuzzer/sigusr.test index 0db6ce8e8b366..103d3114182fc 100644 --- a/compiler-rt/test/fuzzer/sigusr.test +++ b/compiler-rt/test/fuzzer/sigusr.test @@ -6,8 +6,11 @@ RUN: rm -rf %t RUN: mkdir -p %t RUN: %cpp_compiler %S/SleepOneSecondTest.cpp -o %t/LFSIGUSR +# The line below needs the " | env" at the end, in order to make the +# script continue executing, rather than waiting (forever) for the +# 'nohup run...' command to finish. RUN: bash -c "nohup %run %t/LFSIGUSR 2> %t/log &"| env -RUN: ps auxx | grep LFSIGUSR | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 +RUN: ps aux | grep LFSIGUSR | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 RUN: sleep 2 RUN: kill -SIGUSR1 %{readfile:%t2} RUN: sleep 3 From edd2f3df64241bc2459ac9572e7f896c1fcefdc9 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 25 Sep 2025 14:30:08 -0700 Subject: [PATCH 3/4] Use $! inside the bash -c command, to simplify things. --- compiler-rt/test/fuzzer/fork-sigusr.test | 3 +-- compiler-rt/test/fuzzer/sigint.test | 3 +-- compiler-rt/test/fuzzer/sigusr.test | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/compiler-rt/test/fuzzer/fork-sigusr.test b/compiler-rt/test/fuzzer/fork-sigusr.test index aa177d8043eb5..226c4147b7380 100644 --- a/compiler-rt/test/fuzzer/fork-sigusr.test +++ b/compiler-rt/test/fuzzer/fork-sigusr.test @@ -8,8 +8,7 @@ RUN: %cpp_compiler %S/SleepOneSecondTest.cpp -o %t/ForkSIGUSR # The line below needs the " | env" at the end, in order to make the # script continue executing, rather than waiting (forever) for the # 'nohup run...' command to finish. -RUN: bash -c "nohup %run %t/ForkSIGUSR -fork=3 -ignore_crashes=1 2>%t/log &" | env -RUN: ps aux | grep ForkSIGUSR | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 +RUN: bash -c "nohup %run %t/ForkSIGUSR -fork=3 -ignore_crashes=1 2>%t/log & echo -n $! > %t2" | env RUN: sleep 3 RUN: kill -SIGUSR2 %{readfile:%t2} RUN: sleep 6 diff --git a/compiler-rt/test/fuzzer/sigint.test b/compiler-rt/test/fuzzer/sigint.test index 71bdfc0e577f0..aa112f086066f 100644 --- a/compiler-rt/test/fuzzer/sigint.test +++ b/compiler-rt/test/fuzzer/sigint.test @@ -9,8 +9,7 @@ RUN: %msan_compiler %S/SleepOneSecondTest.cpp -o %t/LFSIGINT # The line below needs the " | env" at the end, in order to make the # script continue executing, rather than waiting (forever) for the # 'nohup run...' command to finish. -RUN: bash -c "nohup %run %t/LFSIGINT 2> %t/log &" | env -RUN: ps aux | grep LFSIGINT | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 +RUN: bash -c "nohup %run %t/LFSIGINT 2> %t/log & echo -n $! > %t2" | env RUN: sleep 2 RUN: kill -SIGINT %{readfile:%t2} RUN: sleep 3 diff --git a/compiler-rt/test/fuzzer/sigusr.test b/compiler-rt/test/fuzzer/sigusr.test index 103d3114182fc..0c1d29231e1a0 100644 --- a/compiler-rt/test/fuzzer/sigusr.test +++ b/compiler-rt/test/fuzzer/sigusr.test @@ -9,8 +9,7 @@ RUN: %cpp_compiler %S/SleepOneSecondTest.cpp -o %t/LFSIGUSR # The line below needs the " | env" at the end, in order to make the # script continue executing, rather than waiting (forever) for the # 'nohup run...' command to finish. -RUN: bash -c "nohup %run %t/LFSIGUSR 2> %t/log &"| env -RUN: ps aux | grep LFSIGUSR | grep -v "grep" | awk '{print $2}' | tr -d '\n' > %t2 +RUN: bash -c "nohup %run %t/LFSIGUSR 2> %t/log & echo -n $! > %t2"| env RUN: sleep 2 RUN: kill -SIGUSR1 %{readfile:%t2} RUN: sleep 3 From 8a585b2296d6c1cfb306e1a8b5de474a1400c64c Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Fri, 26 Sep 2025 10:09:20 -0700 Subject: [PATCH 4/4] Restore original version of tsan/ignore_lib0.cpp. --- compiler-rt/test/tsan/ignore_lib0.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler-rt/test/tsan/ignore_lib0.cpp b/compiler-rt/test/tsan/ignore_lib0.cpp index c25439a49fe93..cba58c6177038 100644 --- a/compiler-rt/test/tsan/ignore_lib0.cpp +++ b/compiler-rt/test/tsan/ignore_lib0.cpp @@ -4,12 +4,11 @@ // RUN: %clangxx_tsan -O1 -fno-builtin %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib0.so // RUN: %clangxx_tsan -O1 %s -L%t-dir -lignore_lib0 %link_libcxx_tsan -o %t // RUN: echo running w/o suppressions: -// RUN: bash -c env | grep LD_LIBRARY_PATH | sed s/.*LD_LIBRARY_PATH=// > %t2 -// RUN: env LD_LIBRARY_PATH=%t-dir:%{readfile:%t2} %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP +// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP // RUN: echo running with suppressions: -// RUN: env LD_LIBRARY_PATH=%t-dir:%{readfile:%t2} %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP +// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP // RUN: echo running with generic suppression of noninstrumented code: -// RUN: env LD_LIBRARY_PATH=%t-dir:%{readfile:%t2} %env_tsan_opts=ignore_noninstrumented_modules=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP +// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %env_tsan_opts=ignore_noninstrumented_modules=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP // Tests that interceptors coming from a library specified in called_from_lib // suppression are ignored. @@ -38,3 +37,4 @@ int main() { // CHECK-WITHSUPP-NOT: WARNING: ThreadSanitizer: data race // CHECK-WITHSUPP: OK +