From 9e689792b23b017507955dba1a0d21b239d4b869 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Thu, 20 Jul 2017 20:43:39 +0000 Subject: Generate error reports when a fuzz target exits. Summary: Implements https://github.com/google/sanitizers/issues/835. Flush stdout before exiting in test cases. Since the atexit hook is used for exit reports, pending prints to stdout can be lost if they aren't flushed before calling exit(). Expect tests to have non-zero exit code if exit() is called. Reviewers: vitalybuka, kcc Reviewed By: kcc Subscribers: eraman, llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D35602 llvm-svn: 308669 --- llvm/lib/Fuzzer/test/SimpleTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Fuzzer/test/SimpleTest.cpp') diff --git a/llvm/lib/Fuzzer/test/SimpleTest.cpp b/llvm/lib/Fuzzer/test/SimpleTest.cpp index a8b4988dff1..3882a842b88 100644 --- a/llvm/lib/Fuzzer/test/SimpleTest.cpp +++ b/llvm/lib/Fuzzer/test/SimpleTest.cpp @@ -7,6 +7,7 @@ #include #include #include +#include static volatile int Sink; @@ -17,7 +18,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { if (Size > 1 && Data[1] == 'i') { Sink = 2; if (Size > 2 && Data[2] == '!') { - std::cout << "BINGO; Found the target, exiting\n"; + std::cout << "BINGO; Found the target, exiting\n" << std::flush; exit(0); } } -- cgit v1.2.3