3
This script is used to parse the log generated by fwts and check it for certain
4
errors detected during testing. It expects that this is a log file created by
5
fwts at runtime using the -l <log name> option.
7
It's written now specifically for checking ater the fwts s3 and s4 tests but
8
can be adapted to look for other tests, or all tests.
13
from argparse import ArgumentParser, RawTextHelpFormatter
17
parser = ArgumentParser()
18
parser.add_argument('-v', '--verbose',
21
help="Display each error discovered. May provide \
22
very long output. Also, this option will only \
23
provide a list of UNIQUE errors encountered in \
24
the log file. It will not display duplicates. \
25
Default is [%(default)s]")
26
parser.add_argument('test',
28
help='The test to check (s3 or s4)')
29
parser.add_argument('logfile',
31
help='The log file to parse')
33
args = parser.parse_args()
37
#Create a generator and get our lines
38
log = (line.rstrip() for line in open(args.logfile,'r'))
40
#Now parse and find out error lines. We're looking for specific keys that
41
#occur in the summary section for each test run.
42
#Error levels we care about:
43
levels = ('critical', 'high', 'medium')
49
if "%s: %s" % (args.test, level.upper()) in logline:
50
line = logline.split(']',1)[1].strip()
51
#Only include unique lines to avoid hundreds of repititions
52
if line not in errors[level]:
53
errors[level].append(line)
58
print("%s errors: %s" % (level.upper(), len(errors[level])))
60
#Print the actual errors)
62
for line in errors[level]:
67
print("No errors detected")
71
if __name__ == '__main__':