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) |
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 {} ./runtime/wasm-runtime.c ./runtime/szrt.c ./ru
ntime/wasm-runtime.cpp -lm" |
90 exe_file) | 183 cmd = cmd.format(obj_file, exe_file) |
91 if os.system(cmd) == 0: | 184 |
92 if os.system(exe_file) == 0: | 185 if not run_test or os.system(cmd) == 0: |
93 run_count += 1 | 186 if not run_test or os.system(exe_file) == 0: |
94 print('\033[1;32m[ok]\033[1;m') | 187 with results_lock: |
| 188 run_count += 1 |
| 189 print('\033[1;32m[ok]\033[1;m', file=out) |
95 else: | 190 else: |
| 191 with results_lock: |
| 192 run_failures.append(test_file) |
| 193 print('\033[1;33m[run fail]\033[1;m', file=out) |
| 194 else: |
| 195 with results_lock: |
96 run_failures.append(test_file) | 196 run_failures.append(test_file) |
97 print('\033[1;33m[run fail]\033[1;m') | 197 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 | 198 |
102 verbose = False | 199 sys.stdout.write(out.getvalue()) |
103 | 200 |
104 if len(sys.argv) > 1: | 201 verbose = args.verbose |
105 test_files = sys.argv[1:] | 202 |
106 verbose = True | 203 if len(args.tests) > 0: |
| 204 test_files = args.tests |
107 else: | 205 else: |
108 test_files = glob.glob("./emwasm-torture-out/*.wasm") | 206 test_files = glob.glob("./emwasm-torture-out/*.wasm") |
109 | 207 |
110 if os.path.exists(OUT_DIR): | 208 if os.path.exists(OUT_DIR): |
111 shutil.rmtree(OUT_DIR) | 209 shutil.rmtree(OUT_DIR) |
112 os.mkdir(OUT_DIR) | 210 os.mkdir(OUT_DIR) |
113 | 211 |
| 212 tasks = Queue.Queue() |
| 213 |
| 214 def worker(): |
| 215 while True: |
| 216 run_test(tasks.get(), verbose) |
| 217 tasks.task_done() |
| 218 |
| 219 for i in range(multiprocessing.cpu_count()): |
| 220 t = threading.Thread(target=worker) |
| 221 t.daemon = True |
| 222 t.start() |
| 223 |
114 for test_file in test_files: | 224 for test_file in test_files: |
115 run_test(test_file, verbose) | 225 tasks.put(test_file) |
| 226 |
| 227 tasks.join() |
116 | 228 |
117 if len(compile_failures) > 0: | 229 if len(compile_failures) > 0: |
118 print | 230 print() |
119 print("Compilation failures:") | 231 print("Compilation failures:") |
120 print("=====================\n") | 232 print("=====================\n") |
121 for f in compile_failures: | 233 for f in compile_failures: |
122 print(" \033[1;31m" + f + "\033[1;m") | 234 print(" \033[1;31m" + f + "\033[1;m") |
123 | 235 |
124 if len(run_failures) > 0: | 236 if len(run_failures) > 0: |
125 print | 237 print() |
126 print("Run failures:") | 238 print("Run failures:") |
127 print("=============\n") | 239 print("=============\n") |
128 for f in run_failures: | 240 for f in run_failures: |
129 print(" \033[1;33m" + f + "\033[1;m") | 241 print(" \033[1;33m" + f + "\033[1;m") |
130 | 242 |
131 print("\n\033[1;32m{}\033[1;m / \033[1;33m{}\033[1;m / {} tests passed" | 243 print("\n\033[1;32m{}\033[1;m / \033[1;33m{}\033[1;m / {} tests passed" |
132 .format(run_count, compile_count - run_count, | 244 .format(run_count, compile_count - run_count, |
133 run_count + len(compile_failures) + len(run_failures))) | 245 run_count + len(compile_failures) + len(run_failures))) |
OLD | NEW |