-
Notifications
You must be signed in to change notification settings - Fork 2
/
findfailures.py
42 lines (37 loc) · 1.14 KB
/
findfailures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import subprocess
import sys
import glob
corpus = sys.argv[1]
cmd = "./Tests --input_test_file "
crashes = {}
fatals = {}
for f in glob.glob(corpus + "/*"):
with open("test.out", 'w') as outf:
subprocess.call([cmd + f], shell=True, stdout=outf, stderr=outf)
crashline = None
fatalline = None
stepcount = 0
with open("test.out", 'r') as inf:
for line in inf:
if "Crash" in line:
crashline = line
if "FATAL" in line:
fatalline = line
if "STEP" in line:
stepcount += 1
if crashline is not None:
if crashline not in crashes:
crashes[crashline] = (stepcount, f)
else:
if stepcount < crashes[crashline][0]:
crashes[crashline] = (stepcount, f)
if fatalline is not None:
if fatalline not in fatals:
fatals[fatalline] = (stepcount, f)
else:
if stepcount < fatals[fatalline][0]:
fatals[fatalline] = (stepcount, f)
for fatal in fatals:
print fatal, fatals[fatal]
for crash in crashes:
print crash, crashes[crash]