Files
clang-p2996/compiler-rt/test/msan/Linux/reexec_unlimited_stack.cpp
Harini0924 2d37e48e24 [compiler-rt][test] Add REQUIRES: shell in tests that use the ulimit command (#105339)
This patch adds the `REQUIRES: shell` directive to six test files that
use the `ulimit` command, ensuring these tests are only run in
environments where a full POSIX-compliant shell is available. The lit
internal shell does not use or support the `ulimit` command, which
causes failures when running tests with `LIT_USE_INTERNAL_SHELL=1 ninja
check-compiler-rt`
Specifically, one of the errors encountered is: 
```
# RUN: at line 4
ulimit -s 1000
# executed command: ulimit -s 1000
# .---command stderr------------
# | 'ulimit': command not found
# `-----------------------------
# error: command failed with exit status: 127
```
Since, the lit internal shell doesn't support `ulimit`, adding this
requirement prevents these tests from failing in the lit internal shell,
thereby improving the reliability of the test suite in environments
where the full shell is not available.

This change is relevant for [[RFC] Enabling the Lit Internal Shell by
Default](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179/3)
fixes:  #102398
2024-08-26 12:02:16 -07:00

25 lines
572 B
C++

// MSAN re-execs on unlimited stacks. We use that to verify ReExec() uses the
// right path.
// REQUIRES: shell
// RUN: %clangxx_msan -O0 %s -o %t && ulimit -s unlimited && %run %t | FileCheck %s
#include <stdio.h>
#if !defined(__GLIBC_PREREQ)
#define __GLIBC_PREREQ(a, b) 0
#endif
#if __GLIBC_PREREQ(2, 16)
#include <sys/auxv.h>
#endif
int main() {
#if __GLIBC_PREREQ(2, 16)
// Make sure AT_EXECFN didn't get overwritten by re-exec.
puts(reinterpret_cast<const char *>(getauxval(AT_EXECFN)));
#else
puts("No getauxval");
#endif
// CHECK-NOT: /proc/self/exe
}