| OLD | NEW |
| 1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
| 2 | 2 |
| 3 import argparse | 3 import argparse |
| 4 import ConfigParser | 4 import ConfigParser |
| 5 import os | 5 import os |
| 6 import shutil | 6 import shutil |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 from utils import shellcmd | 9 from utils import shellcmd |
| 10 from utils import FindBaseNaCl | 10 from utils import FindBaseNaCl |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 Builds and executes cross tests from the space of all possible attribute | 49 Builds and executes cross tests from the space of all possible attribute |
| 50 combinations. The space can be restricted by providing subsets of attributes | 50 combinations. The space can be restricted by providing subsets of attributes |
| 51 to specifically include or exclude. | 51 to specifically include or exclude. |
| 52 """ | 52 """ |
| 53 # pypath is where to find other Subzero python scripts. | 53 # pypath is where to find other Subzero python scripts. |
| 54 pypath = os.path.abspath(os.path.dirname(sys.argv[0])) | 54 pypath = os.path.abspath(os.path.dirname(sys.argv[0])) |
| 55 root = FindBaseNaCl() | 55 root = FindBaseNaCl() |
| 56 | 56 |
| 57 # The rest of the attribute sets. | 57 # The rest of the attribute sets. |
| 58 targets = [ 'x8632', 'x8664', 'arm32' ] | 58 targets = [ 'x8632', 'x8664', 'arm32' ] |
| 59 sandboxing = [ 'native', 'sandbox' ] | 59 sandboxing = [ 'native', 'sandbox', 'nonsfi' ] |
| 60 opt_levels = [ 'Om1', 'O2' ] | 60 opt_levels = [ 'Om1', 'O2' ] |
| 61 arch_attrs = { 'x8632': [ 'sse2', 'sse4.1' ], | 61 arch_attrs = { 'x8632': [ 'sse2', 'sse4.1' ], |
| 62 'x8664': [ 'sse2', 'sse4.1' ], | 62 'x8664': [ 'sse2', 'sse4.1' ], |
| 63 'arm32': [ 'neon', 'hwdiv-arm' ] } | 63 'arm32': [ 'neon', 'hwdiv-arm' ] } |
| 64 flat_attrs = [] | 64 flat_attrs = [] |
| 65 for v in arch_attrs.values(): | 65 for v in arch_attrs.values(): |
| 66 flat_attrs += v | 66 flat_attrs += v |
| 67 arch_flags = { 'x8632': [], | 67 arch_flags = { 'x8632': [], |
| 68 'x8664': [], | 68 'x8664': [], |
| 69 # ARM doesn't have an ELF writer yet, and iasm does not | 69 # ARM doesn't have an ELF writer yet, and iasm does not |
| (...skipping 26 matching lines...) Expand all Loading... |
| 96 argparser.add_argument('--no-compile', '-n', default=False, | 96 argparser.add_argument('--no-compile', '-n', default=False, |
| 97 action='store_true', | 97 action='store_true', |
| 98 help="Don't build; reuse binaries from the last run") | 98 help="Don't build; reuse binaries from the last run") |
| 99 argparser.add_argument('--dir', dest='dir', metavar='DIRECTORY', | 99 argparser.add_argument('--dir', dest='dir', metavar='DIRECTORY', |
| 100 default=('{root}/toolchain_build/src/subzero/' + | 100 default=('{root}/toolchain_build/src/subzero/' + |
| 101 'crosstest/Output').format(root=root), | 101 'crosstest/Output').format(root=root), |
| 102 help='Output directory') | 102 help='Output directory') |
| 103 argparser.add_argument('--lit', default=False, action='store_true', | 103 argparser.add_argument('--lit', default=False, action='store_true', |
| 104 help='Generate files for lit testing') | 104 help='Generate files for lit testing') |
| 105 argparser.add_argument('--toolchain-root', dest='toolchain_root', | 105 argparser.add_argument('--toolchain-root', dest='toolchain_root', |
| 106 help='Path to toolchain binaries.') | 106 default=( |
| 107 '{root}/toolchain/linux_x86/pnacl_newlib_raw/bin' |
| 108 ).format(root=root), |
| 109 help='Path to toolchain binaries.') |
| 107 args = argparser.parse_args() | 110 args = argparser.parse_args() |
| 108 | 111 |
| 109 # Run from the crosstest directory to make it easy to grab inputs. | 112 # Run from the crosstest directory to make it easy to grab inputs. |
| 110 crosstest_dir = '{root}/toolchain_build/src/subzero/crosstest'.format( | 113 crosstest_dir = '{root}/toolchain_build/src/subzero/crosstest'.format( |
| 111 root=root) | 114 root=root) |
| 112 os.chdir(crosstest_dir) | 115 os.chdir(crosstest_dir) |
| 113 | 116 |
| 114 tests = ConfigParser.RawConfigParser() | 117 tests = ConfigParser.RawConfigParser() |
| 115 tests.read('crosstest.cfg') | 118 tests.read('crosstest.cfg') |
| 116 | 119 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 attr=attr) | 152 attr=attr) |
| 150 extra = (tests.get(test, 'flags').split(' ') | 153 extra = (tests.get(test, 'flags').split(' ') |
| 151 if tests.has_option(test, 'flags') else []) | 154 if tests.has_option(test, 'flags') else []) |
| 152 # Generate the compile command. | 155 # Generate the compile command. |
| 153 cmp_cmd = ( | 156 cmp_cmd = ( |
| 154 ['{path}/crosstest.py'.format(path=pypath), | 157 ['{path}/crosstest.py'.format(path=pypath), |
| 155 '-{opt}'.format(opt=opt), | 158 '-{opt}'.format(opt=opt), |
| 156 '--mattr={attr}'.format(attr=attr), | 159 '--mattr={attr}'.format(attr=attr), |
| 157 '--prefix=Subzero_', | 160 '--prefix=Subzero_', |
| 158 '--target={target}'.format(target=target), | 161 '--target={target}'.format(target=target), |
| 162 '--nonsfi={nsfi}'.format(nsfi='1' if sb=='nonsfi' else '0'), |
| 159 '--sandbox={sb}'.format(sb='1' if sb=='sandbox' else '0'), | 163 '--sandbox={sb}'.format(sb='1' if sb=='sandbox' else '0'), |
| 160 '--dir={dir}'.format(dir=args.dir), | 164 '--dir={dir}'.format(dir=args.dir), |
| 161 '--output={exe}'.format(exe=exe), | 165 '--output={exe}'.format(exe=exe), |
| 162 '--driver={drv}'.format(drv=tests.get(test, 'driver'))] + | 166 '--driver={drv}'.format(drv=tests.get(test, 'driver'))] + |
| 163 extra + | 167 extra + |
| 164 ['--test=' + t | 168 ['--test=' + t |
| 165 for t in tests.get(test, 'test').split(' ')] + | 169 for t in tests.get(test, 'test').split(' ')] + |
| 166 arch_flags[target]) | 170 arch_flags[target]) |
| 167 run_cmd_base = os.path.join(args.dir, exe) | 171 run_cmd_base = os.path.join(args.dir, exe) |
| 168 # Generate the run command. | 172 # Generate the run command. |
| 169 run_cmd = run_cmd_base | 173 run_cmd = run_cmd_base |
| 170 if sb == 'sandbox': | 174 if sb == 'sandbox': |
| 171 run_cmd = '{root}/run.py -q '.format(root=root) + run_cmd | 175 run_cmd = '{root}/run.py -q '.format(root=root) + run_cmd |
| 176 elif sb == 'nonsfi': |
| 177 run_cmd = ('{root}/scons-out/opt-linux-x86-32/obj/src/nonsfi/' + |
| 178 'loader/nonsfi_loader ').format(root=root) + run_cmd |
| 172 else: | 179 else: |
| 173 run_cmd = RunNativePrefix(args.toolchain_root, target, run_cmd) | 180 run_cmd = RunNativePrefix(args.toolchain_root, target, run_cmd) |
| 174 if args.lit: | 181 if args.lit: |
| 175 # Create a file to drive the lit test. | 182 # Create a file to drive the lit test. |
| 176 with open(run_cmd_base + '.xtest', 'w') as f: | 183 with open(run_cmd_base + '.xtest', 'w') as f: |
| 177 f.write('# RUN: sh %s | FileCheck %s\n') | 184 f.write('# RUN: sh %s | FileCheck %s\n') |
| 178 f.write('cd ' + crosstest_dir + ' && \\\n') | 185 f.write('cd ' + crosstest_dir + ' && \\\n') |
| 179 f.write(' '.join(cmp_cmd) + ' && \\\n') | 186 f.write(' '.join(cmp_cmd) + ' && \\\n') |
| 180 f.write(run_cmd + '\n') | 187 f.write(run_cmd + '\n') |
| 181 f.write('echo Recreate a failure using ' + __file__ + | 188 f.write('echo Recreate a failure using ' + __file__ + |
| 182 ' --toolchain-root=' + args.toolchain_root + | 189 ' --toolchain-root=' + args.toolchain_root + |
| 183 ' --include=' + ','.join(desc) + '\n') | 190 ' --include=' + ','.join(desc) + '\n') |
| 184 f.write('# CHECK: Failures=0\n') | 191 f.write('# CHECK: Failures=0\n') |
| 185 else: | 192 else: |
| 186 if not args.no_compile: | 193 if not args.no_compile: |
| 187 shellcmd(cmp_cmd, | 194 shellcmd(cmp_cmd, |
| 188 echo=args.verbose) | 195 echo=args.verbose) |
| 189 if (args.defer): | 196 if (args.defer): |
| 190 deferred_cmds.append(run_cmd) | 197 deferred_cmds.append(run_cmd) |
| 191 else: | 198 else: |
| 192 shellcmd(run_cmd, echo=True) | 199 shellcmd(run_cmd, echo=True) |
| 193 for run_cmd in deferred_cmds: | 200 for run_cmd in deferred_cmds: |
| 194 shellcmd(run_cmd, echo=True) | 201 shellcmd(run_cmd, echo=True) |
| 195 | 202 |
| 196 if __name__ == '__main__': | 203 if __name__ == '__main__': |
| 197 main() | 204 main() |
| OLD | NEW |