From 04c50977e9df64bcc07e33a5f2e80f172a342ca3 Mon Sep 17 00:00:00 2001 From: Ellis Hoag Date: Fri, 30 May 2025 16:13:06 -0700 Subject: [PATCH 1/2] [Sanitizer] fix android test env issue --- .../TestCases/Posix/sanitizer_set_report_path_fail.cpp | 4 ++-- .../test/sanitizer_common/android_commands/android_run.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp index 782cd0218fd22..af5187a0d3265 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp @@ -1,10 +1,10 @@ // RUN: %clangxx -O2 %s -o %t // Case 1: Try setting a path that is an invalid/inaccessible directory. -// RUN: not %env %run %t 2>&1 | FileCheck %s --check-prefix=ERROR1 +// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=ERROR1 // Case 2: Try setting a path that is too large. -// RUN: not %env %run %t A 2>&1 | FileCheck %s --check-prefix=ERROR2 +// RUN: not %run %t A 2>&1 | FileCheck %s --check-prefix=ERROR2 #include #include diff --git a/compiler-rt/test/sanitizer_common/android_commands/android_run.py b/compiler-rt/test/sanitizer_common/android_commands/android_run.py index f50fc1eb2540d..3f41ce4447dcf 100755 --- a/compiler-rt/test/sanitizer_common/android_commands/android_run.py +++ b/compiler-rt/test/sanitizer_common/android_commands/android_run.py @@ -13,7 +13,7 @@ def build_env(): # Android linker ignores RPATH. Set LD_LIBRARY_PATH to Output dir. args.append("LD_LIBRARY_PATH=%s" % (ANDROID_TMPDIR,)) for (key, value) in list(os.environ.items()): - if key in ["ASAN_ACTIVATION_OPTIONS", "SCUDO_OPTIONS"] or key.endswith( + if key in ["ASAN_ACTIVATION_OPTIONS", "SCUDO_OPTIONS", "HOME", "TMPDIR"] or key.endswith( "SAN_OPTIONS" ): args.append('%s="%s"' % (key, value.replace('"', '\\"'))) From 30441609341d66770e75a5065b703bde0c14d5bc Mon Sep 17 00:00:00 2001 From: Ellis Hoag Date: Fri, 30 May 2025 19:15:40 -0700 Subject: [PATCH 2/2] format --- .../Posix/sanitizer_set_report_path_fail.cpp | 4 ++-- .../sanitizer_common/android_commands/android_run.py | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp index af5187a0d3265..782cd0218fd22 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp @@ -1,10 +1,10 @@ // RUN: %clangxx -O2 %s -o %t // Case 1: Try setting a path that is an invalid/inaccessible directory. -// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=ERROR1 +// RUN: not %env %run %t 2>&1 | FileCheck %s --check-prefix=ERROR1 // Case 2: Try setting a path that is too large. -// RUN: not %run %t A 2>&1 | FileCheck %s --check-prefix=ERROR2 +// RUN: not %env %run %t A 2>&1 | FileCheck %s --check-prefix=ERROR2 #include #include diff --git a/compiler-rt/test/sanitizer_common/android_commands/android_run.py b/compiler-rt/test/sanitizer_common/android_commands/android_run.py index 3f41ce4447dcf..515939dc5c3db 100755 --- a/compiler-rt/test/sanitizer_common/android_commands/android_run.py +++ b/compiler-rt/test/sanitizer_common/android_commands/android_run.py @@ -12,10 +12,13 @@ def build_env(): args = [] # Android linker ignores RPATH. Set LD_LIBRARY_PATH to Output dir. args.append("LD_LIBRARY_PATH=%s" % (ANDROID_TMPDIR,)) - for (key, value) in list(os.environ.items()): - if key in ["ASAN_ACTIVATION_OPTIONS", "SCUDO_OPTIONS", "HOME", "TMPDIR"] or key.endswith( - "SAN_OPTIONS" - ): + for key, value in list(os.environ.items()): + if key in [ + "ASAN_ACTIVATION_OPTIONS", + "SCUDO_OPTIONS", + "HOME", + "TMPDIR", + ] or key.endswith("SAN_OPTIONS"): args.append('%s="%s"' % (key, value.replace('"', '\\"'))) return " ".join(args)