isa-l/tests/fuzz/igzip_dump_inflate_corpus.c
Greg Tucker 4f59eeda90 test: Add llvm fuzz testing
Moved the afl fuzz test and added llvm fuzz tests including inflate
and round trip compress and inflate.  Currently only works with clang,
std makefile and libFuzzer installed.  Need to add checking and
support later when libfuzzer is more tightly integrated into the
compiler.

Change-Id: I2db9ad2335d6c5ed846886703b58225f67bcc935
Signed-off-by: Greg Tucker <greg.b.tucker@intel.com>
2017-11-17 17:28:27 -07:00

38 lines
844 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "inflate_std_vects.h"
#define FNAME_MAX 180
int main(int argc, char *argv[])
{
uint8_t *buf;
int i, len, err;
FILE *fout = NULL;
char fname[FNAME_MAX];
char dname[FNAME_MAX];
if (argc != 2) {
fprintf(stderr, "Usage: %s <outdir>\n", argv[0]);
exit(1);
}
strncpy(dname, argv[1], FNAME_MAX);
for (i = 0; i < sizeof(std_vect_array) / sizeof(struct vect_result); i++) {
buf = std_vect_array[i].vector;
len = std_vect_array[i].vector_length;
err = std_vect_array[i].expected_error;
snprintf(fname, FNAME_MAX, "%s/inflate_corp_n%03d_e%d", dname, i, err);
printf(" writing %s\n", fname);
fout = fopen(fname, "w+");
if (!fout) {
fprintf(stderr, "Can't open %s for writing\n", fname);
exit(1);
}
fwrite(buf, len, 1, fout);
fclose(fout);
}
}