Update IR's helper functions

This commit is contained in:
Jeehoon Kang
2020-04-11 12:20:53 +09:00
parent 6edb4665c0
commit 72ec63ea82
19 changed files with 505 additions and 125 deletions

View File

@@ -23,7 +23,9 @@ REPLACE_DICT = {
"long __undefined;": "",
"return 0;": "return crc32_context % 128;",
r"__attribute__\s*\(\(.*\)\)": "",
"_Float128": "long double",
"_Float128": "double",
"long double": "double",
"(\+[0-9^FL]*)L": r"\1",
"union": "struct",
r"enum[\w\s]*\{[^\}]*\};": "",
r"typedef enum[\w\s]*\{[^;]*;[\s_A-Z]*;": "",
@@ -38,21 +40,23 @@ REPLACE_DICT = {
r"[^\n]*_IO_2_1_[^;]*;": "", # extern을 지우면서 생긴 size를 알 수 없는 struct 삭제
r"__asm\s*\([^\)]*\)": "", # asm extension in mac
r"__asm__\s*\([^\)]*\)": "", # asm extension in linux
"typedef __builtin_va_list __gnuc_va_list;": "",
"typedef __gnuc_va_list va_list;": "",
# To check fuzzer before make kecc support struct type
"struct[^}]*};": "",
" struct[^{]*[^}]*}[^;]*;": "",
"typedef struct _IO_FILE __FILE;": "",
"struct _IO_FILE;": "",
"typedef struct _IO_FILE FILE;": "typedef int FILE;",
"typedef struct _IO_FILE": "typedef int",
"typedef struct __locale_struct": "typedef int",
"typedef __locale_t locale_t;": "typedef int locale_t;",
"struct _IO_FILE_plus;": "",
"typedef _G_fpos_t": "typedef int",
"typedef struct[^\n]*\n{[^}]*}[^;]*;": "",
"typedef struct[^{]{[^}]*}": "typedef int",
"struct _IO_FILE": "int",
# "struct[^}]*};": "",
# " struct[^{]*[^}]*}[^;]*;": "",
# "typedef struct _IO_FILE __FILE;": "",
# "struct _IO_FILE;": "",
# "typedef struct _IO_FILE FILE;": "typedef int FILE;",
# "typedef struct _IO_FILE": "typedef int",
# "typedef struct __locale_struct": "typedef int",
# "typedef __locale_t locale_t;": "typedef int locale_t;",
# "struct _IO_FILE_plus;": "",
# "typedef _G_fpos_t": "typedef int",
# "typedef struct[^\n]*\n{[^}]*}[^;]*;": "",
# "typedef struct[^{]{[^}]*}": "typedef int",
# "struct _IO_FILE": "int",
}
CSMITH_DIR = "csmith-2.3.0"
@@ -229,7 +233,7 @@ def fuzz(tests_dir, fuzz_arg, num_iter):
try:
args = ["cargo", "run", "--release", "--bin", "fuzz", "--", fuzz_arg, os.path.join(tests_dir, "test_polished.c")]
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=tests_dir)
proc.communicate(timeout=10)
proc.communicate(timeout=60)
if proc.returncode != 0:
raise Exception("Test `{}` failed with exit code {}.".format(" ".join(args), proc.returncode))
except subprocess.TimeoutExpired as e: