aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-20 19:34:51 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-20 19:34:51 -0800
commit5e651e7c99f088dd9d1d116ab463ee3493afcc69 (patch)
tree9f01127fa0b1c927089ad035a13cf0a52dd22d2c /tests
parentd48f314a993ab1bef1d0be3d7b142d2f4fc5ad56 (diff)
randomize opt level in csmith driver
Diffstat (limited to 'tests')
-rwxr-xr-xtests/fuzz/csmith_driver.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/fuzz/csmith_driver.py b/tests/fuzz/csmith_driver.py
index ecf5d2dc..da0a3de3 100755
--- a/tests/fuzz/csmith_driver.py
+++ b/tests/fuzz/csmith_driver.py
@@ -6,7 +6,7 @@ Runs csmith, a C fuzzer, and looks for bugs.
CSMITH_PATH should be set to something like /usr/local/include/csmith
'''
-import os, sys, difflib, shutil
+import os, sys, difflib, shutil, random
from distutils.spawn import find_executable
from subprocess import check_call, Popen, PIPE, STDOUT, CalledProcessError
@@ -35,6 +35,9 @@ notes = { 'invalid': 0, 'unaligned': 0, 'embug': 0 }
fails = 0
while 1:
+ opts = '-O' + str(random.randint(0, 2))
+ print 'opt level:', opts
+
print 'Tried %d, notes: %s' % (tried, notes)
print '1) Generate C'
check_call([CSMITH, '--no-volatiles', '--no-math64', '--no-packed-struct'],# +
@@ -47,8 +50,8 @@ while 1:
print '2) Compile natively'
shared.try_delete(filename)
- shared.check_execute([shared.CLANG_CC, '-O2', filename + '.c', '-o', filename + '1'] + CSMITH_CFLAGS) # + shared.EMSDK_OPTS
- shared.check_execute([shared.CLANG_CC, '-O2', '-emit-llvm', '-c', '-Xclang', '-triple=i386-pc-linux-gnu', filename + '.c', '-o', filename + '.bc'] + CSMITH_CFLAGS + shared.EMSDK_OPTS)
+ shared.check_execute([shared.CLANG_CC, opts, filename + '.c', '-o', filename + '1'] + CSMITH_CFLAGS) # + shared.EMSDK_OPTS
+ shared.check_execute([shared.CLANG_CC, opts, '-emit-llvm', '-c', '-Xclang', '-triple=i386-pc-linux-gnu', filename + '.c', '-o', filename + '.bc'] + CSMITH_CFLAGS + shared.EMSDK_OPTS)
shared.check_execute([shared.path_from_root('tools', 'nativize_llvm.py'), filename + '.bc'])
shutil.move(filename + '.bc.run', filename + '2')
shared.check_execute([shared.CLANG_CC, filename + '.c', '-o', filename + '3'] + CSMITH_CFLAGS)
@@ -71,7 +74,7 @@ while 1:
def try_js(args):
shared.try_delete(filename + '.js')
print '(compile)'
- shared.check_execute([shared.EMCC, '-O2', '-s', 'ASM_JS=1', filename + '.c', '-o', filename + '.js'] + CSMITH_CFLAGS + args)
+ shared.check_execute([shared.EMCC, opts, '-s', 'ASM_JS=1', filename + '.c', '-o', filename + '.js'] + CSMITH_CFLAGS + args)
assert os.path.exists(filename + '.js')
print '(run)'
js = shared.run_js(filename + '.js', stderr=PIPE, engine=engine1, check_timeout=True)