Skip to content

Commit e9b11ae

Browse files
[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: #168656
1 parent 8f91d9f commit e9b11ae

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
for I in {1..3}; do \
3+
log show --debug --last $((SECONDS + 30))s --predicate "processID == $1" --style syslog > $2; \
4+
if grep -q "use-after-poison" $2; then break; fi; \
5+
sleep 5; \
6+
done

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
// UNSUPPORTED: ios
22
// REQUIRES: darwin_log_cmd
33
// RUN: %clangxx_asan -fsanitize-recover=address %s -o %t
4-
// RUN: { %env_asan_opts=halt_on_error=0,log_to_syslog=1 %run %t > %t.process_output.txt 2>&1 & } \
5-
// RUN: ; export TEST_PID=$! ; wait ${TEST_PID}
4+
// RUN: bash -c '{ %env_asan_opts=halt_on_error=0,log_to_syslog=1 %run %t > %t.process_output.txt 2>&1 & } \
5+
// RUN: ; export TEST_PID=$! ; wait ${TEST_PID}; echo -n ${TEST_PID} > %t.test_pid'
66

77
// Check process output.
88
// RUN: FileCheck %s --check-prefixes CHECK,CHECK-PROC -input-file=%t.process_output.txt
99

1010
// Check syslog output. We filter recent system logs based on PID to avoid
1111
// getting the logs of previous test runs. Make some reattempts in case there
1212
// is a delay.
13-
// RUN: for I in {1..3}; do \
14-
// RUN: log show --debug --last $((SECONDS + 30))s --predicate "processID == ${TEST_PID}" --style syslog > %t.process_syslog_output.txt; \
15-
// RUN: if grep -q "use-after-poison" %t.process_syslog_output.txt; then break; fi; \
16-
// RUN: sleep 5; \
17-
// RUN: done
13+
// RUN: %S/Inputs/check-syslog.sh %{readfile:%t.test_pid} %t.process_syslog_output.txt
1814
// RUN: FileCheck %s -input-file=%t.process_syslog_output.txt
1915
#include <cassert>
2016
#include <cstdio>

0 commit comments

Comments
 (0)