Changeset 91788fa for src/tests/pybin
- Timestamp:
- Jul 25, 2018, 6:23:58 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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- a95c117, f0b3f51
- Parents:
- 40a7d9c (diff), e89f4b1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/tests/pybin
- Files:
-
- 3 edited
-
settings.py (modified) (4 diffs)
-
test_run.py (modified) (2 diffs)
-
tools.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/pybin/settings.py
r40a7d9c r91788fa 1 from __future__ import print_function 2 3 import os 1 4 import sys 5 6 try : 7 sys.path.append(os.getcwd()) 8 import config 9 10 SRCDIR = os.path.abspath(config.SRCDIR) 11 BUILDDIR = os.path.abspath(config.BUILDDIR) 12 except: 13 print('ERROR: missing config.py, re-run configure script.', file=sys.stderr) 14 sys.exit(1) 2 15 3 16 class Architecture: … … 5 18 'x64' : 'x64', 6 19 'x86-64' : 'x64', 20 'x86_64' : 'x64', 7 21 'x86' : 'x86', 8 22 'i386' : 'x86', … … 25 39 self.cross_compile = False 26 40 try: 27 arch = machine_default()41 arch = config.HOSTARCH 28 42 self.target = Architecture.makeCanonical( arch ) 29 43 except KeyError: … … 66 80 arch = Architecture(options.arch) 67 81 82 68 83 def updateMakeCmd(force, jobs): 69 84 global make 70 85 71 86 make = "make" if not force else ("make -j%i" % jobs) 72 73 74 def set_machine_default( func ):75 global machine_default76 77 machine_default = func -
src/tests/pybin/test_run.py
r40a7d9c r91788fa 33 33 34 34 def expect(self): 35 return ("%s /.expect/%s%s.txt" % (self.path, self.name, '' if not self.arch else ".%s" % self.arch))35 return ("%s.expect/%s%s.txt" % (os.path.join(settings.SRCDIR, self.path), self.name, '' if not self.arch else ".%s" % self.arch)) 36 36 37 37 def error_log(self): 38 return ("%s /.err/%s.log" % (self.path, self.name))38 return ("%s.err/%s.log" % (os.path.join(settings.BUILDDIR, self.path), self.name)) 39 39 40 40 def output_log(self): 41 return ("%s /.out/%s.log" % (self.path, self.name))41 return ("%s.out/%s.log" % (os.path.join(settings.BUILDDIR, self.path), self.name)) 42 42 43 43 def input(self): 44 return ("%s /.in/%s.txt" % (self.path, self.name))44 return ("%s.in/%s.txt" % (os.path.join(settings.SRCDIR, self.path), self.name)) 45 45 46 46 def target_output(self): … … 49 49 def target(self): 50 50 return os.path.join(self.path, self.name) 51 52 def target_executable(self): 53 return os.path.join(settings.BUILDDIR, self.path, self.name) 51 54 52 55 @classmethod -
src/tests/pybin/tools.py
r40a7d9c r91788fa 9 9 import stat 10 10 import sys 11 import fileinput 11 12 12 13 from pybin import settings … … 33 34 out, err = proc.communicate() 34 35 return proc.returncode, out 36 37 def is_ascii(fname): 38 if not os.path.isfile(fname): 39 return False 40 41 code, out = sh("file %s" % fname, print2stdout = False) 42 if code != 0: 43 return False 44 45 match = re.search(".*: (.*)", out) 46 47 if not match: 48 return False 49 50 return match.group(1) == "ASCII text" 35 51 36 52 # Remove 1 or more files silently … … 105 121 # helper function to replace patterns in a file 106 122 def file_replace(fname, pat, s_after): 107 # first, see if the pattern is even in the file. 108 with open(fname) as f: 109 if not any(re.search(pat, line) for line in f): 110 return # pattern does not occur in file so we are done. 111 112 # pattern is in the file, so perform replace operation. 113 with open(fname) as f: 114 out_fname = fname + ".tmp" 115 out = open(out_fname, "w") 116 for line in f: 117 out.write(re.sub(pat, s_after, line)) 118 out.close() 119 os.rename(out_fname, fname) 123 file = fileinput.FileInput(fname, inplace=True, backup='.bak') 124 for line in file: 125 print(line.replace(pat, s_after), end='') 126 file.close() 120 127 121 128 # helper function to check if a files contains only a specific string … … 140 147 # transform path to canonical form 141 148 def canonicalPath(path): 142 return os.path.join('.', os.path.normpath(path) ) 149 abspath = os.path.abspath(__main__.__file__) 150 dname = os.path.dirname(abspath) 151 return os.path.join(dname, os.path.normpath(path) ) 143 152 144 153 # compare path even if form is different … … 151 160 for name in names: 152 161 path = os.path.join(dirname, name) 153 154 162 op( path ) 155 163 156 164 # Start the walk 157 os.path.walk('.', step, '') 165 abspath = os.path.abspath(__main__.__file__) 166 dname = os.path.dirname(abspath) 167 os.path.walk(dname, step, '') 158 168 159 169 ################################################################################ 160 170 # system 161 171 ################################################################################ 162 163 # parses the Makefile to find the machine type (32-bit / 64-bit)164 def getMachineType():165 sh('echo "void ?{}(int&a,int b){}int main(){return 0;}" > .dummy.c')166 ret, out = make('.dummy', silent = True)167 168 if ret != 0:169 print("Failed to identify architecture:")170 print(out)171 print("Stopping")172 rm( (".dummy.c",".dummy") )173 sys.exit(1)174 175 _, out = sh("file .dummy", print2stdout=False)176 rm( (".dummy.c",".dummy") )177 178 if settings.dry_run :179 return 'x64'180 181 return re.search(r"[^,]+,([^,]+),", out).group(1).strip()182 183 172 # count number of jobs to create 184 173 def jobCount( options, tests ): … … 244 233 else: 245 234 print(text) 246 247 settings.set_machine_default( getMachineType )
Note:
See TracChangeset
for help on using the changeset viewer.