Skip to content

Commit 42d06b8

Browse files
authored
[compiler-rt][test] Change tests to remove the use of unset command in lit internal shell (#104880)
This patch rewrites tests to remove the use of the `unset` command, which is not supported in the lit internal shell. The tests now use the `env -u` to unset environment variables. The `unset` command is used in shell environments to remove the environment variable. However, because the lit internal shell does not support the `unset` command, using it in tests would result in errors or other unexpected behavior. To overcome this limitation, the tests have been updated to use the `env -u` command instead. `env -u` is supported by lit and effectively removes specified environment variables. This allows the tests to achieve the same goal of unsetting environment variables while ensuring compatibility with the lit internal shell. 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: #102397
1 parent 8b5f606 commit 42d06b8

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

compiler-rt/test/fuzzer/afl-driver-close-fd-mask.test

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@ RUN: %no_fuzzer_cpp_compiler %S/AFLDriverTest.cpp %libfuzzer_src/afl/afl_driver.
33

44
; Test that not specifying AFL_DRIVER_CLOSE_FD_MASK works as intended.
55
RUN: echo -n "abc" > %t.file3
6-
RUN: unset AFL_DRIVER_CLOSE_FD_MASK
7-
RUN: %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=STDERR,STDOUT
6+
RUN: env -u AFL_DRIVER_CLOSE_FD_MASK %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=STDERR,STDOUT
87
STDOUT: STDOUT MESSAGE
98
STDERR: STDERR MESSAGE
109

1110
; Test that stdout is closed properly.
12-
RUN: AFL_DRIVER_CLOSE_FD_MASK=1 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDOUT,STDERR
11+
RUN: env AFL_DRIVER_CLOSE_FD_MASK=1 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDOUT,STDERR
1312
NOT_STDOUT-NOT: STDOUT MESSAGE
1413

1514
; Test that stderr is closed properly.
16-
RUN: AFL_DRIVER_CLOSE_FD_MASK=2 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,STDOUT
15+
RUN: env AFL_DRIVER_CLOSE_FD_MASK=2 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,STDOUT
1716
NOT_STDERR-NOT: STDERR MESSAGE
1817

1918
; Test that both are closed properly.
20-
RUN: AFL_DRIVER_CLOSE_FD_MASK=3 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,NOT_STDOUT
19+
RUN: env AFL_DRIVER_CLOSE_FD_MASK=3 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,NOT_STDOUT
2120

2221
; Test that a stack is printed when we close stderr
2322
RUN: echo -n "abcd" > %t.file4
24-
RUN: AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4 2>&1 | FileCheck %s --check-prefixes=ASAN_CRASH,STDOUT,NOT_STDERR
23+
RUN: env AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4 2>&1 | FileCheck %s --check-prefixes=ASAN_CRASH,STDOUT,NOT_STDERR
2524
ASAN_CRASH: ERROR: AddressSanitizer
2625

2726
; Test that a stack is written to the stderr duplicate file when we close stderr
2827
; and specify a duplicate.
2928
RUN: rm -f %t.stderr
30-
RUN: AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t.stderr AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4
29+
RUN: env AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t.stderr AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4
3130
RUN: cat %t.stderr | FileCheck %s --check-prefixes=ASAN_CRASH,NOT_STDERR

compiler-rt/test/fuzzer/afl-driver-stderr.test

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ XFAIL: ios
44
RUN: %no_fuzzer_cpp_compiler %S/AFLDriverTest.cpp %libfuzzer_src/afl/afl_driver.cpp -o %t-AFLDriverTest
55

66
; Test that not specifying a stderr file isn't broken.
7-
RUN: unset AFL_DRIVER_STDERR_DUPLICATE_FILENAME
8-
RUN: %run %t-AFLDriverTest
7+
RUN: env -u AFL_DRIVER_STDERR_DUPLICATE_FILENAME %run %t-AFLDriverTest
98

109
; Test that specifying an invalid file causes a crash.
11-
RUN: ASAN_OPTIONS= AFL_DRIVER_STDERR_DUPLICATE_FILENAME="%T" not --crash %run %t-AFLDriverTest
10+
RUN: env ASAN_OPTIONS= AFL_DRIVER_STDERR_DUPLICATE_FILENAME="%T" not --crash %run %t-AFLDriverTest
1211

1312
; Test that a file is created when specified as the duplicate stderr.
14-
RUN: AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t %run %t-AFLDriverTest
13+
RUN: env AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t %run %t-AFLDriverTest
1514
RUN: stat %t

0 commit comments

Comments
 (0)