Changeset 5bf1f3e
- Timestamp:
- Mar 26, 2019, 10:36:58 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 1bb2488
- Parents:
- eb60b04
- Location:
- tests
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/pybin/settings.py
reb60b04 r5bf1f3e 37 37 def __init__(self, arch): 38 38 try: 39 canonical_host = Architecture.make Canonical( config.HOSTARCH )39 canonical_host = Architecture.make_canonical( config.HOSTARCH ) 40 40 except KeyError: 41 41 print("Unkown host architecture %s" % config.HOSTARCH, file=sys.stderr) … … 44 44 if arch: 45 45 try: 46 arch = Architecture.make Canonical( arch )46 arch = Architecture.make_canonical( arch ) 47 47 except KeyError: 48 48 print("Unkown architecture %s" % arch, file=sys.stderr) … … 75 75 76 76 @classmethod 77 def make Canonical(_, arch):77 def make_canonical(_, arch): 78 78 return Architecture.KnownArchitectures[arch] 79 79 … … 110 110 global install 111 111 global timeout 112 global width112 global output_width 113 113 114 dry_run = options.dry_run115 generating = options.regenerate_expected116 make = 'make'117 debug 118 install = Install(options.install)119 arch = Architecture(options.arch)120 timeout = Timeouts(options.timeout, options.global_timeout)121 width= 24114 dry_run = options.dry_run 115 generating = options.regenerate_expected 116 make = 'make' 117 debug = Debug(options.debug) 118 install = Install(options.install) 119 arch = Architecture(options.arch) 120 timeout = Timeouts(options.timeout, options.global_timeout) 121 output_width = 24 122 122 123 123 124 def update MakeCmd(force, jobs):124 def update_make_cmd(force, jobs): 125 125 global make 126 126 … … 141 141 142 142 def prep_output(tests): 143 global width144 width = max(map(lambda t: len(t.target()), tests))143 global output_width 144 output_width = max(map(lambda t: len(t.target()), tests)) -
tests/pybin/test_run.py
reb60b04 r5bf1f3e 4 4 5 5 import pybin.settings 6 import datetime7 8 from string import Template9 10 class DeltaTemplate(Template):11 delimiter = "%"12 13 def strfdelta(tdelta, fmt):14 d["H"], rem = divmod(tdelta.seconds, 3600)15 d["M"], d["S"] = divmod(rem, 60)16 t = DeltaTemplate(fmt)17 return t.substitute(**d)18 6 19 7 # Test class that defines what a test is -
tests/pybin/tools.py
reb60b04 r5bf1f3e 55 55 return match.group(1).startswith("ASCII text") 56 56 57 def is_exe(fname): 58 return os.path.isfile(fname) and os.access(fname, os.X_OK) 59 57 60 # Remove 1 or more files silently 58 61 def rm( files ): … … 79 82 # diff the output of the files 80 83 diff_cmd = ("diff --text " 81 # "--ignore-all-space " 82 # "--ignore-blank-lines " 83 "--old-group-format='\t\tmissing lines :\n" 84 "%%<' \\\n" 85 "--new-group-format='\t\tnew lines :\n" 86 "%%>' \\\n" 87 "--unchanged-group-format='%%=' \\" 88 "--changed-group-format='\t\texpected :\n" 89 "%%<" 90 "\t\tgot :\n" 91 "%%>\n' \\\n" 92 "--new-line-format='\t\t%%dn\t%%L' \\\n" 93 "--old-line-format='\t\t%%dn\t%%L' \\\n" 94 "--unchanged-line-format='' \\\n" 95 "%s %s") 84 "--old-group-format='\t\tmissing lines :\n" 85 "%%<' \\\n" 86 "--new-group-format='\t\tnew lines :\n" 87 "%%>' \\\n" 88 "--unchanged-group-format='%%=' \\" 89 "--changed-group-format='\t\texpected :\n" 90 "%%<" 91 "\t\tgot :\n" 92 "%%>\n' \\\n" 93 "--new-line-format='\t\t%%dn\t%%L' \\\n" 94 "--old-line-format='\t\t%%dn\t%%L' \\\n" 95 "--unchanged-line-format='' \\\n" 96 "%s %s") 96 97 97 98 # fetch return code and error from the diff command … … 115 116 116 117 def which(program): 117 import os118 def is_exe(fpath):119 return os.path.isfile(fpath) and os.access(fpath, os.X_OK)120 121 118 fpath, fname = os.path.split(program) 122 119 if fpath: … … 160 157 161 158 # helper function to check if a files contains only a specific string 162 def file ContainsOnly(file, text) :159 def file_contains_only(file, text) : 163 160 with open(file) as f: 164 161 ff = f.read().strip() 165 162 result = ff == text.strip() 166 163 167 return result; 168 169 # check whether or not a file is executable 170 def fileIsExecutable(file) : 171 try : 172 fileinfo = os.stat(file) 173 return bool(fileinfo.st_mode & stat.S_IXUSR) 174 except Exception as inst: 175 print(type(inst)) # the exception instance 176 print(inst.args) # arguments stored in .args 177 print(inst) 178 return False 164 return result 179 165 180 166 # transform path to canonical form 181 def canonical Path(path):167 def canonical_path(path): 182 168 abspath = os.path.abspath(__main__.__file__) 183 169 dname = os.path.dirname(abspath) … … 185 171 186 172 # compare path even if form is different 187 def path Cmp(lhs, rhs):188 return canonical Path( lhs ) == canonicalPath( rhs )173 def path_cmp(lhs, rhs): 174 return canonical_path( lhs ) == canonical_path( rhs ) 189 175 190 176 # walk all files in a path 191 def pathWalk( op ): 192 def step(_, dirname, names): 193 for name in names: 194 path = os.path.join(dirname, name) 195 op( path ) 196 197 # Start the walk 177 def path_walk( op ): 198 178 dname = settings.SRCDIR 199 179 for dirname, _, names in os.walk(dname): … … 206 186 ################################################################################ 207 187 # count number of jobs to create 208 def job Count( options, tests ):188 def job_count( options, tests ): 209 189 # check if the user already passed in a number of jobs for multi-threading 210 190 if not options.jobs: … … 229 209 230 210 # setup a proper processor pool with correct signal handling 231 def setup Pool(jobs):211 def setup_pool(jobs): 232 212 original_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_IGN) 233 213 pool = multiprocessing.Pool(jobs) … … 261 241 return False 262 242 raise argparse.ArgumentTypeError(msg) 263 return False264 243 265 244 def fancy_print(text): … … 273 252 274 253 275 def core Info(path):254 def core_info(path): 276 255 cmd = os.path.join(settings.SRCDIR, "pybin/print-core.gdb") 277 256 if not os.path.isfile(cmd): -
tests/test.py
reb60b04 r5bf1f3e 14 14 ################################################################################ 15 15 16 def find Tests():16 def find_tests(): 17 17 expected = [] 18 18 19 def match Test(path):19 def match_test(path): 20 20 match = re.search("^%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt$" % settings.SRCDIR, path) 21 21 if match : … … 27 27 expected.append(test) 28 28 29 path Walk( matchTest )29 path_walk( match_test ) 30 30 31 31 return expected 32 32 33 33 # reads the directory ./.expect and indentifies the tests 34 def list Tests( includes, excludes ):34 def list_tests( includes, excludes ): 35 35 # tests directly in the .expect folder will always be processed 36 test_list = find Tests()36 test_list = find_tests() 37 37 38 38 # if we have a limited number of includes, filter by them … … 51 51 52 52 # from the found tests, filter all the valid tests/desired tests 53 def valid Tests( options ):53 def valid_tests( options ): 54 54 tests = [] 55 55 … … 58 58 if options.regenerate_expected : 59 59 for testname in options.tests : 60 testname = canonical Path( testname )60 testname = canonical_path( testname ) 61 61 if Test.valid_name(testname): 62 found = [test for test in all Tests if canonicalPath( test.target() ) == testname]62 found = [test for test in all_tests if canonical_path( test.target() ) == testname] 63 63 tests.append( found[0] if len(found) == 1 else Test.from_target(testname) ) 64 64 else : … … 68 68 # otherwise we only need to validate that all tests are present in the complete list 69 69 for testname in options.tests: 70 test = [t for t in all Tests if pathCmp( t.target(), testname )]70 test = [t for t in all_tests if path_cmp( t.target(), testname )] 71 71 72 72 if test : … … 78 78 79 79 # parses the option 80 def getOptions():80 def parse_args(): 81 81 # create a parser with the arguments for the tests script 82 82 parser = argparse.ArgumentParser(description='Script which runs cforall tests') … … 123 123 return val == 0 or settings.dry_run 124 124 125 def isExe(file): 126 return settings.dry_run or fileIsExecutable(file) 127 128 def noRule(file, target): 129 return not settings.dry_run and fileContainsOnly(file, "make: *** No rule to make target `%s'. Stop." % target) 125 def no_rule(file, target): 126 return not settings.dry_run and file_contains_only(file, "make: *** No rule to make target `%s'. Stop." % target) 130 127 131 128 # logic to run a single test and return the result (No handling of printing or other test framework logic) … … 150 147 if success(make_ret): 151 148 with Timed() as run_dur: 152 if isExe(exe_file):149 if settings.dry_run or is_exe(exe_file): 153 150 # run test 154 151 retcode = run(exe_file, out_file, in_file) … … 162 159 if settings.generating : 163 160 # if we are ounly generating the output we still need to check that the test actually exists 164 if no Rule(out_file, test.target()) :161 if no_rule(out_file, test.target()) : 165 162 retcode = 1 166 163 error = "\t\tNo make target for test %s!" % test.target() … … 176 173 error = myfile.read() 177 174 178 ret, info = core Info(exe_file)175 ret, info = core_info(exe_file) 179 176 error = error + info 180 177 … … 190 187 with SignalHandling(): 191 188 # print formated name 192 name_txt = '{0:{width}} '.format(t.target(), width=settings. width)189 name_txt = '{0:{width}} '.format(t.target(), width=settings.output_width) 193 190 194 191 retcode, error, duration = run_single_test(t) … … 216 213 217 214 # create the executor for our jobs and handle the signal properly 218 pool = setup Pool(jobs)215 pool = setup_pool(jobs) 219 216 220 217 # for each test to run … … 246 243 247 244 # parse the command line arguments 248 options = getOptions()245 options = parse_args() 249 246 250 247 # init global settings … … 252 249 253 250 # fetch the liest of all valid tests 254 all Tests = listTests( options.include, options.exclude )251 all_tests = list_tests( options.include, options.exclude ) 255 252 256 253 257 254 # if user wants all tests than no other treatement of the test list is required 258 255 if options.all or options.list or options.list_comp or options.include : 259 tests = all Tests256 tests = all_tests 260 257 261 258 #otherwise we need to validate that the test list that was entered is valid 262 259 else : 263 tests = valid Tests( options )260 tests = valid_tests( options ) 264 261 265 262 # make sure we have at least some test to run … … 286 283 settings.validate() 287 284 288 options.jobs, forceJobs = job Count( options, tests )289 settings.update MakeCmd(forceJobs, options.jobs)285 options.jobs, forceJobs = job_count( options, tests ) 286 settings.update_make_cmd(forceJobs, options.jobs) 290 287 291 288 print('%s (%s:%s) on %i cores' % (
Note: See TracChangeset
for help on using the changeset viewer.