When running tests in compiler-rt using the lit internal shell with the following command: ``` LIT_USE_INTERNAL_SHELL=1 ninja check-compiler-rt ``` one common error that occurs is: ``` 'XRAY_OPTIONS=patch_premain=false:verbosity=1': command not found ``` This error, along with over 50 similar "environment variable not found" errors, appears across 35 files in complier-rt. These errors happen because the environment variables are not being set correctly when the internal shell is used, leading to commands failing due to unrecognized environment variables. This patch addresses the issue by using the `env` command to properly set the environment variables before running the tests. By explicitly setting the environment variables through `env`, the internal shell can correctly interpret and apply them, allowing the tests to pass. fixes: #102395 [link to RFC](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179)
29 lines
1.3 KiB
C++
29 lines
1.3 KiB
C++
// Test various levels of coverage
|
|
//
|
|
// RUN: %clangxx_msan -DINIT_VAR=1 -O1 -fsanitize-coverage=func,trace-pc-guard %s -o %t
|
|
// RUN: mkdir -p %t-dir
|
|
// RUN: env MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
|
|
// RUN: %clangxx_msan -O1 -fsanitize-coverage=func,trace-pc-guard %s -o %t
|
|
// RUN: env MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
|
|
// RUN: %clangxx_msan -O1 -fsanitize-coverage=bb,trace-pc-guard %s -o %t
|
|
// RUN: env MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
|
|
// RUN: %clangxx_msan -O1 -fsanitize-coverage=edge,trace-pc-guard %s -o %t
|
|
// RUN: env MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
|
|
|
|
volatile int sink;
|
|
int main(int argc, char **argv) {
|
|
int var;
|
|
#if INIT_VAR
|
|
var = 0;
|
|
#endif
|
|
if (argc == 0)
|
|
sink = 0;
|
|
return *(volatile int*)&var;
|
|
}
|
|
|
|
// CHECK_WARN: WARNING: MemorySanitizer: use-of-uninitialized-value
|
|
// CHECK_NOWARN-NOT: ERROR
|
|
// CHECK1: 1 PCs written
|
|
// CHECK2: 1 PCs written
|
|
// CHECK3: 2 PCs written
|