|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
3 | | -importos |
4 | | -importsys |
5 | | -importtimedRun |
6 | | - |
7 | 3 | fromoptparseimportOptionParser |
8 | | -path0=os.path.dirname(os.path.abspath(__file__)) |
9 | | -path1=os.path.abspath(os.path.join(path0,os.pardir,'util')) |
10 | | -sys.path.append(path1) |
11 | | -importfileIngredients |
| 4 | + |
| 5 | +importtimedRun |
12 | 6 |
|
13 | 7 |
|
14 | 8 | defparseOptions(arguments): |
15 | 9 | parser=OptionParser() |
16 | 10 | parser.disable_interspersed_args() |
17 | | -parser.add_option('-r','--regex',action='store_true',dest='useRegex', |
18 | | -default=False, |
19 | | -help='Allow search for regular expressions instead of strings.') |
20 | | -parser.add_option('-s','--sig',action='store',dest='sig', |
21 | | -default='', |
22 | | -help='Optionally set the crash signature. Defaults to "%default".') |
23 | 11 | parser.add_option('-t','--timeout',type='int',action='store',dest='condTimeout', |
24 | 12 | default=120, |
25 | 13 | help='Optionally set the timeout. Defaults to "%default" seconds.') |
26 | 14 |
|
27 | 15 | options,args=parser.parse_args(arguments) |
28 | 16 |
|
29 | | -returnoptions.useRegex,options.sig,options.condTimeout,args |
| 17 | +returnoptions.condTimeout,args |
30 | 18 |
|
31 | 19 |
|
32 | 20 | definteresting(cliArgs,tempPrefix): |
33 | | - (regexEnabled,crashSig,timeout,args)=parseOptions(cliArgs) |
34 | | - |
35 | | -# Examine stack for crash signature, this is needed if crashSig is specified. |
36 | | -wantStack= (crashSig!='') |
37 | | -runinfo=timedRun.timed_run(args,timeout,tempPrefix,wantStack) |
| 21 | + (timeout,args)=parseOptions(cliArgs) |
38 | 22 |
|
| 23 | +runinfo=timedRun.timed_run(args,timeout,tempPrefix) |
39 | 24 | timeString=" (%.3f seconds)"%runinfo.elapsedtime |
40 | | - |
41 | | -crashLogName=tempPrefix+"-crash.txt" |
42 | | - |
43 | 25 | ifruninfo.sta==timedRun.CRASHED: |
44 | | -ifnotwantStack: |
45 | | -print'Exit status: '+runinfo.msg+timeString |
46 | | -returnTrue |
47 | | -elifos.path.exists(crashLogName): |
48 | | -# When using this script, remember to escape characters, e.g. "\(" instead of "(" ! |
49 | | -found,foundSig=fileIngredients.fileContains(crashLogName,crashSig,regexEnabled) |
50 | | -iffound: |
51 | | -print'Exit status: '+runinfo.msg+timeString |
52 | | -returnTrue |
53 | | -else: |
54 | | -print"[Uninteresting] It crashed somewhere else!"+timeString |
55 | | -returnFalse |
56 | | -else: |
57 | | -print"[Uninteresting] It appeared to crash, but no crash log was found?"+timeString |
58 | | -returnFalse |
| 26 | +print'Exit status: '+runinfo.msg+timeString |
| 27 | +returnTrue |
59 | 28 | else: |
60 | 29 | print"[Uninteresting] It didn't crash."+timeString |
61 | 30 | returnFalse |