1dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth#!/usr/bin/env python2 2dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 3dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothimport argparse 494e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Portoimport collections 5dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothimport ConfigParser 6dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothimport os 7dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothimport shutil 8dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothimport sys 9dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 10dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothfrom utils import shellcmd 11dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothfrom utils import FindBaseNaCl 12dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 13dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothdef Match(desc, includes, excludes, default_match): 14dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth """Determines whether desc is a match against includes and excludes. 15dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 16dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 'desc' is a set of attributes, and 'includes' and 'excludes' are lists of sets 17dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth of attributes. 18dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 19dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth If 'desc' matches any element from 'excludes', the result is False. 20dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth Otherwise, if 'desc' matches any element from 'includes', the result is True. 21dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth Otherwise, the 'default_match' value is returned. 22dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth """ 23dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth for exclude in excludes: 24833f13f9bbbed63ff7d24ec27f9d931098a7b65eJim Stichnoth if exclude <= desc: 25dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth return False 26dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth for include in includes: 27833f13f9bbbed63ff7d24ec27f9d931098a7b65eJim Stichnoth if include <= desc: 28dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth return True 29dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth return default_match 30dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 318e32fed59522195debe86ae35c314f6bf34aed09Jan Voung 3294e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Portodef RunNativePrefix(toolchain_root, target, attr, run_cmd): 338e32fed59522195debe86ae35c314f6bf34aed09Jan Voung """Returns a prefix for running an executable for the target. 348e32fed59522195debe86ae35c314f6bf34aed09Jan Voung 358e32fed59522195debe86ae35c314f6bf34aed09Jan Voung For example, we may be running an ARM or MIPS target executable on an 368e32fed59522195debe86ae35c314f6bf34aed09Jan Voung x86 machine and need to use an emulator. 378e32fed59522195debe86ae35c314f6bf34aed09Jan Voung """ 388e32fed59522195debe86ae35c314f6bf34aed09Jan Voung arch_map = { 'x8632' : '', 398e32fed59522195debe86ae35c314f6bf34aed09Jan Voung 'x8664' : '', 408e32fed59522195debe86ae35c314f6bf34aed09Jan Voung 'arm32' : os.path.join(toolchain_root, 'arm_trusted', 418e32fed59522195debe86ae35c314f6bf34aed09Jan Voung 'run_under_qemu_arm'), 42623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'mips32': os.path.join(toolchain_root, 'mips_trusted', 43623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'run_under_qemu_mips32'), 448e32fed59522195debe86ae35c314f6bf34aed09Jan Voung } 4594e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Porto attr_map = collections.defaultdict(str, { 4694e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Porto 'arm32-neon': ' -cpu cortex-a9', 47623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'arm32-hwdiv-arm': ' -cpu cortex-a15', 48623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'mips32-base': ' -cpu mips32r5-generic'}) 4994e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Porto prefix = arch_map[target] + attr_map[target + '-' + attr] 508208e756c4b6b488d2fc053072b579c63d5d73aeStefan Maksimovic if target == 'mips32': 518208e756c4b6b488d2fc053072b579c63d5d73aeStefan Maksimovic prefix = 'QEMU_SET_ENV=LD_LIBRARY_PATH=/usr/mipsel-linux-gnu/lib/ ' + prefix 528e32fed59522195debe86ae35c314f6bf34aed09Jan Voung return (prefix + ' ' + run_cmd) if prefix else run_cmd 538e32fed59522195debe86ae35c314f6bf34aed09Jan Voung 54dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Portodef NonsfiLoaderArch(target): 55dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto """Returns the arch for the nonsfi_loader""" 56dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto arch_map = { 'arm32' : 'arm', 57dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto 'x8632' : 'x86-32', 58623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'mips32' : 'mips32', 59dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto } 60dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto return arch_map[target] 61dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto 628e32fed59522195debe86ae35c314f6bf34aed09Jan Voung 63dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothdef main(): 64dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth """Framework for cross test generation and execution. 65dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 66dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth Builds and executes cross tests from the space of all possible attribute 67dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth combinations. The space can be restricted by providing subsets of attributes 68dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth to specifically include or exclude. 69dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth """ 70dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # pypath is where to find other Subzero python scripts. 71dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth pypath = os.path.abspath(os.path.dirname(sys.argv[0])) 72dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth root = FindBaseNaCl() 73dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 74dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # The rest of the attribute sets. 75623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina targets = [ 'x8632', 'x8664', 'arm32', 'mips32' ] 768ff4b2819944bc4f02fb29204a1fa5ba7dea5682Jim Stichnoth sandboxing = [ 'native', 'sandbox', 'nonsfi' ] 77dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth opt_levels = [ 'Om1', 'O2' ] 788e32fed59522195debe86ae35c314f6bf34aed09Jan Voung arch_attrs = { 'x8632': [ 'sse2', 'sse4.1' ], 791d235425dab1f3dd059973fc53f1b1d5879469e3John Porto 'x8664': [ 'sse2', 'sse4.1' ], 80623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'arm32': [ 'neon', 'hwdiv-arm' ], 81623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'mips32': [ 'base' ] 82623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina } 838e32fed59522195debe86ae35c314f6bf34aed09Jan Voung flat_attrs = [] 848e32fed59522195debe86ae35c314f6bf34aed09Jan Voung for v in arch_attrs.values(): 858e32fed59522195debe86ae35c314f6bf34aed09Jan Voung flat_attrs += v 868e32fed59522195debe86ae35c314f6bf34aed09Jan Voung arch_flags = { 'x8632': [], 871d235425dab1f3dd059973fc53f1b1d5879469e3John Porto 'x8664': [], 88623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'arm32': [], 89623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina 'mips32': [] 90623f8ce32c8dd33f9c755dde229967dfddd3353bSrdjan Obucina } 91dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # all_keys is only used in the help text. 92dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth all_keys = '; '.join([' '.join(targets), ' '.join(sandboxing), 938e32fed59522195debe86ae35c314f6bf34aed09Jan Voung ' '.join(opt_levels), ' '.join(flat_attrs)]) 94dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 95dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser = argparse.ArgumentParser( 96dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth description=' ' + main.__doc__ + 97dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 'The set of attributes is the set of tests plus the following:\n' + 98dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth all_keys, formatter_class=argparse.RawTextHelpFormatter) 99dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--config', default='crosstest.cfg', dest='config', 100dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth metavar='FILE', help='Test configuration file') 101dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--print-tests', default=False, action='store_true', 102dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth help='Print the set of test names and exit') 103dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--include', '-i', default=[], dest='include', 104dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth action='append', metavar='ATTR_LIST', 105dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth help='Attributes to include (comma-separated). ' + 106dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 'Can be used multiple times.') 107dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--exclude', '-e', default=[], dest='exclude', 108dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth action='append', metavar='ATTR_LIST', 109dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth help='Attributes to include (comma-separated). ' + 110dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 'Can be used multiple times.') 111dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--verbose', '-v', default=False, action='store_true', 112dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth help='Use verbose output') 113dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--defer', default=False, action='store_true', 114dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth help='Defer execution until all executables are built') 115dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--no-compile', '-n', default=False, 116dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth action='store_true', 117dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth help="Don't build; reuse binaries from the last run") 118dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--dir', dest='dir', metavar='DIRECTORY', 119dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth default=('{root}/toolchain_build/src/subzero/' + 120dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 'crosstest/Output').format(root=root), 121dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth help='Output directory') 122dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth argparser.add_argument('--lit', default=False, action='store_true', 123dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth help='Generate files for lit testing') 1248e32fed59522195debe86ae35c314f6bf34aed09Jan Voung argparser.add_argument('--toolchain-root', dest='toolchain_root', 1258ff4b2819944bc4f02fb29204a1fa5ba7dea5682Jim Stichnoth default=( 1268ff4b2819944bc4f02fb29204a1fa5ba7dea5682Jim Stichnoth '{root}/toolchain/linux_x86/pnacl_newlib_raw/bin' 1278ff4b2819944bc4f02fb29204a1fa5ba7dea5682Jim Stichnoth ).format(root=root), 1288ff4b2819944bc4f02fb29204a1fa5ba7dea5682Jim Stichnoth help='Path to toolchain binaries.') 129b19d39cc5fa8dc60c678c2507af02147184f168fDavid Sehr argparser.add_argument('--filetype', default=None, dest='filetype', 130b19d39cc5fa8dc60c678c2507af02147184f168fDavid Sehr help='File type override, one of {asm, iasm, obj}.') 131dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth args = argparser.parse_args() 132dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 133dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # Run from the crosstest directory to make it easy to grab inputs. 134dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth crosstest_dir = '{root}/toolchain_build/src/subzero/crosstest'.format( 135dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth root=root) 136dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth os.chdir(crosstest_dir) 137dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 138dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth tests = ConfigParser.RawConfigParser() 139dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth tests.read('crosstest.cfg') 140dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 141dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if args.print_tests: 142dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth print 'Test name attributes: ' + ' '.join(sorted(tests.sections())) 143dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth sys.exit(0) 144dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 145dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # includes and excludes are both lists of sets. 146dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth includes = [ set(item.split(',')) for item in args.include ] 147dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth excludes = [ set(item.split(',')) for item in args.exclude ] 148dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # If any --include args are provided, the default is to not match. 149dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth default_match = not args.include 150dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 151dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # Delete and recreate the output directory, unless --no-compile was specified. 152dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if not args.no_compile: 153dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if os.path.exists(args.dir): 154dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if os.path.isdir(args.dir): 155dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth shutil.rmtree(args.dir) 156dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth else: 157dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth os.remove(args.dir) 158dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if not os.path.exists(args.dir): 159dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth os.makedirs(args.dir) 160dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 161dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # If --defer is specified, collect the run commands into deferred_cmds for 162dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # later execution. 163dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth deferred_cmds = [] 164dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth for test in sorted(tests.sections()): 165dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth for target in targets: 166dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth for sb in sandboxing: 167dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth for opt in opt_levels: 1688e32fed59522195debe86ae35c314f6bf34aed09Jan Voung for attr in arch_attrs[target]: 169dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth desc = [ test, target, sb, opt, attr ] 170dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if Match(set(desc), includes, excludes, default_match): 171dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth exe = '{test}_{target}_{sb}_{opt}_{attr}'.format( 172dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth test=test, target=target, sb=sb, opt=opt, 173dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth attr=attr) 174dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth extra = (tests.get(test, 'flags').split(' ') 175dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if tests.has_option(test, 'flags') else []) 176b19d39cc5fa8dc60c678c2507af02147184f168fDavid Sehr if args.filetype: 177b19d39cc5fa8dc60c678c2507af02147184f168fDavid Sehr extra += ['--filetype={ftype}'.format(ftype=args.filetype)] 178dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # Generate the compile command. 1798e32fed59522195debe86ae35c314f6bf34aed09Jan Voung cmp_cmd = ( 1808e32fed59522195debe86ae35c314f6bf34aed09Jan Voung ['{path}/crosstest.py'.format(path=pypath), 1818e32fed59522195debe86ae35c314f6bf34aed09Jan Voung '-{opt}'.format(opt=opt), 1828e32fed59522195debe86ae35c314f6bf34aed09Jan Voung '--mattr={attr}'.format(attr=attr), 1838e32fed59522195debe86ae35c314f6bf34aed09Jan Voung '--prefix=Subzero_', 1848e32fed59522195debe86ae35c314f6bf34aed09Jan Voung '--target={target}'.format(target=target), 1858ff4b2819944bc4f02fb29204a1fa5ba7dea5682Jim Stichnoth '--nonsfi={nsfi}'.format(nsfi='1' if sb=='nonsfi' else '0'), 1868e32fed59522195debe86ae35c314f6bf34aed09Jan Voung '--sandbox={sb}'.format(sb='1' if sb=='sandbox' else '0'), 1878e32fed59522195debe86ae35c314f6bf34aed09Jan Voung '--dir={dir}'.format(dir=args.dir), 1888e32fed59522195debe86ae35c314f6bf34aed09Jan Voung '--output={exe}'.format(exe=exe), 1898e32fed59522195debe86ae35c314f6bf34aed09Jan Voung '--driver={drv}'.format(drv=tests.get(test, 'driver'))] + 1908e32fed59522195debe86ae35c314f6bf34aed09Jan Voung extra + 1918e32fed59522195debe86ae35c314f6bf34aed09Jan Voung ['--test=' + t 1928e32fed59522195debe86ae35c314f6bf34aed09Jan Voung for t in tests.get(test, 'test').split(' ')] + 1938e32fed59522195debe86ae35c314f6bf34aed09Jan Voung arch_flags[target]) 194dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth run_cmd_base = os.path.join(args.dir, exe) 195dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # Generate the run command. 196dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth run_cmd = run_cmd_base 197dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if sb == 'sandbox': 198dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth run_cmd = '{root}/run.py -q '.format(root=root) + run_cmd 1998ff4b2819944bc4f02fb29204a1fa5ba7dea5682Jim Stichnoth elif sb == 'nonsfi': 200dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto run_cmd = ( 201dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto '{root}/scons-out/opt-linux-{arch}/obj/src/nonsfi/' + 202dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto 'loader/nonsfi_loader ').format( 203dc61925cf9de3cba7f310c9e8855c56b8e5b3edcJohn Porto root=root, arch=NonsfiLoaderArch(target)) + run_cmd 20494e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Porto run_cmd = RunNativePrefix(args.toolchain_root, target, attr, 20594e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Porto run_cmd) 2068e32fed59522195debe86ae35c314f6bf34aed09Jan Voung else: 20794e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Porto run_cmd = RunNativePrefix(args.toolchain_root, target, attr, 20894e97f6a75cf87c7e547d4d9ff1a9acbc9275ceaJohn Porto run_cmd) 209dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if args.lit: 210dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth # Create a file to drive the lit test. 211dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth with open(run_cmd_base + '.xtest', 'w') as f: 212dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth f.write('# RUN: sh %s | FileCheck %s\n') 213dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth f.write('cd ' + crosstest_dir + ' && \\\n') 214dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth f.write(' '.join(cmp_cmd) + ' && \\\n') 215dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth f.write(run_cmd + '\n') 216dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth f.write('echo Recreate a failure using ' + __file__ + 217a9eeb42043a73ca2de57d3c4c9f095e530e17aa3Jim Stichnoth ' --toolchain-root=' + args.toolchain_root + 2183e324002a1df4861c389f7289ead7e9ff5adcd42Jim Stichnoth (' --filetype=' + args.filetype 2193e324002a1df4861c389f7289ead7e9ff5adcd42Jim Stichnoth if args.filetype else '') + 220dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth ' --include=' + ','.join(desc) + '\n') 221dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth f.write('# CHECK: Failures=0\n') 222dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth else: 223dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if not args.no_compile: 224dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth shellcmd(cmp_cmd, 225dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth echo=args.verbose) 226dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth if (args.defer): 227dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth deferred_cmds.append(run_cmd) 228dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth else: 229dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth shellcmd(run_cmd, echo=True) 230dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth for run_cmd in deferred_cmds: 231dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth shellcmd(run_cmd, echo=True) 232dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth 233dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnothif __name__ == '__main__': 234dc7c597ea93585ad9a56a06558260e4fac6d48aeJim Stichnoth main() 235