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-testpi1.py ## 22## ## 23## DESCRIPTION: Log Parser for the testpi-1.c test ## 24## ## 25## AUTHOR: Chirag <chirag@linux.vnet.ibm.com ## 26## ## 27################################################################################ 28 29from scripts.parser import * 30import re 31class TestPi1(Log): 32 def __init__(self,filename): 33 Log.__init__(self,filename) 34 35 def eval(self): 36 exp1= re.compile("pthread pol 0 pri 0") 37 exp2= re.compile(r'^Noise Thread') 38 exp3=re.compile("[1-9]\d{2,3}") 39 flag=False 40 for line in self.read(): 41 if exp1.search(line) and exp2.search(prev_line)and exp3.search(prev_line): 42 list=prev_line.split(" ") 43 if int(list[4])< 9900: 44 flag=True 45 else: 46 flag=False 47 48 49 50 prev_line=line 51 return flag 52 53def main(): 54 if len(sys.argv) < 2: 55 sys.exit("Usage : ./%s <logname>" % sys.argv[0]) 56 else: 57 log_file = sys.argv[1] 58 log = TestPi1(log_file) 59 sys.exit("Result: %s " % (["FAIL", "PASS"][log.eval()])) 60 61if __name__ == "__main__": 62 main() 63