| 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 import glob | 12 import glob |
| 13 import os | 13 import os |
| 14 import shutil |
| 14 import sys | 15 import sys |
| 15 | 16 |
| 16 success_count = 0 | 17 IGNORED_TESTS = [ |
| 17 fail_count = 0 | 18 'loop-2f.c.wasm', # mmap not in MVP |
| 18 failures = [] | 19 'loop-2g.c.wasm', # mmap not in MVP |
| 20 |
| 21 '960521-1.c.wasm', # sbrk not in MVP |
| 22 |
| 23 'pr36765.c.wasm', # __builtin_malloc not allowed |
| 24 |
| 25 'pr24716.c.wasm', # infinite loop |
| 26 'vla-dealloc-1.c.wasm', # infinite loop |
| 27 '20040811-1.c.wasm', # infinite loop |
| 28 '961125-1.c.wasm', # infinite loop |
| 29 '980506-1.c.wasm', # infinite loop |
| 30 '20070824-1.c.wasm', # infinite loop |
| 31 '20140212-1.c.wasm', # infinite loop |
| 32 'pr59014.c.wasm', # infinite loop |
| 33 'pr58277-2.c.wasm', # infinite loop |
| 34 'pr43560.c.wasm', # infinite loop |
| 35 '20000818-1.c.wasm', # infinite loop |
| 36 '20010409-1.c.wasm', # infinite loop |
| 37 'loop-7.c.wasm', # infinite loop |
| 38 'pr34415.c.wasm', # infinite loop |
| 39 '20011126-2.c.wasm', # infinite loop |
| 40 'postmod-1.c.wasm', # infinite loop |
| 41 'pr17133.c.wasm', # infinite loop |
| 42 '20021024-1.c.wasm', # infinite loop |
| 43 'pr15296.c.wasm', # infinite loop |
| 44 '990524-1.c.wasm', # infinite loop |
| 45 'loop-12.c.wasm', # infinite loop |
| 46 '961125-1.c.wasm', # infinite loop |
| 47 ] |
| 48 |
| 49 OUT_DIR = "./build/wasm-torture" |
| 50 |
| 51 compile_count = 0 |
| 52 compile_failures = [] |
| 53 |
| 54 run_count = 0 |
| 55 run_failures = [] |
| 19 | 56 |
| 20 def run_test(test_file, verbose=False): | 57 def run_test(test_file, verbose=False): |
| 21 global success_count | 58 global compile_count |
| 22 global fail_count | 59 global compile_failures |
| 60 global run_count |
| 61 global run_failures |
| 62 global OUT_DIR |
| 63 global IGNORED_TESTS |
| 64 |
| 65 test_name = os.path.basename(test_file) |
| 66 obj_file = os.path.join(OUT_DIR, test_name + ".o") |
| 67 exe_file = os.path.join(OUT_DIR, test_name + ".exe") |
| 68 |
| 69 if not verbose and test_name in IGNORED_TESTS: |
| 70 print("\033[1;34mSkipping {}\033[1;m".format(test_file)) |
| 71 return |
| 23 | 72 |
| 24 cmd = """LD_LIBRARY_PATH=../../../../v8/out/native/lib.target ./pnacl-sz \ | 73 cmd = """LD_LIBRARY_PATH=../../../../v8/out/native/lib.target ./pnacl-sz \ |
| 25 -filetype=asm -target=arm32 {} -threads=0 -O2 \ | 74 -filetype=obj -target=x8632 {} -threads=0 -O2 \ |
| 26 -verbose=wasm""".format(test_file) | 75 -verbose=wasm -o {}""".format(test_file, obj_file) |
| 27 | 76 |
| 28 if not verbose: | 77 if not verbose: |
| 29 cmd += " &> /dev/null" | 78 cmd += " &> /dev/null" |
| 30 | 79 |
| 31 sys.stdout.write(test_file + "..."); | 80 sys.stdout.write(test_file + " ..."); |
| 32 status = os.system(cmd); | 81 status = os.system(cmd); |
| 33 if status != 0: | 82 if status != 0: |
| 34 fail_count += 1 | 83 print('\033[1;31m[compile fail]\033[1;m') |
| 35 print('\033[1;31m[fail]\033[1;m') | 84 compile_failures.append(test_file) |
| 36 failures.append(test_file) | |
| 37 else: | 85 else: |
| 38 success_count += 1 | 86 compile_count += 1 |
| 39 print('\033[1;32m[ok]\033[1;m') | |
| 40 | 87 |
| 88 # Try to link and run the program. |
| 89 cmd = "clang -g -m32 {} -o {} ./runtime/wasm-runtime.c".format(obj_file, |
| 90 exe_file) |
| 91 if os.system(cmd) == 0: |
| 92 if os.system(exe_file) == 0: |
| 93 run_count += 1 |
| 94 print('\033[1;32m[ok]\033[1;m') |
| 95 else: |
| 96 run_failures.append(test_file) |
| 97 print('\033[1;33m[run fail]\033[1;m') |
| 98 else: |
| 99 run_failures.append(test_file) |
| 100 print('\033[1;33m[run fail]\033[1;m') |
| 41 | 101 |
| 42 verbose = False | 102 verbose = False |
| 43 | 103 |
| 44 if len(sys.argv) > 1: | 104 if len(sys.argv) > 1: |
| 45 test_files = sys.argv[1:] | 105 test_files = sys.argv[1:] |
| 46 verbose = True | 106 verbose = True |
| 47 else: | 107 else: |
| 48 test_files = glob.glob("./torture-s2wasm-sexpr-wasm.old/*.wasm") | 108 test_files = glob.glob("./emwasm-torture-out/*.wasm") |
| 109 |
| 110 if os.path.exists(OUT_DIR): |
| 111 shutil.rmtree(OUT_DIR) |
| 112 os.mkdir(OUT_DIR) |
| 49 | 113 |
| 50 for test_file in test_files: | 114 for test_file in test_files: |
| 51 run_test(test_file, verbose) | 115 run_test(test_file, verbose) |
| 52 | 116 |
| 53 if len(failures) > 0: | 117 if len(compile_failures) > 0: |
| 54 print("Failures:") | 118 print |
| 55 for f in failures: | 119 print("Compilation failures:") |
| 56 print(" \033[1;31m" + f + "\033[1;m") | 120 print("=====================\n") |
| 57 print("{} / {} tests passed".format(success_count, success_count + fail_count)) | 121 for f in compile_failures: |
| 122 print(" \033[1;31m" + f + "\033[1;m") |
| 123 |
| 124 if len(run_failures) > 0: |
| 125 print |
| 126 print("Run failures:") |
| 127 print("=============\n") |
| 128 for f in run_failures: |
| 129 print(" \033[1;33m" + f + "\033[1;m") |
| 130 |
| 131 print("\n\033[1;32m{}\033[1;m / \033[1;33m{}\033[1;m / {} tests passed" |
| 132 .format(run_count, compile_count - run_count, |
| 133 run_count + len(compile_failures) + len(run_failures))) |
| OLD | NEW |