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