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