Changeset f3b9efc
- Timestamp:
- Dec 5, 2017, 1:29:12 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 86ad276
- Parents:
- 099a40d
- Location:
- src/tests
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/pybin/settings.py
r099a40d rf3b9efc 1 import sys 1 2 2 3 class Architecture: 3 def __init__(self, cmd): 4 if cmd: 4 KnownArchitectures = { 5 'x64' : 'x64', 6 'x86-64' : 'x64', 7 'x86' : 'x86', 8 'i386' : 'x86', 9 'i486' : 'x86', 10 'i686' : 'x86', 11 'Intel 80386' : 'x86', 12 'arm' : 'arm', 13 'ARM' : 'arm', 14 } 15 16 def __init__(self, arch): 17 if arch: 5 18 self.cross_compile = True 6 self.target = cmd 19 try: 20 self.target = Architecture.makeCanonical( arch ) 21 except KeyError: 22 print("Unkown architecture %s" % arch) 23 sys.exit(1) 7 24 else: 8 25 self.cross_compile = False 9 self.target = 'x64' 26 try: 27 arch = machine_default() 28 self.target = Architecture.makeCanonical( arch ) 29 except KeyError: 30 print("Running on unkown architecture %s" % arch) 31 sys.exit(1) 10 32 11 def toString(self): 12 return self.target 33 self.string = self.target 34 35 def update(self): 36 if not self.cross_compile: 37 self.target = machine_default() 38 self.string = self.target 39 print("updated to %s" % self.target) 40 41 def match(self, arch): 42 return True if not arch else self.target == arch 43 44 @classmethod 45 def makeCanonical(_, arch): 46 return Architecture.KnownArchitectures[arch] 47 48 49 class Debug: 50 def __init__(self, value): 51 self.string = "debug" if value else "no debug" 52 self.flags = """DEBUG_FLAGS="%s" """ % ("-debug" if value else "-nodebug") 13 53 14 54 def init( options ): … … 20 60 global debugFlag 21 61 22 arch = Architecture(options.arch)23 62 dry_run = options.dry_run 24 63 generating = options.regenerate_expected 25 make = ' ./make_command_not_initialized'26 debug = "debug" if options.debug else "no debug"27 debugFlag = """DEBUG_FLAGS="%s" """ % ("-debug" if debug else "-nodebug")64 make = 'make' 65 debug = Debug(options.debug) 66 arch = Architecture(options.arch) 28 67 29 68 def updateMakeCmd(force, jobs): 30 69 global make 31 70 32 make = "make" if force else ("make -j%i" % jobs) 71 make = "make" if not force else ("make -j%i" % jobs) 72 73 74 def set_machine_default( func ): 75 global machine_default 76 77 machine_default = func -
src/tests/pybin/test_run.py
r099a40d rf3b9efc 21 21 22 22 def expect(self): 23 return ("%s/.expect/%s .txt" % (self.path, self.name))23 return ("%s/.expect/%s%s.txt" % (self.path, self.name, '' if not self.arch else ".%s" % self.arch)) 24 24 25 25 def error_log(self): … … 39 39 40 40 @classmethod 41 def valid_name( cls, name):41 def valid_name(_, name): 42 42 return not name.endswith( ('.c', '.cc', '.cpp', '.cfa') ) 43 43 44 44 @classmethod 45 def from_target( cls, target):45 def from_target(_, target): 46 46 test = Test() 47 47 test.name = os.path.basename(target) -
src/tests/pybin/tools.py
r099a40d rf3b9efc 76 76 '-s' if silent else '', 77 77 test_param, 78 settings.debug Flag,78 settings.debug.flags, 79 79 flags, 80 80 target, … … 147 147 # parses the Makefile to find the machine type (32-bit / 64-bit) 148 148 def getMachineType(): 149 return 'x64'150 149 sh('echo "void ?{}(int&a,int b){}int main(){return 0;}" > .dummy.c') 151 150 ret, out = make('.dummy', silent = True) … … 161 160 rm( (".dummy.c",".dummy") ) 162 161 163 return out 164 return re.search("ELF\s([0-9]+)-bit", out).group(1) 162 if settings.dry_run : 163 return 'x64' 164 165 return re.search(r"[^,]+,([^,]+),", out).group(1).strip() 165 166 166 167 # count number of jobs to create … … 213 214 raise argparse.ArgumentTypeError(msg) 214 215 return False 216 217 218 settings.set_machine_default( getMachineType ) -
src/tests/test.py
r099a40d rf3b9efc 17 17 expected = [] 18 18 19 def findTest(path):19 def matchTest(path): 20 20 match = re.search("(\.[\w\/\-_]*)\/.expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt", path) 21 21 if match : … … 24 24 test.path = match.group(1) 25 25 test.arch = match.group(3)[1:] if match.group(3) else None 26 expected.append(test) 27 28 pathWalk( findTest ) 26 if settings.arch.match(test.arch): 27 expected.append(test) 28 29 pathWalk( matchTest ) 29 30 30 31 return expected … … 77 78 78 79 # make sure we have at least some test to run 79 if tests :80 if not tests : 80 81 print('ERROR: No valid test to run', file=sys.stderr) 81 82 sys.exit(1) … … 139 140 ) 140 141 141 retcode = 0142 error = None143 144 142 # if the make command succeds continue otherwise skip to diff 145 143 if make_ret == 0 or settings.dry_run: … … 149 147 else : 150 148 # simply cat the result into the output 151 sh("cat %s > %s" % (test.target(), out_file))149 retcode, _ = sh("cat %s > %s" % (test.target(), out_file)) 152 150 else: 153 sh("mv %s %s" % (err_file, out_file))151 retcode, _ = sh("mv %s %s" % (err_file, out_file)) 154 152 155 153 … … 161 159 error = "\t\tNo make target for test %s!" % test.target() 162 160 sh("rm %s" % out_file, False) 161 else: 162 error = None 163 163 else : 164 164 # fetch return code and error from the diff command … … 250 250 tests = allTests 251 251 252 #otherwise we need to validate that the test list that was entered is valid 252 253 else : 253 #otherwise we need to validate that the test list that was entered is valid254 254 tests = validTests( options ) 255 255 256 256 # sort the test alphabetically for convenience 257 tests.sort(key=lambda t: t.target())257 tests.sort(key=lambda t: (t.arch if t.arch else '') + t.target()) 258 258 259 259 # users may want to simply list the tests 260 260 if options.list_comp : 261 print("-h --help --debug --dry-run --list --a ll --regenerate-expected -j --jobs ", end='')261 print("-h --help --debug --dry-run --list --arch --all --regenerate-expected -j --jobs ", end='') 262 262 print(" ".join(map(lambda t: "%s" % (t.target()), tests))) 263 263 264 264 elif options.list : 265 print("Listing for %s:%s"% (settings.arch. toString(), settings.debug))265 print("Listing for %s:%s"% (settings.arch.string, settings.debug.string)) 266 266 print("\n".join(map(lambda t: "%s" % (t.toString()), tests))) 267 267 … … 272 272 print('%s (%s:%s) on %i cores' % ( 273 273 'Regenerate tests' if settings.generating else 'Running', 274 settings.arch. toString(),275 settings.debug ,274 settings.arch.string, 275 settings.debug.string, 276 276 options.jobs 277 277 ))
Note: See TracChangeset
for help on using the changeset viewer.