all repos — mgba @ a90eeea92438672cec7701b46d6756a182f246bf

mGBA Game Boy Advance Emulator

Test: Rearrange fuzz-main for AFL additions
Jeffrey Pfau jeffrey@endrift.com
Mon, 05 Oct 2015 19:22:44 -0700
commit

a90eeea92438672cec7701b46d6756a182f246bf

parent

d490f9a013a1a76856dfc8f83e0b10637eab86f0

1 files changed, 18 insertions(+), 11 deletions(-)

jump to
M src/platform/test/fuzz-main.csrc/platform/test/fuzz-main.c

@@ -68,18 +68,9 @@ GBAContextDeinit(&context);

return !parsed; } - struct VFile* rom = VFileOpen(args.fname, O_RDONLY); - - context.gba->hardCrash = false; - GBAContextLoadROMFromVFile(&context, rom, 0); - struct GBAVideoSoftwareRenderer renderer; renderer.outputBuffer = 0; - struct VFile* savestate = 0; - struct VFile* savestateOverlay = 0; - size_t overlayOffset; - if (!fuzzOpts.noVideo) { GBAVideoSoftwareRendererCreate(&renderer); renderer.outputBuffer = malloc(256 * 256 * 4);

@@ -87,6 +78,19 @@ renderer.outputBufferStride = 256;

context.renderer = &renderer.d; } +#ifdef __AFL_HAVE_MANUAL_CONTROL + __AFL_INIT(); +#endif + + struct VFile* rom = VFileOpen(args.fname, O_RDONLY); + + context.gba->hardCrash = false; + GBAContextLoadROMFromVFile(&context, rom, 0); + + struct VFile* savestate = 0; + struct VFile* savestateOverlay = 0; + size_t overlayOffset; + GBAContextStart(&context); if (fuzzOpts.savestate) {

@@ -121,18 +125,21 @@ blip_set_rates(context.gba->audio.right, GBA_ARM7TDMI_FREQUENCY, 0x8000);

_GBAFuzzRunloop(&context, fuzzOpts.frames); + GBAContextStop(&context); + GBAContextUnloadROM(&context); + if (savestate) { savestate->close(savestate); } if (savestateOverlay) { savestateOverlay->close(savestateOverlay); } - GBAContextStop(&context); - GBAContextDeinit(&context); + freeArguments(&args); if (renderer.outputBuffer) { free(renderer.outputBuffer); } + GBAContextDeinit(&context); return 0; }