Add fuzzer for the terminal

This commit adds a fuzzer for more of the terminal pipeline, adding
coverage for the input and output portions of the terminal
framebuffer.
This commit is contained in:
Alex Chernyakhovsky
2022-05-30 20:01:52 -04:00
committed by Alex Chernyakhovsky
parent 0c6e034459
commit adb62e97ff
18 changed files with 33 additions and 1 deletions
+5 -1
View File
@@ -1,7 +1,11 @@
AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CFLAGS) $(MISC_CXXFLAGS) $(CODE_COVERAGE_CXXFLAGS) $(FUZZING_CFLAGS)
noinst_PROGRAMS = terminal_parser_fuzzer
noinst_PROGRAMS = terminal_parser_fuzzer terminal_fuzzer
terminal_parser_fuzzer_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util
terminal_parser_fuzzer_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a
terminal_parser_fuzzer_SOURCES = terminal_parser_fuzzer.cc
terminal_fuzzer_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util -I$(srcdir)/../statesync -I../protobufs
terminal_fuzzer_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a ../statesync/libmoshstatesync.a ../protobufs/libmoshprotos.a $(TINFO_LIBS) $(protobuf_LIBS)
terminal_fuzzer_SOURCES = terminal_fuzzer.cc
@@ -0,0 +1 @@
&:#
@@ -0,0 +1,3 @@
@
@@ -0,0 +1,2 @@
@
@@ -0,0 +1 @@
+17
View File
@@ -0,0 +1,17 @@
#include <cstddef>
#include <cstdint>
#include "parser.h"
#include "completeterminal.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
Terminal::Display display(false);
Terminal::Complete complete(80, 24);
Terminal::Framebuffer state(80, 24);
for (size_t i = 0; i < size; i++) {
complete.act(Parser::UserByte(data[i]));
}
display.new_frame(true, state, complete.get_fb());
return 0;
}