diff options
Diffstat (limited to 'tests/fuzz/csmith_driver.py')
-rwxr-xr-x | tests/fuzz/csmith_driver.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/fuzz/csmith_driver.py b/tests/fuzz/csmith_driver.py index 404324a2..6c6965df 100755 --- a/tests/fuzz/csmith_driver.py +++ b/tests/fuzz/csmith_driver.py @@ -26,13 +26,18 @@ tried = 0 notes = { 'invalid': 0, 'unaligned': 0, 'embug': 0 } +fails = 0 + while 1: print 'Tried %d, notes: %s' % (tried, notes) - tried += 1 print '1) Generate C' - shared.execute([CSMITH, '--no-volatiles', '--no-math64', '--no-packed-struct'] + - ['--max-block-depth', '2', '--max-block-size', '2', '--max-expr-complexity', '2', '--max-funcs', '2'], + shared.execute([CSMITH, '--no-volatiles', '--no-math64', '--no-packed-struct'],# + + #['--max-block-depth', '2', '--max-block-size', '2', '--max-expr-complexity', '2', '--max-funcs', '2'], stdout=open(filename + '.c', 'w')) + #shutil.copyfile(filename + '.c', 'testcase%d.c' % tried) + print '1) Generate C... %.2f K of C source' % (len(open(filename + '.c').read())/1024.) + + tried += 1 print '2) Compile natively' shared.try_delete(filename) @@ -40,12 +45,16 @@ while 1: shared.execute([shared.CLANG_CC, '-O2', '-emit-llvm', '-c', '-Xclang', '-triple=i386-pc-linux-gnu', filename + '.c', '-o', filename + '.bc'] + CSMITH_CFLAGS + shared.EMSDK_OPTS, stderr=PIPE) shared.execute([shared.path_from_root('tools', 'nativize_llvm.py'), filename + '.bc'], stdout=PIPE, stderr=PIPE) shutil.move(filename + '.bc.run', filename + '2') + shared.execute([shared.CLANG_CC, filename + '.c', '-o', filename + '3'] + CSMITH_CFLAGS, stderr=PIPE) print '3) Run natively' try: correct1 = shared.timeout_run(Popen([filename + '1'], stdout=PIPE, stderr=PIPE), 3) if 'Segmentation fault' in correct1 or len(correct1) < 10: raise Exception('segfault') correct2 = shared.timeout_run(Popen([filename + '2'], stdout=PIPE, stderr=PIPE), 3) if 'Segmentation fault' in correct2 or len(correct2) < 10: raise Exception('segfault') + correct3 = shared.timeout_run(Popen([filename + '3'], stdout=PIPE, stderr=PIPE), 3) + if 'Segmentation fault' in correct3 or len(correct3) < 10: raise Exception('segfault') + if correct1 != correct3: raise Exception('clang opts change result') except Exception, e: print 'Failed or infinite looping in native, skipping', e notes['invalid'] += 1 @@ -75,10 +84,15 @@ while 1: except Exception, e: print e normal = False + #open('testcase%d.js' % tried, 'w').write( + # open(filename + '.js').read().replace(' var ret = run();', ' var ret = run(["1"]);') + #) if not ok: print "EMSCRIPTEN BUG" notes['embug'] += 1 - break + fails += 1 + shutil.copyfile('fuzzcode.c', 'newfail%d.c' % fails) + continue #if not ok: # try: # finally, try with safe heap. if that is triggered, this is nonportable code almost certainly # try_js(['-s', 'SAFE_HEAP=1']) |