[compiler-rt] [llvm] [compiler-rt][test] Resolved export command failure in test run with lit's internal shell (PR #105961)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 24 15:16:05 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Connie Zhu (connieyzhu)

<details>
<summary>Changes</summary>

This patch fixes the incorrect usage of lit's built-in `export` command. 

First, a typo in raising the error itself is resolved. The error being raised had the wrong number of parameters passed in. 

Then, the `export` command was given the wrong number of arguments, as `%env_asan_opts` expands to `env ASAN_OPTIONS`, giving `export` two arguments instead of the expected one argument. To avoid this, the use of `export` is completely removed, and the setting of the environment variable `ASAN_OPTIONS` is added before all RUN lines following the initial export RUN line. This is essentially the same as using `export`, which propagates the environment variable value to all subsequent commands. 

Fixes https://github.com/llvm/llvm-project/issues/102386.

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


2 Files Affected:

- (modified) compiler-rt/test/asan/TestCases/Posix/high-address-dereference.c (+5-6) 
- (modified) llvm/utils/lit/lit/TestRunner.py (+1-1) 


``````````diff
diff --git a/compiler-rt/test/asan/TestCases/Posix/high-address-dereference.c b/compiler-rt/test/asan/TestCases/Posix/high-address-dereference.c
index 845e126d3f89b9..37a7b1702e982e 100644
--- a/compiler-rt/test/asan/TestCases/Posix/high-address-dereference.c
+++ b/compiler-rt/test/asan/TestCases/Posix/high-address-dereference.c
@@ -5,12 +5,11 @@
 
 // REQUIRES: x86_64-target-arch
 // RUN: %clang_asan %s -o %t
-// RUN: export %env_asan_opts=print_scariness=1
-// RUN: not %run %t 0x0000000000000000 2>&1 | FileCheck %s --check-prefixes=ZERO,HINT-PAGE0
-// RUN: not %run %t 0x0000000000000FFF 2>&1 | FileCheck %s --check-prefixes=LOW1,HINT-PAGE0
-// RUN: not %run %t 0x0000000000001000 2>&1 | FileCheck %s --check-prefixes=LOW2,HINT-NONE
-// RUN: not %run %t 0x4141414141414141 2>&1 | FileCheck %s --check-prefixes=HIGH,HINT-HIGHADDR
-// RUN: not %run %t 0xFFFFFFFFFFFFFFFF 2>&1 | FileCheck %s --check-prefixes=MAX,HINT-HIGHADDR
+// RUN: %env_asan_opts=print_scariness=1 not %run %t 0x0000000000000000 2>&1 | FileCheck %s --check-prefixes=ZERO,HINT-PAGE0
+// RUN: %env_asan_opts=print_scariness=1 not %run %t 0x0000000000000FFF 2>&1 | FileCheck %s --check-prefixes=LOW1,HINT-PAGE0
+// RUN: %env_asan_opts=print_scariness=1 not %run %t 0x0000000000001000 2>&1 | FileCheck %s --check-prefixes=LOW2,HINT-NONE
+// RUN: %env_asan_opts=print_scariness=1 not %run %t 0x4141414141414141 2>&1 | FileCheck %s --check-prefixes=HIGH,HINT-HIGHADDR
+// RUN: %env_asan_opts=print_scariness=1 not %run %t 0xFFFFFFFFFFFFFFFF 2>&1 | FileCheck %s --check-prefixes=MAX,HINT-HIGHADDR
 
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index da7fa86fd39173..63ab5e4c183494 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -356,7 +356,7 @@ def executeBuiltinPopd(cmd, shenv):
 def executeBuiltinExport(cmd, shenv):
     """executeBuiltinExport - Set an environment variable."""
     if len(cmd.args) != 2:
-        raise InternalShellError("'export' supports only one argument")
+        raise InternalShellError(cmd, "'export' supports only one argument")
     updateEnv(shenv, cmd.args)
     return ShellCommandResult(cmd, "", "", 0, False)
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/105961


More information about the llvm-commits mailing list