mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[libFuzzer] print stats if we crash on empty input
llvm-svn: 270639
This commit is contained in:
parent
9b2e9d0752
commit
10bbd18b43
@ -177,9 +177,10 @@ void Fuzzer::DumpCurrentUnit(const char *Prefix) {
|
||||
|
||||
NO_SANITIZE_MEMORY
|
||||
void Fuzzer::DeathCallback() {
|
||||
if (!CurrentUnitSize) return;
|
||||
Printf("DEATH:\n");
|
||||
DumpCurrentUnit("crash-");
|
||||
if (CurrentUnitSize) {
|
||||
Printf("DEATH:\n");
|
||||
DumpCurrentUnit("crash-");
|
||||
}
|
||||
PrintFinalStats();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ set(Tests
|
||||
LeakTest
|
||||
LeakTimeoutTest
|
||||
NullDerefTest
|
||||
NullDerefOnEmptyTest
|
||||
NthRunCrashTest
|
||||
OutOfMemoryTest
|
||||
RepeatedMemcmp
|
||||
|
19
lib/Fuzzer/test/NullDerefOnEmptyTest.cpp
Normal file
19
lib/Fuzzer/test/NullDerefOnEmptyTest.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
|
||||
// Simple test for a fuzzer. The fuzzer must find the empty string.
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
|
||||
static volatile int *Null = 0;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
if (Size == 0) {
|
||||
std::cout << "Found the target, dereferencing NULL\n";
|
||||
*Null = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ LIBFUZZER_OWN_SEGV_HANDLER: == ERROR: libFuzzer: deadly signal
|
||||
LIBFUZZER_OWN_SEGV_HANDLER: SUMMARY: libFuzzer: deadly signal
|
||||
LIBFUZZER_OWN_SEGV_HANDLER: Test unit written to ./crash-
|
||||
|
||||
RUN: not LLVMFuzzer-NullDerefOnEmptyTest -print_final_stats=1 2>&1 | FileCheck %s --check-prefix=NULL_DEREF_ON_EMPTY
|
||||
NULL_DEREF_ON_EMPTY: stat::number_of_executed_units:
|
||||
|
||||
#not LLVMFuzzer-FullCoverageSetTest -timeout=15 -seed=1 -mutate_depth=2 -use_full_coverage_set=1 2>&1 | FileCheck %s
|
||||
|
||||
RUN: not LLVMFuzzer-CounterTest -use_counters=1 -max_len=6 -seed=1 -timeout=15 2>&1 | FileCheck %s
|
||||
|
Loading…
Reference in New Issue
Block a user