Harini0924 52ae891036
[compiler-rt][test] Add env command to fix command not found errors in compiler-rt with lit internal shell (#105917)
There are several files in the compiler-rt subproject that have command
not found errors. This patch uses the `env` command to properly set the
environment variables correctly when using the lit internal shell.
fixes: #102395 
[This change is relevant [RFC] Enabling the lit internal shell by
Default](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179)
2024-08-25 21:36:34 -07:00

26 lines
769 B
C++

// RUN: %clangxx_nsan -O0 -g %s -o %t
// RUN: env NSAN_OPTIONS=check_nan=true,halt_on_error=0 %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_nsan -O3 -g %s -o %t
// RUN: env NSAN_OPTIONS=check_nan=true,halt_on_error=0 %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_nsan -O0 -g %s -o %t
// RUN: env NSAN_OPTIONS=check_nan=true,halt_on_error=1 not %run %t
#include <cmath>
#include <cstdio>
// This function returns a NaN value for triggering the NaN detection.
__attribute__((noinline)) float ReturnNaN(float p, float q) {
float ret = p / q;
return ret;
// CHECK: WARNING: NumericalStabilitySanitizer: NaN detected
}
int main() {
float val = ReturnNaN(0., 0.);
printf("%f\n", val);
// CHECK: WARNING: NumericalStabilitySanitizer: NaN detected
return 0;
}