~ubuntu-branches/ubuntu/trusty/emscripten/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/fuzz/csmith_driver.py

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20140119141240-jg1l42cc158j59tn
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
CSMITH_PATH should be set to something like /usr/local/include/csmith
7
7
'''
8
8
 
9
 
import os, sys, difflib, shutil
 
9
import os, sys, difflib, shutil, random
10
10
from distutils.spawn import find_executable
11
11
from subprocess import check_call, Popen, PIPE, STDOUT, CalledProcessError
12
12
 
13
 
sys.path += [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'tools')]
 
13
sys.path += [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'tools')]
14
14
import shared
15
15
 
16
16
engine1 = eval('shared.' + sys.argv[1]) if len(sys.argv) > 1 else shared.JS_ENGINES[0]
35
35
fails = 0
36
36
 
37
37
while 1:
 
38
  opts = '-O' + str(random.randint(0, 2))
 
39
  print 'opt level:', opts
 
40
 
38
41
  print 'Tried %d, notes: %s' % (tried, notes)
39
42
  print '1) Generate C'
40
 
  check_call([CSMITH, '--no-volatiles', '--no-math64', '--no-packed-struct'],# +
 
43
  check_call([CSMITH, '--no-volatiles', '--no-packed-struct'],# '--no-math64'
41
44
                 #['--max-block-depth', '2', '--max-block-size', '2', '--max-expr-complexity', '2', '--max-funcs', '2'],
42
45
                 stdout=open(filename + '.c', 'w'))
43
46
  #shutil.copyfile(filename + '.c', 'testcase%d.c' % tried)
47
50
 
48
51
  print '2) Compile natively'
49
52
  shared.try_delete(filename)
50
 
  shared.check_execute([shared.CLANG_CC, '-O2', filename + '.c', '-o', filename + '1'] + CSMITH_CFLAGS) #  + shared.EMSDK_OPTS
51
 
  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)
 
53
  shared.check_execute([shared.CLANG_CC, opts, filename + '.c', '-o', filename + '1'] + CSMITH_CFLAGS) #  + shared.EMSDK_OPTS
 
54
  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)
52
55
  shared.check_execute([shared.path_from_root('tools', 'nativize_llvm.py'), filename + '.bc'])
53
56
  shutil.move(filename + '.bc.run', filename + '2')
54
57
  shared.check_execute([shared.CLANG_CC, filename + '.c', '-o', filename + '3'] + CSMITH_CFLAGS)
71
74
  def try_js(args):
72
75
    shared.try_delete(filename + '.js')
73
76
    print '(compile)'
74
 
    shared.check_execute([shared.EMCC, '-O2', '-s', 'ASM_JS=1', filename + '.c', '-o', filename + '.js'] + CSMITH_CFLAGS + args)
 
77
    shared.check_execute([shared.EMCC, opts, filename + '.c', '-o', filename + '.js'] + CSMITH_CFLAGS + args)
75
78
    assert os.path.exists(filename + '.js')
76
79
    print '(run)'
77
80
    js = shared.run_js(filename + '.js', stderr=PIPE, engine=engine1, check_timeout=True)