• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: unset AFL_DRIVER_CLOSE_FD_MASK
7RUN: %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=STDERR,STDOUT
8STDOUT: STDOUT MESSAGE
9STDERR: STDERR MESSAGE
10
11; Test that stdout is closed properly.
12RUN: AFL_DRIVER_CLOSE_FD_MASK=1 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDOUT,STDERR
13NOT_STDOUT-NOT: STDOUT MESSAGE
14
15; Test that stderr is closed properly.
16RUN: AFL_DRIVER_CLOSE_FD_MASK=2 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,STDOUT
17NOT_STDERR-NOT: STDERR MESSAGE
18
19; Test that both are closed properly.
20RUN: AFL_DRIVER_CLOSE_FD_MASK=3 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,NOT_STDOUT
21
22; Test that a stack is printed when we close stderr
23RUN: echo -n "abcd" > %t.file4
24RUN: AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4 2>&1  | FileCheck %s --check-prefixes=ASAN_CRASH,STDOUT,NOT_STDERR
25ASAN_CRASH: ERROR: AddressSanitizer
26
27; Test that a stack is written to the stderr duplicate file when we close stderr
28; and specify a duplicate.
29RUN: rm -f %t.stderr
30RUN: AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t.stderr AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4
31RUN: cat %t.stderr | FileCheck %s --check-prefixes=ASAN_CRASH,NOT_STDERR
32