Fix hw1 fuzzer

This commit is contained in:
Jeehoon Kang
2020-03-26 22:59:02 +09:00
parent 8938a7ad8f
commit 938390821f
7 changed files with 178 additions and 69 deletions

2
tests/.gitignore vendored
View File

@@ -1,4 +1,4 @@
/platform.info
/csmith-*
/test*.c*
/test*.c
/reduce-criteria.sh

View File

@@ -22,13 +22,18 @@ REPLACE_DICT = {
"__restrict": "",
"long __undefined;": "",
"return 0;": "return crc32_context % 128;",
r"__attribute__ \(\(.*\)\)": "",
r"__attribute__\s*\(\(.*\)\)": "",
"_Float128": "long double",
"union": "struct",
r"enum\s*\{[^\}]*\};": "",
r"enum[\w\s]*\{[^\}]*\};": "",
"const char \*const sys_errlist\[\];": "",
r"[^\n]*printf[^;]*;": "",
r"[^\n]*scanf[^;]*;": "",
" restrict": "",
"inline ": "",
"_Nullable": "",
"\"g_\w*\", ": "",
"char\* vname, ": "",
}
CSMITH_DIR = "csmith-2.3.0"
@@ -172,7 +177,8 @@ def creduce(tests_dir, fuzz_arg):
raise e
try:
args = ["creduce", "./reduce-criteria.sh", "test_reduced.c"]
# --tidy: Do not make a backup copy of each file to reduce as file.orig
args = ["creduce", "--tidy", "./reduce-criteria.sh", "test_reduced.c"]
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=tests_dir)
(out, err) = proc.communicate()
if proc.returncode != 0:

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash
cargo run --manifest-path $PROJECT_DIR/Cargo.toml --release -- -p test_reduced.c >/dev/null 2>&1 &&\
! cargo run --manifest-path $PROJECT_DIR/Cargo.toml --release --bin fuzz -- $FUZZ_ARG test_reduced.c