Changes in src/tests/test.py [c2d5e28:c07d724]
- File:
-
- 1 edited
-
src/tests/test.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/test.py
rc2d5e28 rc07d724 24 24 self.name, self.path = name, path 25 25 26 class TestResult:27 SUCCESS = 028 FAILURE = 129 TIMEOUT = 12430 31 26 # parses the Makefile to find the machine type (32-bit / 64-bit) 32 27 def getMachineType(): 33 28 sh('echo "void ?{}(int*a,int b){}int main(){return 0;}" > .dummy.c') 34 29 ret, out = sh("make .dummy -s", print2stdout=True) 35 30 36 31 if ret != 0: 37 32 print("Failed to identify architecture:") … … 166 161 167 162 # build, skipping to next test on error 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) 169 170 retcode = 0 171 error = None 163 make_ret, _ = sh("""%s test=yes EXTRA_FLAGS="-quiet %s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run) 172 164 173 165 # if the make command succeds continue otherwise skip to diff … … 178 170 if fileIsExecutable(test.name) : 179 171 # run test 180 retcode, _ = sh("timeout 60./%s %s > %s 2>&1" % (test.name, stdinput, out_file), dry_run)172 sh("./%s %s > %s 2>&1" % (test.name, stdinput, out_file), dry_run) 181 173 else : 182 174 # simply cat the result into the output … … 187 179 sh("mv %s %s" % (err_file, out_file), dry_run) 188 180 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) 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 199 195 # clean the executable 200 196 sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run) … … 209 205 name_txt = "%20s " % t.name 210 206 211 retcode, error = run_single_test(t, generate, dry_run, debug) 207 #run the test instance and collect the result 208 test_failed, error = run_single_test(t, generate, dry_run, debug) 212 209 213 210 # update output based on current action 214 211 if generate : 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" 212 failed_txt = "ERROR" 213 success_txt = "Done" 214 else : 215 failed_txt = "FAILED" 216 success_txt = "PASSED" 222 217 223 218 #print result with error if needed 224 text = name_txt + result_txt219 text = name_txt + (failed_txt if test_failed else success_txt) 225 220 out = sys.stdout 226 221 if error : … … 228 223 out = sys.stderr 229 224 230 print(text, file = out) 225 print(text, file = out); 231 226 sys.stdout.flush() 232 227 sys.stderr.flush() 233 228 signal.signal(signal.SIGINT, signal.SIG_IGN) 234 229 235 return retcode != TestResult.SUCCESS230 return test_failed 236 231 237 232 # run the given list of tests with the given parameters … … 274 269 if __name__ == "__main__": 275 270 #always run from same folder 276 chdir() 277 271 chdir() 272 278 273 # parse the command line arguments 279 274 options = getOptions()
Note:
See TracChangeset
for help on using the changeset viewer.