Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
| 2 | 2 |
| 3 #===- subzero/wasm-run-torture-tests.py - Subzero WASM Torture Test Driver ===// | 3 #===- subzero/wasm-run-torture-tests.py - Subzero WASM Torture Test Driver ===// |
| 4 # | 4 # |
| 5 # The Subzero Code Generator | 5 # The Subzero Code Generator |
| 6 # | 6 # |
| 7 # This file is distributed under the University of Illinois Open Source | 7 # This file is distributed under the University of Illinois Open Source |
| 8 # License. See LICENSE.TXT for details. | 8 # License. See LICENSE.TXT for details. |
| 9 # | 9 # |
| 10 #===-----------------------------------------------------------------------===// | 10 #===-----------------------------------------------------------------------===// |
| 11 | 11 |
| 12 from __future__ import print_function | |
| 13 import argparse | |
| 12 import glob | 14 import glob |
| 15 import multiprocessing | |
| 13 import os | 16 import os |
| 17 import Queue | |
| 14 import shutil | 18 import shutil |
| 19 import StringIO | |
| 15 import sys | 20 import sys |
| 21 import threading | |
| 16 | 22 |
| 17 IGNORED_TESTS = [ | 23 IGNORED_TESTS = set([ |
| 18 'loop-2f.c.wasm', # mmap not in MVP | 24 'loop-2f.c.wasm', # mmap not in MVP |
| 19 'loop-2g.c.wasm', # mmap not in MVP | 25 'loop-2g.c.wasm', # mmap not in MVP |
| 20 | 26 |
| 21 '960521-1.c.wasm', # sbrk not in MVP | 27 '960521-1.c.wasm', # sbrk |
| 28 'ipa-sra-2.c.wasm', # sbrk | |
| 29 'pr41463.c.wasm', # sbrk | |
| 30 '20051113-1.c.wasm', # sbrk | |
| 31 '990628-1.c.wasm', # sbrk | |
| 32 'pr41395-2.c.wasm', # sbrk | |
| 33 'pr42614.c.wasm', # sbrk | |
| 34 'pr41395-1.c.wasm', # sbrk | |
| 35 '920810-1.c.wasm', # sbrk | |
| 36 '20000914-1.c.wasm', # sbrk | |
| 37 'pr15262-1.c.wasm', # sbrk | |
| 38 '941014-2.c.wasm', # sbrk | |
| 39 'va-arg-21.c.wasm', # sbrk | |
| 40 '20020406-1.c.wasm', # sbrk | |
| 22 | 41 |
| 23 'pr36765.c.wasm', # __builtin_malloc not allowed | 42 # waterfall known failures |
| 43 '20010122-1.c.wasm', | |
| 44 '20031003-1.c.wasm', | |
| 45 '20071018-1.c.wasm', | |
| 46 '20071120-1.c.wasm', | |
| 47 '20071220-1.c.wasm', | |
| 48 '20071220-2.c.wasm', | |
| 49 '20101011-1.c.wasm', | |
| 50 'alloca-1.c.wasm', | |
| 51 'bitfld-3.c.wasm', | |
| 52 'bitfld-5.c.wasm', | |
| 53 'builtin-bitops-1.c.wasm', | |
| 54 'conversion.c.wasm', | |
| 55 'eeprof-1.c.wasm', | |
| 56 'frame-address.c.wasm', | |
| 57 'pr17377.c.wasm', | |
| 58 'pr32244-1.c.wasm', | |
| 59 'pr34971.c.wasm', | |
| 60 'pr36765.c.wasm', | |
| 61 'pr39228.c.wasm', | |
| 62 'pr43008.c.wasm', | |
| 63 'pr47237.c.wasm', | |
| 64 'pr60960.c.wasm', | |
| 65 'va-arg-pack-1.c.wasm', | |
| 24 | 66 |
| 25 'pr24716.c.wasm', # infinite loop | 67 '20000717-5.c.wasm', # abort() (also works without emcc) |
| 26 'vla-dealloc-1.c.wasm', # infinite loop | 68 '20001203-2.c.wasm', # assert fail (works without emcc) |
| 27 '20040811-1.c.wasm', # infinite loop | 69 '20040811-1.c.wasm', # OOB trap |
| 28 '961125-1.c.wasm', # infinite loop | 70 '20070824-1.c.wasm', # abort() (also works without emcc) |
| 29 '980506-1.c.wasm', # infinite loop | 71 'arith-rand-ll.c.wasm', # abort() (works without emcc) |
| 30 '20070824-1.c.wasm', # infinite loop | 72 'arith-rand.c.wasm', # abort() (works without emcc) |
| 31 '20140212-1.c.wasm', # infinite loop | 73 'pr23135.c.wasm', # OOB trap (works without emcc) |
| 32 'pr59014.c.wasm', # infinite loop | 74 'pr34415.c.wasm', # (empty output?) |
| 33 'pr58277-2.c.wasm', # infinite loop | 75 'pr36339.c.wasm', # abort() (works without emcc) |
| 34 'pr43560.c.wasm', # infinite loop | 76 'pr38048-2.c.wasm', # abort() (works without emcc) |
| 35 '20000818-1.c.wasm', # infinite loop | 77 'pr42691.c.wasm', # abort() (works without emcc) |
| 36 '20010409-1.c.wasm', # infinite loop | 78 'pr43220.c.wasm', # OOB trap (works without emcc) |
| 37 'loop-7.c.wasm', # infinite loop | 79 'pr43269.c.wasm', # abort() (works without emcc) |
| 38 'pr34415.c.wasm', # infinite loop | 80 'vla-dealloc-1.c.wasm', # OOB trap (works without emcc) |
| 39 '20011126-2.c.wasm', # infinite loop | 81 '20051012-1.c.wasm', # error reading binary |
| 40 'postmod-1.c.wasm', # infinite loop | 82 '921208-2.c.wasm', # error reading binary |
| 41 'pr17133.c.wasm', # infinite loop | 83 '920501-1.c.wasm', # error reading binary |
| 42 '20021024-1.c.wasm', # infinite loop | 84 'call-trap-1.c.wasm', # error reading binary |
| 43 'pr15296.c.wasm', # infinite loop | 85 'pr44942.c.wasm', # error reading binary |
| 44 '990524-1.c.wasm', # infinite loop | 86 |
| 45 'loop-12.c.wasm', # infinite loop | 87 '920625-1.c.wasm', # abort() (also fails without emcc) |
| 46 '961125-1.c.wasm', # infinite loop | 88 '931004-10.c.wasm', # abort() (also fails without emcc) |
| 47 ] | 89 '931004-12.c.wasm', # abort() (also fails without emcc) |
| 90 '931004-14.c.wasm', # abort() (also fails without emcc) | |
| 91 '931004-6.c.wasm', # abort() (also fails without emcc) | |
| 92 'pr38051.c.wasm', # (empty output?) (fails without emcc) | |
| 93 'pr38151.c.wasm', # abort() (fails without emcc) | |
| 94 'pr44575.c.wasm', # abort() (fails without emcc) | |
| 95 'strct-stdarg-1.c.wasm', # abort() (fails without emcc) | |
| 96 'strct-varg-1.c.wasm', # abort() (fails without emcc) | |
| 97 'va-arg-22.c.wasm', # abort() (fails without emcc) | |
| 98 'stdarg-3.c.wasm', # abort() (fails without emcc) | |
| 99 'pr56982.c.wasm', # missing setjmp (wasm.js check did not catch) | |
| 100 | |
| 101 '20010605-2.c.wasm', # missing __netf2 | |
| 102 '20020413-1.c.wasm', # missing __lttf2 | |
| 103 '20030914-1.c.wasm', # missing __floatsitf | |
| 104 '20040709-1.c.wasm', # missing __netf2 | |
| 105 '20040709-2.c.wasm', # missing __netf2 | |
| 106 '20050121-1.c.wasm', # missing __floatsitf | |
| 107 '20080502-1.c.wasm', # missing __eqtf2 | |
| 108 '920501-8.c.wasm', # missing __extenddftf2 | |
| 109 '930513-1.c.wasm', # missing __extenddftf2 | |
| 110 '930622-2.c.wasm', # missing __floatditf | |
| 111 '960215-1.c.wasm', # missing __addtf3 | |
| 112 '960405-1.c.wasm', # missing __eqtf2 | |
| 113 '960513-1.c.wasm', # missing __subtf3 | |
| 114 'align-2.c.wasm', # missing __eqtf2 | |
| 115 'complex-6.c.wasm', # missing __subtf3 | |
| 116 'complex-7.c.wasm', # missing __netf2 | |
| 117 'pr49218.c.wasm', # missing __fixsfti | |
| 118 'pr54471.c.wasm', # missing __multi3 | |
| 119 'regstack-1.c.wasm', # missing __addtf3 | |
| 120 'stdarg-1.c.wasm', # missing __netf2 | |
| 121 'stdarg-2.c.wasm', # missing __floatsitf | |
| 122 'va-arg-5.c.wasm', # missing __eqtf2 | |
| 123 'va-arg-6.c.wasm', # missing __eqtf2 | |
| 124 'struct-ret-1.c.wasm', # missing __extenddftf2 | |
| 125 ]) | |
| 126 | |
| 127 parser = argparse.ArgumentParser() | |
| 128 parser.add_argument('-v', '--verbose', action='store_true') | |
| 129 parser.add_argument('--translate-only', action='store_true') | |
| 130 parser.add_argument('tests', nargs='*') | |
| 131 args = parser.parse_args() | |
| 48 | 132 |
| 49 OUT_DIR = "./build/wasm-torture" | 133 OUT_DIR = "./build/wasm-torture" |
| 50 | 134 |
| 135 results_lock = threading.Lock() | |
| 136 | |
| 51 compile_count = 0 | 137 compile_count = 0 |
| 52 compile_failures = [] | 138 compile_failures = [] |
| 53 | 139 |
| 54 run_count = 0 | 140 run_count = 0 |
| 55 run_failures = [] | 141 run_failures = [] |
| 56 | 142 |
| 57 def run_test(test_file, verbose=False): | 143 def run_test(test_file, verbose=False): |
| 144 global args | |
| 58 global compile_count | 145 global compile_count |
| 59 global compile_failures | 146 global compile_failures |
| 147 global results_lock | |
| 60 global run_count | 148 global run_count |
| 61 global run_failures | 149 global run_failures |
| 62 global OUT_DIR | 150 global OUT_DIR |
| 63 global IGNORED_TESTS | 151 global IGNORED_TESTS |
| 64 | 152 |
| 153 run_test = not args.translate_only | |
| 154 | |
| 65 test_name = os.path.basename(test_file) | 155 test_name = os.path.basename(test_file) |
| 66 obj_file = os.path.join(OUT_DIR, test_name + ".o") | 156 obj_file = os.path.join(OUT_DIR, test_name + ".o") |
| 67 exe_file = os.path.join(OUT_DIR, test_name + ".exe") | 157 exe_file = os.path.join(OUT_DIR, test_name + ".exe") |
| 68 | 158 |
| 69 if not verbose and test_name in IGNORED_TESTS: | 159 if not verbose and test_name in IGNORED_TESTS: |
| 70 print("\033[1;34mSkipping {}\033[1;m".format(test_file)) | 160 print("\033[1;34mSkipping {}\033[1;m".format(test_file)) |
| 71 return | 161 return |
| 72 | 162 |
| 73 cmd = """LD_LIBRARY_PATH=../../../../v8/out/native/lib.target ./pnacl-sz \ | 163 cmd = """LD_LIBRARY_PATH=../../../../v8/out/native/lib.target ./pnacl-sz \ |
| 74 -filetype=obj -target=x8632 {} -threads=0 -O2 \ | 164 -filetype=obj -target=x8632 {} -threads=0 -O2 \ |
| 75 -verbose=wasm -o {}""".format(test_file, obj_file) | 165 -verbose=wasm -o {}""".format(test_file, obj_file) |
| 76 | 166 |
| 77 if not verbose: | 167 if not verbose: |
| 78 cmd += " &> /dev/null" | 168 cmd += " &> /dev/null" |
| 79 | 169 |
| 80 sys.stdout.write(test_file + " ..."); | 170 out = StringIO.StringIO() |
| 171 | |
| 172 out.write(test_file + " ..."); | |
| 81 status = os.system(cmd); | 173 status = os.system(cmd); |
| 82 if status != 0: | 174 if status != 0: |
| 83 print('\033[1;31m[compile fail]\033[1;m') | 175 print('\033[1;31m[compile fail]\033[1;m', file=out) |
|
Karl
2016/04/21 19:14:17
Are these parenthesis necessary? (More instances b
Eric Holk
2016/04/21 21:56:02
They are because I imported print_function from __
| |
| 84 compile_failures.append(test_file) | 176 with results_lock: |
| 177 compile_failures.append(test_file) | |
| 85 else: | 178 else: |
| 86 compile_count += 1 | 179 compile_count += 1 |
| 87 | 180 |
| 88 # Try to link and run the program. | 181 # Try to link and run the program. |
| 89 cmd = "clang -g -m32 {} -o {} ./runtime/wasm-runtime.c".format(obj_file, | 182 cmd = "clang -g -m32 {} -o {} " + \ |
| 90 exe_file) | 183 "./runtime/szrt.c ./runtime/wasm-runtime.cpp -lm" |
| 91 if os.system(cmd) == 0: | 184 cmd = cmd.format(obj_file, exe_file) |
| 92 if os.system(exe_file) == 0: | 185 |
| 93 run_count += 1 | 186 if not run_test or os.system(cmd) == 0: |
| 94 print('\033[1;32m[ok]\033[1;m') | 187 if not run_test or os.system(exe_file) == 0: |
| 188 with results_lock: | |
| 189 run_count += 1 | |
| 190 print('\033[1;32m[ok]\033[1;m', file=out) | |
| 95 else: | 191 else: |
| 192 with results_lock: | |
| 193 run_failures.append(test_file) | |
| 194 print('\033[1;33m[run fail]\033[1;m', file=out) | |
| 195 else: | |
| 196 with results_lock: | |
| 96 run_failures.append(test_file) | 197 run_failures.append(test_file) |
| 97 print('\033[1;33m[run fail]\033[1;m') | 198 print('\033[1;33m[run fail]\033[1;m', file=out) |
| 98 else: | |
| 99 run_failures.append(test_file) | |
| 100 print('\033[1;33m[run fail]\033[1;m') | |
| 101 | 199 |
| 102 verbose = False | 200 sys.stdout.write(out.getvalue()) |
| 103 | 201 |
| 104 if len(sys.argv) > 1: | 202 verbose = args.verbose |
| 105 test_files = sys.argv[1:] | 203 |
| 106 verbose = True | 204 if len(args.tests) > 0: |
| 205 test_files = args.tests | |
| 107 else: | 206 else: |
| 108 test_files = glob.glob("./emwasm-torture-out/*.wasm") | 207 test_files = glob.glob("./emwasm-torture-out/*.wasm") |
| 109 | 208 |
| 110 if os.path.exists(OUT_DIR): | 209 if os.path.exists(OUT_DIR): |
| 111 shutil.rmtree(OUT_DIR) | 210 shutil.rmtree(OUT_DIR) |
| 112 os.mkdir(OUT_DIR) | 211 os.mkdir(OUT_DIR) |
| 113 | 212 |
| 213 tasks = Queue.Queue() | |
| 214 | |
| 215 def worker(): | |
| 216 while True: | |
| 217 run_test(tasks.get(), verbose) | |
| 218 tasks.task_done() | |
| 219 | |
| 220 for i in range(multiprocessing.cpu_count()): | |
| 221 t = threading.Thread(target=worker) | |
| 222 t.daemon = True | |
| 223 t.start() | |
| 224 | |
| 114 for test_file in test_files: | 225 for test_file in test_files: |
| 115 run_test(test_file, verbose) | 226 tasks.put(test_file) |
| 227 | |
| 228 tasks.join() | |
| 116 | 229 |
| 117 if len(compile_failures) > 0: | 230 if len(compile_failures) > 0: |
| 118 print | 231 print() |
| 119 print("Compilation failures:") | 232 print("Compilation failures:") |
| 120 print("=====================\n") | 233 print("=====================\n") |
| 121 for f in compile_failures: | 234 for f in compile_failures: |
| 122 print(" \033[1;31m" + f + "\033[1;m") | 235 print(" \033[1;31m" + f + "\033[1;m") |
| 123 | 236 |
| 124 if len(run_failures) > 0: | 237 if len(run_failures) > 0: |
| 125 print | 238 print() |
| 126 print("Run failures:") | 239 print("Run failures:") |
| 127 print("=============\n") | 240 print("=============\n") |
| 128 for f in run_failures: | 241 for f in run_failures: |
| 129 print(" \033[1;33m" + f + "\033[1;m") | 242 print(" \033[1;33m" + f + "\033[1;m") |
| 130 | 243 |
| 131 print("\n\033[1;32m{}\033[1;m / \033[1;33m{}\033[1;m / {} tests passed" | 244 print("\n\033[1;32m{}\033[1;m / \033[1;33m{}\033[1;m / {} tests passed" |
| 132 .format(run_count, compile_count - run_count, | 245 .format(run_count, compile_count - run_count, |
| 133 run_count + len(compile_failures) + len(run_failures))) | 246 run_count + len(compile_failures) + len(run_failures))) |
| OLD | NEW |