Skip to content

[Sanitizer] Fix android test env issue #142235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2025
Merged

[Sanitizer] Fix android test env issue #142235

merged 2 commits into from
May 31, 2025

Conversation

ellishg
Copy link
Contributor

@ellishg ellishg commented May 30, 2025

I attempted to fix android tests in #142207 (broken by #141820). They are still failing but now I have more info.

https://lab.llvm.org/buildbot/#/builders/186/builds/9504/steps/16/logs/stdio

ERROR: Can't open file: //foo.8862 (reason: 30)

I believe the reason is that on android the HOME and TMPDIR environment variables are not being set correctly, or they are not read correctly. (#142234 (comment))

@llvmbot
Copy link
Member

llvmbot commented May 30, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Ellis Hoag (ellishg)

Changes

I attempted to fix android tests in #142207 (broken by #141820). They are still failing but now I have more info.

https://lab.llvm.org/buildbot/#/builders/186/builds/9504/steps/16/logs/stdio

ERROR: Can't open file: //foo.8862 (reason: 30)

I believe the reason is that on android the HOME and TMPDIR environment variables are not being set correctly, or they are not read correctly. (#142234 (comment))

Also remove an extra %env left in a related test.


Full diff: https://github.com/llvm/llvm-project/pull/142235.diff

2 Files Affected:

  • (modified) compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp (+2-2)
  • (modified) compiler-rt/test/sanitizer_common/android_commands/android_run.py (+1-1)
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 <sanitizer/common_interface_defs.h>
 #include <stdio.h>
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('"', '\\"')))

Copy link
Contributor

@fmayer fmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not include the unrelated test change in the same PR

Copy link

github-actions bot commented May 30, 2025

✅ With the latest revision this PR passed the Python code formatter.

@ellishg ellishg merged commit c979d1f into llvm:main May 31, 2025
9 of 10 checks passed
@ellishg ellishg deleted the fix-android branch May 31, 2025 02:26
ellishg added a commit that referenced this pull request May 31, 2025
I attempted to fix this test in
#142235 but we a new error.


https://lab.llvm.org/buildbot/#/builders/186/builds/9524/steps/26/logs/stdio
> ERROR: Can't create directory: /var

The path we want is actually at `/data/local/tmp/Output/var/...`.

I found `%device_rundir/` evaluates to this prefix on android, and
nothing otherwise.


https://github.com/llvm/llvm-project/blob/f057a593a7151437edd25cfbbdcf450139346f12/compiler-rt/test/lit.common.cfg.py#L658
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request May 31, 2025
I attempted to fix this test in
llvm/llvm-project#142235 but we a new error.

https://lab.llvm.org/buildbot/#/builders/186/builds/9524/steps/26/logs/stdio
> ERROR: Can't create directory: /var

The path we want is actually at `/data/local/tmp/Output/var/...`.

I found `%device_rundir/` evaluates to this prefix on android, and
nothing otherwise.

https://github.com/llvm/llvm-project/blob/f057a593a7151437edd25cfbbdcf450139346f12/compiler-rt/test/lit.common.cfg.py#L658
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants