mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-19 21:13:46 +00:00
add regression testing tasks (#664)
This commit is contained in:
16
src/integration-tests/libfuzzer-regression/Makefile
Normal file
16
src/integration-tests/libfuzzer-regression/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
CC=clang
|
||||
|
||||
CFLAGS=-g3 -fsanitize=fuzzer -fsanitize=address
|
||||
|
||||
all: broken.exe fixed.exe
|
||||
|
||||
broken.exe: simple.c
|
||||
$(CC) $(CFLAGS) simple.c -o broken.exe
|
||||
|
||||
fixed.exe: simple.c
|
||||
$(CC) $(CFLAGS) simple.c -o fixed.exe -DFIXED
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f broken.exe fixed.exe
|
@ -0,0 +1 @@
|
||||
good
|
26
src/integration-tests/libfuzzer-regression/simple.c
Normal file
26
src/integration-tests/libfuzzer-regression/simple.c
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t len) {
|
||||
int cnt = 0;
|
||||
|
||||
if (len < 3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (data[0] == 'x') { cnt++; }
|
||||
if (data[1] == 'y') { cnt++; }
|
||||
if (data[2] == 'z') { cnt++; }
|
||||
|
||||
#ifndef FIXED
|
||||
if (cnt >= 3) {
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user