source: tests/pybin/settings.py@ c5c0148

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since c5c0148 was abec2f8, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Fixed makefiles missed in the removal of -in-tree

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[f85bc15]1import os
[a45fc7b]2import subprocess
[f3b9efc]3import sys
[5b993e0]4from . import tools
[bacc36c]5
[dcfedca]6global original_path
7
[f85bc15]8try :
[dcfedca]9 original_path = os.getcwd()
[afe8882]10 testpath = os.path.dirname(os.path.abspath(os.path.join(os.getcwd(), sys.argv[0])))
11 sys.path.append(testpath)
[552f5cb]12 import config
[f85bc15]13
[552f5cb]14 SRCDIR = os.path.abspath(config.SRCDIR)
15 BUILDDIR = os.path.abspath(config.BUILDDIR)
[d65f92c]16 distribute = config.DISTRIBUTE
[afe8882]17 os.chdir(testpath)
18
[f85bc15]19except:
20 print('ERROR: missing config.py, re-run configure script.', file=sys.stderr)
21 sys.exit(1)
22
[bacc36c]23class Architecture:
[f3b9efc]24 KnownArchitectures = {
[a8d4b59]25 'x64' : 'x64',
26 'x86-64' : 'x64',
27 'x86_64' : 'x64',
28 'x86' : 'x86',
29 'aarch64' : 'arm',
[f3b9efc]30 'i386' : 'x86',
31 'i486' : 'x86',
32 'i686' : 'x86',
33 'Intel 80386' : 'x86',
[a8d4b59]34 'arm' : 'arm',
35 'ARM' : 'arm',
[f3b9efc]36 }
37
[575a6e5]38 CrossCompileFlags = {
39 'x64' : 'ARCH_FLAGS=-m64',
40 'x86' : 'ARCH_FLAGS=-m32',
41 }
42
[f3b9efc]43 def __init__(self, arch):
[575a6e5]44 try:
[5bf1f3e]45 canonical_host = Architecture.make_canonical( config.HOSTARCH )
[575a6e5]46 except KeyError:
[d82892a]47 print("Unknown host architecture %s" % config.HOSTARCH, file=sys.stderr)
[575a6e5]48 sys.exit(1)
49
[f3b9efc]50 if arch:
51 try:
[5bf1f3e]52 arch = Architecture.make_canonical( arch )
[f3b9efc]53 except KeyError:
[d82892a]54 print("Unknown architecture %s" % arch, file=sys.stderr)
[f3b9efc]55 sys.exit(1)
[575a6e5]56
57 if arch and arch != canonical_host:
58 self.target = arch
59 self.cross_compile = True
60 else:
61 self.target = canonical_host
62 self.cross_compile = False
[47c1928]63
64
65 try :
66 self.flags = Architecture.CrossCompileFlags[self.target]
67 except KeyError:
68 print("Cross compilation not available for architecture %s" % self.target, file=sys.stderr)
69 sys.exit(1)
[575a6e5]70
[f3b9efc]71 self.string = self.target
72
73 def update(self):
74 if not self.cross_compile:
75 self.target = machine_default()
76 self.string = self.target
77 print("updated to %s" % self.target)
78
79 def match(self, arch):
80 return True if not arch else self.target == arch
81
82 @classmethod
[5bf1f3e]83 def make_canonical(_, arch):
[f3b9efc]84 return Architecture.KnownArchitectures[arch]
85
[bacc36c]86
[f3b9efc]87class Debug:
88 def __init__(self, value):
89 self.string = "debug" if value else "no debug"
[a45fc7b]90 self.flags = """DEBUG_FLAGS=%s""" % ("-debug -O0" if value else "-nodebug -O2")
[d65f92c]91 self.path = "debug" if value else "nodebug"
[bacc36c]92
[a5121bf]93class Install:
94 def __init__(self, value):
[d65f92c]95 if value:
96 distribute = False
97
[abec2f8]98 self.string = "installed" if value else "in tree"
[158b026]99 self.flags = """installed=%s""" % ("yes" if value else "no")
[a5121bf]100
[afe8882]101class Timeouts:
102 def __init__(self, ts, tg):
103 self.single = Timeouts.check(ts)
104 self.total = Timeouts.check(tg)
105
106 @classmethod
107 def check(_, value):
108 if value < 1:
109 print("Timeouts must be at least 1 second", file=sys.stderr)
110 sys.exit(1)
111
112 return value
113
[bacc36c]114def init( options ):
115 global arch
[6daaee3]116 global archive
117 global debug
118 global distcc
[bacc36c]119 global dry_run
120 global generating
[a5121bf]121 global install
[6daaee3]122 global make
[5bf1f3e]123 global output_width
[6daaee3]124 global timeout
[bacc36c]125
[6daaee3]126 arch = Architecture(options.arch)
127 archive = os.path.abspath(os.path.join(original_path, options.archive_errors)) if options.archive_errors else None
128 debug = Debug(options.debug)
[8209e70]129 dry_run = options.dry_run # must be called before tools.config_hash()
[6daaee3]130 distcc = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash()
[5bf1f3e]131 generating = options.regenerate_expected
132 install = Install(options.install)
[6daaee3]133 make = ['make']
[5bf1f3e]134 output_width = 24
[6daaee3]135 timeout = Timeouts(options.timeout, options.global_timeout)
[bacc36c]136
[17bc05b]137 # if we distribute, distcc errors will fail tests, use log file for distcc
138 # don't use "'DISTCC_LOG' not in os.environ" because it can be set to ''
[d65f92c]139 if distribute and not os.environ.get('DISTCC_LOG'):
140 os.putenv('DISTCC_LOG', os.path.join(BUILDDIR, 'distcc_error.log'))
[f85bc15]141
[5bf1f3e]142def update_make_cmd(force, jobs):
[bacc36c]143 global make
144
[a45fc7b]145 make = ['make'] if not force else ['make', "-j%i" % jobs]
[28582b2]146
147def validate():
[afe8882]148 errf = os.path.join(BUILDDIR, ".validate.err")
[d65f92c]149 make_ret, out = tools.make( ".validate", error_file = errf, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL )
[28582b2]150 if make_ret != 0:
[afe8882]151 with open (errf, "r") as myfile:
[28582b2]152 error=myfile.read()
[575a6e5]153 print("ERROR: Invalid configuration %s:%s" % (arch.string, debug.string), file=sys.stderr)
[28582b2]154 print(" verify returned : \n%s" % error, file=sys.stderr)
[afe8882]155 tools.rm(errf)
[28582b2]156 sys.exit(1)
157
[d3c1c6a]158 tools.rm(errf)
159
160def prep_output(tests):
[5bf1f3e]161 global output_width
162 output_width = max(map(lambda t: len(t.target()), tests))
Note: See TracBrowser for help on using the repository browser.