OLD | NEW |
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
2 | 2 |
3 import argparse | 3 import argparse |
| 4 import collections |
4 import ConfigParser | 5 import ConfigParser |
5 import os | 6 import os |
6 import shutil | 7 import shutil |
7 import sys | 8 import sys |
8 | 9 |
9 from utils import shellcmd | 10 from utils import shellcmd |
10 from utils import FindBaseNaCl | 11 from utils import FindBaseNaCl |
11 | 12 |
12 def Match(desc, includes, excludes, default_match): | 13 def Match(desc, includes, excludes, default_match): |
13 """Determines whether desc is a match against includes and excludes. | 14 """Determines whether desc is a match against includes and excludes. |
14 | 15 |
15 'desc' is a set of attributes, and 'includes' and 'excludes' are lists of sets | 16 'desc' is a set of attributes, and 'includes' and 'excludes' are lists of sets |
16 of attributes. | 17 of attributes. |
17 | 18 |
18 If 'desc' matches any element from 'excludes', the result is False. | 19 If 'desc' matches any element from 'excludes', the result is False. |
19 Otherwise, if 'desc' matches any element from 'includes', the result is True. | 20 Otherwise, if 'desc' matches any element from 'includes', the result is True. |
20 Otherwise, the 'default_match' value is returned. | 21 Otherwise, the 'default_match' value is returned. |
21 """ | 22 """ |
22 for exclude in excludes: | 23 for exclude in excludes: |
23 if exclude <= desc: | 24 if exclude <= desc: |
24 return False | 25 return False |
25 for include in includes: | 26 for include in includes: |
26 if include <= desc: | 27 if include <= desc: |
27 return True | 28 return True |
28 return default_match | 29 return default_match |
29 | 30 |
30 | 31 |
31 def RunNativePrefix(toolchain_root, target, run_cmd): | 32 def RunNativePrefix(toolchain_root, target, attr, run_cmd): |
32 """Returns a prefix for running an executable for the target. | 33 """Returns a prefix for running an executable for the target. |
33 | 34 |
34 For example, we may be running an ARM or MIPS target executable on an | 35 For example, we may be running an ARM or MIPS target executable on an |
35 x86 machine and need to use an emulator. | 36 x86 machine and need to use an emulator. |
36 """ | 37 """ |
37 arch_map = { 'x8632' : '', | 38 arch_map = { 'x8632' : '', |
38 'x8664' : '', | 39 'x8664' : '', |
39 'arm32' : os.path.join(toolchain_root, 'arm_trusted', | 40 'arm32' : os.path.join(toolchain_root, 'arm_trusted', |
40 'run_under_qemu_arm'), | 41 'run_under_qemu_arm'), |
41 } | 42 } |
42 prefix = arch_map[target] | 43 attr_map = collections.defaultdict(str, { |
| 44 'arm32-neon': ' -cpu cortex-a9', |
| 45 'arm32-hwdiv-arm': ' -cpu cortex-a15' }) |
| 46 prefix = arch_map[target] + attr_map[target + '-' + attr] |
43 return (prefix + ' ' + run_cmd) if prefix else run_cmd | 47 return (prefix + ' ' + run_cmd) if prefix else run_cmd |
44 | 48 |
45 def NonsfiLoaderArch(target): | 49 def NonsfiLoaderArch(target): |
46 """Returns the arch for the nonsfi_loader""" | 50 """Returns the arch for the nonsfi_loader""" |
47 arch_map = { 'arm32' : 'arm', | 51 arch_map = { 'arm32' : 'arm', |
48 'x8632' : 'x86-32', | 52 'x8632' : 'x86-32', |
49 } | 53 } |
50 return arch_map[target] | 54 return arch_map[target] |
51 | 55 |
52 | 56 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 run_cmd_base = os.path.join(args.dir, exe) | 184 run_cmd_base = os.path.join(args.dir, exe) |
181 # Generate the run command. | 185 # Generate the run command. |
182 run_cmd = run_cmd_base | 186 run_cmd = run_cmd_base |
183 if sb == 'sandbox': | 187 if sb == 'sandbox': |
184 run_cmd = '{root}/run.py -q '.format(root=root) + run_cmd | 188 run_cmd = '{root}/run.py -q '.format(root=root) + run_cmd |
185 elif sb == 'nonsfi': | 189 elif sb == 'nonsfi': |
186 run_cmd = ( | 190 run_cmd = ( |
187 '{root}/scons-out/opt-linux-{arch}/obj/src/nonsfi/' + | 191 '{root}/scons-out/opt-linux-{arch}/obj/src/nonsfi/' + |
188 'loader/nonsfi_loader ').format( | 192 'loader/nonsfi_loader ').format( |
189 root=root, arch=NonsfiLoaderArch(target)) + run_cmd | 193 root=root, arch=NonsfiLoaderArch(target)) + run_cmd |
190 run_cmd = RunNativePrefix(args.toolchain_root, target, run_cmd) | 194 run_cmd = RunNativePrefix(args.toolchain_root, target, attr, |
| 195 run_cmd) |
191 else: | 196 else: |
192 run_cmd = RunNativePrefix(args.toolchain_root, target, run_cmd) | 197 run_cmd = RunNativePrefix(args.toolchain_root, target, attr, |
| 198 run_cmd) |
193 if args.lit: | 199 if args.lit: |
194 # Create a file to drive the lit test. | 200 # Create a file to drive the lit test. |
195 with open(run_cmd_base + '.xtest', 'w') as f: | 201 with open(run_cmd_base + '.xtest', 'w') as f: |
196 f.write('# RUN: sh %s | FileCheck %s\n') | 202 f.write('# RUN: sh %s | FileCheck %s\n') |
197 f.write('cd ' + crosstest_dir + ' && \\\n') | 203 f.write('cd ' + crosstest_dir + ' && \\\n') |
198 f.write(' '.join(cmp_cmd) + ' && \\\n') | 204 f.write(' '.join(cmp_cmd) + ' && \\\n') |
199 f.write(run_cmd + '\n') | 205 f.write(run_cmd + '\n') |
200 f.write('echo Recreate a failure using ' + __file__ + | 206 f.write('echo Recreate a failure using ' + __file__ + |
201 ' --toolchain-root=' + args.toolchain_root + | 207 ' --toolchain-root=' + args.toolchain_root + |
202 ' --include=' + ','.join(desc) + '\n') | 208 ' --include=' + ','.join(desc) + '\n') |
203 f.write('# CHECK: Failures=0\n') | 209 f.write('# CHECK: Failures=0\n') |
204 else: | 210 else: |
205 if not args.no_compile: | 211 if not args.no_compile: |
206 shellcmd(cmp_cmd, | 212 shellcmd(cmp_cmd, |
207 echo=args.verbose) | 213 echo=args.verbose) |
208 if (args.defer): | 214 if (args.defer): |
209 deferred_cmds.append(run_cmd) | 215 deferred_cmds.append(run_cmd) |
210 else: | 216 else: |
211 shellcmd(run_cmd, echo=True) | 217 shellcmd(run_cmd, echo=True) |
212 for run_cmd in deferred_cmds: | 218 for run_cmd in deferred_cmds: |
213 shellcmd(run_cmd, echo=True) | 219 shellcmd(run_cmd, echo=True) |
214 | 220 |
215 if __name__ == '__main__': | 221 if __name__ == '__main__': |
216 main() | 222 main() |
OLD | NEW |