[compiler-rt] e9b11ae - [ASan] Make duplicate_os_log_reports.cpp work with the internal shell

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 19 09:26:35 PST 2025


Author: Aiden Grossman
Date: 2025-11-19T09:26:30-08:00
New Revision: e9b11ae83731bbca6adf9f9b39b6d3aa1869e445

URL: https://github.com/llvm/llvm-project/commit/e9b11ae83731bbca6adf9f9b39b6d3aa1869e445
DIFF: https://github.com/llvm/llvm-project/commit/e9b11ae83731bbca6adf9f9b39b6d3aa1869e445.diff

LOG: [ASan] Make duplicate_os_log_reports.cpp work with the internal shell

This test used a for loop to implement retries and also did some trickery with PIDs.
For this test, just invoke bash for actually running the test given we need the PID,
and move the for loop into a separate shell script file that we can then invoke from
within the test. Normally it would make sense to rewrite such a script in Python, but
given this test does not have portability concerns only running on Darwin, it is fine
to use a shell script here given there is no other convenient alternative.

Reviewers: ndrewh, DanBlackwell, fmayer

Reviewed By: ndrewh

Pull Request: https://github.com/llvm/llvm-project/pull/168656

Added: 
    compiler-rt/test/asan/TestCases/Darwin/Inputs/check-syslog.sh

Modified: 
    compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/TestCases/Darwin/Inputs/check-syslog.sh b/compiler-rt/test/asan/TestCases/Darwin/Inputs/check-syslog.sh
new file mode 100755
index 0000000000000..8939ca7ca1564
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/Darwin/Inputs/check-syslog.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+for I in {1..3}; do \
+  log show --debug --last $((SECONDS + 30))s --predicate "processID == $1" --style syslog > $2; \
+  if grep -q "use-after-poison" $2; then break; fi; \
+  sleep 5; \
+done

diff  --git a/compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp b/compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp
index 5a0353bfb1b31..40a168bc15290 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp
@@ -1,8 +1,8 @@
 // UNSUPPORTED: ios
 // REQUIRES: darwin_log_cmd
 // RUN: %clangxx_asan -fsanitize-recover=address %s -o %t
-// RUN: { %env_asan_opts=halt_on_error=0,log_to_syslog=1 %run %t > %t.process_output.txt 2>&1 & } \
-// RUN: ; export TEST_PID=$! ; wait ${TEST_PID}
+// RUN: bash -c '{ %env_asan_opts=halt_on_error=0,log_to_syslog=1 %run %t > %t.process_output.txt 2>&1 & } \
+// RUN: ; export TEST_PID=$! ; wait ${TEST_PID}; echo -n ${TEST_PID} > %t.test_pid'
 
 // Check process output.
 // RUN: FileCheck %s --check-prefixes CHECK,CHECK-PROC -input-file=%t.process_output.txt
@@ -10,11 +10,7 @@
 // Check syslog output. We filter recent system logs based on PID to avoid
 // getting the logs of previous test runs. Make some reattempts in case there
 // is a delay.
-// RUN: for I in {1..3}; do \
-// RUN:   log show --debug --last $((SECONDS + 30))s --predicate "processID == ${TEST_PID}" --style syslog > %t.process_syslog_output.txt; \
-// RUN:   if grep -q "use-after-poison" %t.process_syslog_output.txt; then break; fi; \
-// RUN:   sleep 5; \
-// RUN: done
+// RUN: %S/Inputs/check-syslog.sh %{readfile:%t.test_pid} %t.process_syslog_output.txt
 // RUN: FileCheck %s -input-file=%t.process_syslog_output.txt
 #include <cassert>
 #include <cstdio>


        


More information about the llvm-commits mailing list