1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3 4################################################################################ 5## ## 6## Copyright © International Business Machines Corp., 2007, 2008 ## 7## ## 8## This program is free software; you can redistribute it and#or modify ## 9## it under the terms of the GNU General Public License as published by ## 10## the Free Software Foundation; either version 2 of the License, or ## 11## (at your option) any later version. ## 12## ## 13## This program is distributed in the hope that it will be useful, but ## 14## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## 15## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## 16## for more details. ## 17## ## 18## You should have received a copy of the GNU General Public License ## 19## along with this program; if not, write to the Free Software ## 20## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## 21## ## 22## NAME: parse-testpi2.py ## 23## ## 24## DESCRIPTION: Log Parser for the testpi-2.c test ## 25## ## 26## AUTHOR: Chirag <chirag@linux.vnet.ibm.com ## 27## ## 28################################################################################ 29 30 31from scripts.parser import * 32import re 33class TestPi2(Log): 34 def __init__(self,filename): 35 Log.__init__(self,filename) 36 37 def eval(self): 38 exp1= re.compile("pthread pol 2 pri 10") 39 exp2= re.compile(r'^Noise Thread') 40 exp3=re.compile("[1-9]\d{2,3}") 41 prev_line="temp" 42 count=0 43 flag=True 44 for line in self.read(): 45 if exp1.search(line) and exp2.search(prev_line) and exp3.search(prev_line): 46 list=prev_line.split(" ") 47 if int(list[4])<= 9900: 48 count+=1 49 flag=True 50 elif count == 0: 51 return False 52 53 54 55 prev_line=line 56 if count>=2: 57 return True 58 else: 59 return False 60 61def main(): 62 if len(sys.argv) < 2: 63 sys.exit("Usage : ./%s <logname>" % sys.argv[0]) 64 else: 65 log_file=sys.argv[1] 66 log = TestPi2(log_file) 67 sys.exit("Result: %s " % (["FAIL", "PASS"][log.eval()])) 68 69if __name__ == "__main__": 70 main() 71