summaryrefslogtreecommitdiff
path: root/compiler-rt/test
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/test')
-rw-r--r--compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp1
-rw-r--r--compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c3
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp9
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/rtlallocateheap_realloc_in_place.cpp71
-rw-r--r--compiler-rt/test/asan/TestCases/suppressions-library.cpp2
-rw-r--r--compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp3
-rw-r--r--compiler-rt/test/asan/TestCases/zero_alloc.cpp35
-rw-r--r--compiler-rt/test/fuzzer/CrossOverTest.cpp3
-rw-r--r--compiler-rt/test/fuzzer/sig-trap.test4
-rw-r--r--compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp2
-rw-r--r--compiler-rt/test/msan/zero_alloc.cpp35
-rw-r--r--compiler-rt/test/profile/instrprof-thinlto-indirect-call-promotion.cpp2
-rw-r--r--compiler-rt/test/rtsan/unrecognized_flags.cpp2
-rw-r--r--compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp2
-rw-r--r--compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c3
-rw-r--r--compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp3
-rw-r--r--compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp4
-rw-r--r--compiler-rt/test/xray/TestCases/Posix/dlopen.cpp2
-rw-r--r--compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp2
-rw-r--r--compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp2
-rw-r--r--compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp2
21 files changed, 161 insertions, 31 deletions
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 43ca027c970c..0091ebc09205 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,5 +1,4 @@
// UNSUPPORTED: ios
-// REQUIRES: shell
// 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 & } \
diff --git a/compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c b/compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c
index 08bf5e125cf4..5d4a812c80d8 100644
--- a/compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c
+++ b/compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c
@@ -6,8 +6,7 @@
// will be unable to resolve its $ORIGIN due to readlink() restriction and will
// thus fail to start, causing the test to die with SIGPIPE when attempting to
// talk to it.
-// RUN: not ls /usr/include/linux/seccomp.h || ( %clang_asan %s -o %t && ( not env ASAN_OPTIONS=symbolize=0 %run %t 2>&1 ) | FileCheck %s )
-// REQUIRES: shell
+// RUN: not ls /usr/include/linux/seccomp.h || %clang_asan %s -o %t || not env ASAN_OPTIONS=symbolize=0 %run %t 2>&1 | FileCheck %s
// UNSUPPORTED: android
#include <errno.h>
diff --git a/compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp b/compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp
index 8b0bc71b9f5d..6a5f8a1e7ea0 100644
--- a/compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp
@@ -1,15 +1,20 @@
// RUN: %clang_cl_asan %Od %MT -o %t %s
// RUN: %env_asan_opts=windows_hook_rtl_allocators=true %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: asan-64-bits
#include <cassert>
#include <iostream>
+#include <sanitizer/allocator_interface.h>
#include <windows.h>
int main() {
void *ptr = malloc(0);
if (ptr)
std::cerr << "allocated!\n";
- ((char *)ptr)[0] = '\xff'; //check this 'allocate 1 instead of 0' hack hasn't changed
+
+ // Check the 'allocate 1 instead of 0' hack hasn't changed
+ // Note that as of b3452d90b043a398639e62b0ab01aa339cc649de, dereferencing
+ // the pointer will be detected as a heap-buffer-overflow.
+ if (__sanitizer_get_allocated_size(ptr) != 1)
+ return 1;
free(ptr);
diff --git a/compiler-rt/test/asan/TestCases/Windows/rtlallocateheap_realloc_in_place.cpp b/compiler-rt/test/asan/TestCases/Windows/rtlallocateheap_realloc_in_place.cpp
new file mode 100644
index 000000000000..35fa9ce57429
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/Windows/rtlallocateheap_realloc_in_place.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cl_asan %Od %s %Fe%t %MD
+// RUN: %env_asan_opts=windows_hook_rtl_allocators=true not %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+#include <windows.h>
+
+using AllocateFunctionPtr = PVOID(__stdcall *)(PVOID, ULONG, SIZE_T);
+using ReAllocateFunctionPtr = PVOID(__stdcall *)(PVOID, ULONG, PVOID, SIZE_T);
+using FreeFunctionPtr = PVOID(__stdcall *)(PVOID, ULONG, PVOID);
+
+int main() {
+ HMODULE NtDllHandle = GetModuleHandle("ntdll.dll");
+ if (!NtDllHandle) {
+ fputs("Couldn't load ntdll??\n", stderr);
+ return -1;
+ }
+
+ auto RtlAllocateHeap_ptr =
+ (AllocateFunctionPtr)GetProcAddress(NtDllHandle, "RtlAllocateHeap");
+ if (RtlAllocateHeap_ptr == 0) {
+ fputs("Couldn't RtlAllocateHeap\n", stderr);
+ return -1;
+ }
+
+ auto RtlReAllocateHeap_ptr =
+ (ReAllocateFunctionPtr)GetProcAddress(NtDllHandle, "RtlReAllocateHeap");
+ if (RtlReAllocateHeap_ptr == 0) {
+ fputs("Couldn't find RtlReAllocateHeap\n", stderr);
+ return -1;
+ }
+
+ auto RtlFreeHeap_ptr =
+ (FreeFunctionPtr)GetProcAddress(NtDllHandle, "RtlFreeHeap");
+ if (RtlFreeHeap_ptr == 0) {
+ fputs("Couldn't RtlFreeHeap\n", stderr);
+ return -1;
+ }
+
+ char *ptr1;
+ char *ptr2;
+ ptr2 = ptr1 = (char *)RtlAllocateHeap_ptr(GetProcessHeap(), 0, 15);
+ if (ptr1)
+ fputs("Okay alloc\n", stderr);
+ // CHECK: Okay alloc
+
+ // TODO: Growing is currently not supported
+ ptr2 = (char *)RtlReAllocateHeap_ptr(GetProcessHeap(),
+ HEAP_REALLOC_IN_PLACE_ONLY, ptr1, 23);
+ if (ptr2 == NULL)
+ fputs("Okay grow failed\n", stderr);
+ // CHECK: Okay grow failed
+
+ // TODO: Shrinking is currently not supported
+ ptr2 = (char *)RtlReAllocateHeap_ptr(GetProcessHeap(),
+ HEAP_REALLOC_IN_PLACE_ONLY, ptr1, 7);
+ if (ptr2 == ptr1)
+ fputs("Okay shrinking return the original pointer\n", stderr);
+ // CHECK: Okay shrinking return the original pointer
+
+ ptr1[7] = 'a';
+ fputs("Okay 7\n", stderr);
+ // CHECK: Okay 7
+
+ // TODO: Writing behind the shrinked part is currently not detected.
+ // Therefore test writing behind the original allocation for now.
+ ptr1[16] = 'a';
+ // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 1 at [[ADDR]] thread T0
+
+ RtlFreeHeap_ptr(GetProcessHeap(), 0, ptr1);
+}
diff --git a/compiler-rt/test/asan/TestCases/suppressions-library.cpp b/compiler-rt/test/asan/TestCases/suppressions-library.cpp
index 5427122eaa92..9d1f5d4888e3 100644
--- a/compiler-rt/test/asan/TestCases/suppressions-library.cpp
+++ b/compiler-rt/test/asan/TestCases/suppressions-library.cpp
@@ -4,8 +4,6 @@
// Check that without suppressions, we catch the issue.
// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
-// REQUIRES: shell
-
// RUN: echo "interceptor_via_lib:"%xdynamiclib_filename > %t.supp
// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
diff --git a/compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp b/compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp
index 37c1dab6db8e..2c094c484371 100644
--- a/compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp
+++ b/compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp
@@ -1,9 +1,6 @@
// RUN: rm -rf %t-dir && mkdir -p %t-dir
// RUN: %clangxx_asan %s -o %t-dir/verbose-log-path_test-binary
-// The glob below requires bash.
-// REQUIRES: shell
-
// Good log_path.
// RUN: rm -f %t-dir/asan.log.*
// RUN: %env_asan_opts=log_path=%t-dir/asan.log:log_exe_name=1 not %run %t-dir/verbose-log-path_test-binary 2> %t.out
diff --git a/compiler-rt/test/asan/TestCases/zero_alloc.cpp b/compiler-rt/test/asan/TestCases/zero_alloc.cpp
new file mode 100644
index 000000000000..aa807f44ed3b
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/zero_alloc.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_asan -Wno-alloc-size -fsanitize-recover=address %s -o %t && %env_asan_opts=halt_on_error=0 %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv) {
+ {
+ char *p1 = (char *)calloc(1, 0);
+ printf("p1 is %p\n", p1);
+ printf("Content of p1 is: %d\n", *p1);
+ // CHECK: ERROR: AddressSanitizer: heap-buffer-overflow
+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
+ free(p1);
+ }
+
+ {
+ char *p2 = (char *)calloc(0, 1);
+ printf("p2 is %p\n", p2);
+ printf("Content of p2 is: %d\n", *p2);
+ // CHECK: ERROR: AddressSanitizer: heap-buffer-overflow
+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
+ free(p2);
+ }
+
+ {
+ char *p3 = (char *)malloc(0);
+ printf("p3 is %p\n", p3);
+ printf("Content of p2 is: %d\n", *p3);
+ // CHECK: ERROR: AddressSanitizer: heap-buffer-overflow
+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
+ free(p3);
+ }
+
+ return 0;
+}
diff --git a/compiler-rt/test/fuzzer/CrossOverTest.cpp b/compiler-rt/test/fuzzer/CrossOverTest.cpp
index b4506f665dc7..eb8a8c44ad47 100644
--- a/compiler-rt/test/fuzzer/CrossOverTest.cpp
+++ b/compiler-rt/test/fuzzer/CrossOverTest.cpp
@@ -45,6 +45,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
// fprintf(stderr, "ExpectedHash: %x\n", ExpectedHash);
if (Size == 10 && ExpectedHash == simple_hash(Data, Size))
*NullPtr = 0;
+ // It's UB to read *Data when Size == 0
+ if (Size == 0)
+ return 0;
if (*Data == 'A')
Sink++;
if (*Data == 'Z')
diff --git a/compiler-rt/test/fuzzer/sig-trap.test b/compiler-rt/test/fuzzer/sig-trap.test
index 30d9d47f4d81..60208c486a87 100644
--- a/compiler-rt/test/fuzzer/sig-trap.test
+++ b/compiler-rt/test/fuzzer/sig-trap.test
@@ -5,7 +5,7 @@ UNSUPPORTED: target={{.*windows.*}}
RUN: %cpp_compiler %S/SigTrapTest.cpp -o %t
RUN: not %run %t 2>&1 | FileCheck %s
-CHECK: BINGO
-CHECK: ERROR: libFuzzer: deadly signal
+CHECK-DAG: BINGO
+CHECK-DAG: ERROR: libFuzzer: deadly signal
RUN: trap "%run %t -handle_trap=0" TRAP
diff --git a/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp b/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp
index 91acd28a1a5f..b045ec704cec 100644
--- a/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp
+++ b/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp
@@ -4,7 +4,7 @@
// Android HWAsan does not support LSan.
// UNSUPPORTED: android
-// RUN: %clangxx_hwasan -O0 %s -o %t && HWASAN_OPTIONS=detect_leaks=1 %run %t
+// RUN: %clangxx_hwasan -O0 %s -o %t && env HWASAN_OPTIONS=detect_leaks=1 %run %t
#include <assert.h>
#include <dlfcn.h>
diff --git a/compiler-rt/test/msan/zero_alloc.cpp b/compiler-rt/test/msan/zero_alloc.cpp
new file mode 100644
index 000000000000..1451e1e89e9f
--- /dev/null
+++ b/compiler-rt/test/msan/zero_alloc.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_msan -Wno-alloc-size -fsanitize-recover=memory %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv) {
+ {
+ char *p1 = (char *)calloc(1, 0);
+ printf("p1 is %p\n", p1);
+ printf("Content of p1 is: %d\n", *p1);
+ // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
+ free(p1);
+ }
+
+ {
+ char *p2 = (char *)calloc(0, 1);
+ printf("p2 is %p\n", p2);
+ printf("Content of p2 is: %d\n", *p2);
+ // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
+ free(p2);
+ }
+
+ {
+ char *p3 = (char *)malloc(0);
+ printf("p3 is %p\n", p3);
+ printf("Content of p2 is: %d\n", *p3);
+ // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
+ free(p3);
+ }
+
+ return 0;
+}
diff --git a/compiler-rt/test/profile/instrprof-thinlto-indirect-call-promotion.cpp b/compiler-rt/test/profile/instrprof-thinlto-indirect-call-promotion.cpp
index d361186cf26a..4509c0149bdb 100644
--- a/compiler-rt/test/profile/instrprof-thinlto-indirect-call-promotion.cpp
+++ b/compiler-rt/test/profile/instrprof-thinlto-indirect-call-promotion.cpp
@@ -80,7 +80,7 @@ static void callee0() {}
void callee1() {}
typedef void (*FPT)();
FPT calleeAddrs[] = {callee0, callee1};
-// `global_func`` might call one of two indirect callees. callee0 has internal
+// `global_func` might call one of two indirect callees. callee0 has internal
// linkage and callee1 has external linkage.
void global_func() {
FPT fp = calleeAddrs[0];
diff --git a/compiler-rt/test/rtsan/unrecognized_flags.cpp b/compiler-rt/test/rtsan/unrecognized_flags.cpp
index 9e44e9f42993..d6649db6b0fb 100644
--- a/compiler-rt/test/rtsan/unrecognized_flags.cpp
+++ b/compiler-rt/test/rtsan/unrecognized_flags.cpp
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsanitize=realtime %s -o %t
-// RUN: RTSAN_OPTIONS="verbosity=1,asdf=1" %run %t 2>&1 | FileCheck %s
+// RUN: env RTSAN_OPTIONS="verbosity=1,asdf=1" %run %t 2>&1 | FileCheck %s
// UNSUPPORTED: ios
// Intent: Make sure we are respecting some basic common flags
diff --git a/compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp b/compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp
index 9416da2940be..45e8eaddb024 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp
@@ -19,8 +19,6 @@
// RUN: %env_tool_opts=external_symbolizer_path=%d/external_symbolizer_path.cpp.tmp.bin/llvm-symbolizer \
// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=NOT-FOUND
-// REQUIRES: shell
-
// Mobile device will not have symbolizer in provided path.
// UNSUPPORTED: ios, android
diff --git a/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c b/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c
index bf0e4e1bc376..b8ca5c739f42 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c
+++ b/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c
@@ -2,9 +2,6 @@
// RUN: mkdir -p %t.dir
// RUN: %clang %s -o %t.dir/suffix-log-path_test-binary
-// The glob below requires bash.
-// REQUIRES: shell
-
// Good log_path with suffix.
// RUN: %env_tool_opts=log_path=%t.dir/sanitizer.log:log_exe_name=1:log_suffix=.txt %run %t.dir/suffix-log-path_test-binary 2> %t.out
// RUN: FileCheck %s < %t.dir/sanitizer.log.suffix-log-path_test-binary.*.txt
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
index 527bd8552c81..e1191b5f6bb9 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
@@ -1,8 +1,5 @@
// Test various levels of coverage
//
-// FIXME: Port the environment variable logic below for the lit shell.
-// REQUIRES: shell
-//
// RUN: rm -rf %t-dir && mkdir %t-dir
// RUN: %clangxx -fsanitize=shift -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=func,trace-pc-guard %s -o %t
// RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir='"%t-dir"' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp b/compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp
index ffd95a5f9c0b..f1618afba248 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp
@@ -1,9 +1,6 @@
// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
// XFAIL: android
-// The globs below do not work in the lit shell.
-// REQUIRES: shell
-
// RUN: %clangxx -fsanitize=undefined %s -O1 -o %t
// Regular run.
@@ -38,4 +35,3 @@ int main(int argc, char *argv[]) {
}
// CHECK-ERROR: runtime error: -4 is outside the range of representable values of type 'unsigned int'
-
diff --git a/compiler-rt/test/xray/TestCases/Posix/dlopen.cpp b/compiler-rt/test/xray/TestCases/Posix/dlopen.cpp
index 9567269e8ff1..5326d83dfdd7 100644
--- a/compiler-rt/test/xray/TestCases/Posix/dlopen.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/dlopen.cpp
@@ -5,7 +5,7 @@
// RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -shared -std=c++11 %t/testlib.cpp -o %t/testlib.so
// RUN: %clangxx_xray -g -fPIC -rdynamic -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp -o %t/main.o
//
-// RUN: XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlib.so 2>&1 | FileCheck %s
+// RUN: env XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlib.so 2>&1 | FileCheck %s
// REQUIRES: target={{(aarch64|x86_64)-.*}}
diff --git a/compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp b/compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp
index 82cc127b521a..3b4564306abd 100644
--- a/compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp
@@ -15,7 +15,7 @@
// Executable links with a and b explicitly and loads d and e at runtime.
// RUN: %clangxx_xray -g -fPIC -rdynamic -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testliba.so %t/testlibb.so -o %t/main.o
//
-// RUN: XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlibd.so %t/testlibe.so 2>&1 | FileCheck %s
+// RUN: env XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlibd.so %t/testlibe.so 2>&1 | FileCheck %s
// REQUIRES: target={{(aarch64|x86_64)-.*}}
diff --git a/compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp b/compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp
index 7bce653fe723..5014fce61d5b 100644
--- a/compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp
@@ -4,7 +4,7 @@
// RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -shared -std=c++11 %t/testlib.cpp -o %t/testlib.so
// RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testlib.so -Wl,-rpath,%t -o %t/main.o
-// RUN: XRAY_OPTIONS="patch_premain=true,verbosity=1" %run %t/main.o 2>&1 | FileCheck %s
+// RUN: env XRAY_OPTIONS="patch_premain=true,verbosity=1" %run %t/main.o 2>&1 | FileCheck %s
// REQUIRES: target={{(aarch64|x86_64)-.*}}
diff --git a/compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp b/compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp
index 640cf9bcc1a3..9b3f63b5368a 100644
--- a/compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp
@@ -6,7 +6,7 @@
// RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -shared -std=c++11 %t/testlib.cpp -o %t/testlib.so
// RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testlib.so -Wl,-rpath,%t -o %t/main.o
-// RUN: XRAY_OPTIONS="patch_premain=false" %run %t/main.o 2>&1 | FileCheck %s
+// RUN: env XRAY_OPTIONS="patch_premain=false" %run %t/main.o 2>&1 | FileCheck %s
// REQUIRES: target={{(aarch64|x86_64)-.*}}