Changeset c2d5e28
- Timestamp:
- May 11, 2017, 3:29:00 PM (8 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:
- 9738e74
- Parents:
- 6a4f3d4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/test.py
r6a4f3d4 rc2d5e28 23 23 def __init__(self, name, path): 24 24 self.name, self.path = name, path 25 26 class TestResult: 27 SUCCESS = 0 28 FAILURE = 1 29 TIMEOUT = 124 25 30 26 31 # parses the Makefile to find the machine type (32-bit / 64-bit) … … 163 168 make_ret, _ = sh("""%s test=yes EXTRA_FLAGS="%s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run) 164 169 170 retcode = 0 171 error = None 172 165 173 # if the make command succeds continue otherwise skip to diff 166 174 if make_ret == 0 : … … 170 178 if fileIsExecutable(test.name) : 171 179 # run test 172 sh("./%s %s > %s 2>&1" % (test.name, stdinput, out_file), dry_run)180 retcode, _ = sh("timeout 60 ./%s %s > %s 2>&1" % (test.name, stdinput, out_file), dry_run) 173 181 else : 174 182 # simply cat the result into the output … … 179 187 sh("mv %s %s" % (err_file, out_file), dry_run) 180 188 181 retcode = 0 182 error = None 183 184 if generate : 185 # if we are ounly generating the output we still need to check that the test actually exists 186 if not dry_run and fileContainsOnly(out_file, "make: *** No rule to make target `%s'. Stop." % test.name) : 187 retcode = 1; 188 error = "\t\tNo make target for test %s!" % test.name 189 sh("rm %s" % out_file, False) 190 191 else : 192 # fetch return code and error from the diff command 193 retcode, error = diff(".expect/%s.txt" % test.path, ".out/%s.log" % test.name, dry_run) 194 189 if retcode == 0: 190 if generate : 191 # if we are ounly generating the output we still need to check that the test actually exists 192 if not dry_run and fileContainsOnly(out_file, "make: *** No rule to make target `%s'. Stop." % test.name) : 193 retcode = 1; 194 error = "\t\tNo make target for test %s!" % test.name 195 sh("rm %s" % out_file, False) 196 else : 197 # fetch return code and error from the diff command 198 retcode, error = diff(".expect/%s.txt" % test.path, ".out/%s.log" % test.name, dry_run) 195 199 # clean the executable 196 200 sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run) … … 205 209 name_txt = "%20s " % t.name 206 210 207 #run the test instance and collect the result 208 test_failed, error = run_single_test(t, generate, dry_run, debug) 211 retcode, error = run_single_test(t, generate, dry_run, debug) 209 212 210 213 # update output based on current action 211 214 if generate : 212 failed_txt = "ERROR" 213 success_txt = "Done" 214 else : 215 failed_txt = "FAILED" 216 success_txt = "PASSED" 215 if retcode == TestResult.SUCCESS: result_txt = "Done" 216 elif retcode == TestResult.TIMEOUT: result_txt = "TIMEOUT" 217 else : result_txt = "ERROR" 218 else : 219 if retcode == TestResult.SUCCESS: result_txt = "PASSED" 220 elif retcode == TestResult.TIMEOUT: result_txt = "TIMEOUT" 221 else : result_txt = "FAILED" 217 222 218 223 #print result with error if needed 219 text = name_txt + (failed_txt if test_failed else success_txt)224 text = name_txt + result_txt 220 225 out = sys.stdout 221 226 if error : … … 223 228 out = sys.stderr 224 229 225 print(text, file = out) ;230 print(text, file = out) 226 231 sys.stdout.flush() 227 232 sys.stderr.flush() 228 233 signal.signal(signal.SIGINT, signal.SIG_IGN) 229 234 230 return test_failed235 return retcode != TestResult.SUCCESS 231 236 232 237 # run the given list of tests with the given parameters
Note: See TracChangeset
for help on using the changeset viewer.