1REQUIRES: linux 2RUN: %no_fuzzer_cpp_compiler %S/AFLDriverTest.cpp %libfuzzer_src/afl/afl_driver.cpp -o %t-AFLDriverTest 3 4; Test that not specifying AFL_DRIVER_CLOSE_FD_MASK works as intended. 5RUN: echo -n "abc" > %t.file3 6RUN: env -u AFL_DRIVER_CLOSE_FD_MASK %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=STDERR,STDOUT 7STDOUT: STDOUT MESSAGE 8STDERR: STDERR MESSAGE 9 10; Test that stdout is closed properly. 11RUN: env AFL_DRIVER_CLOSE_FD_MASK=1 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDOUT,STDERR 12NOT_STDOUT-NOT: STDOUT MESSAGE 13 14; Test that stderr is closed properly. 15RUN: env AFL_DRIVER_CLOSE_FD_MASK=2 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,STDOUT 16NOT_STDERR-NOT: STDERR MESSAGE 17 18; Test that both are closed properly. 19RUN: env AFL_DRIVER_CLOSE_FD_MASK=3 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,NOT_STDOUT 20 21; Test that a stack is printed when we close stderr 22RUN: echo -n "abcd" > %t.file4 23RUN: env AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4 2>&1 | FileCheck %s --check-prefixes=ASAN_CRASH,STDOUT,NOT_STDERR 24ASAN_CRASH: ERROR: AddressSanitizer 25 26; Test that a stack is written to the stderr duplicate file when we close stderr 27; and specify a duplicate. 28RUN: rm -f %t.stderr 29RUN: env AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t.stderr AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4 30RUN: cat %t.stderr | FileCheck %s --check-prefixes=ASAN_CRASH,NOT_STDERR 31