Imported Upstream version 20080930
[ltp-debian.git] / testcases / realtime / func / sched_football / parse-football.py
blobcd252c7a978abfb683b602fc7b587c5100817644
1 # -*- coding: utf-8 -*-
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
20 ## ##
21 ## NAME: parse-football.py ##
22 ## ##
23 ## DESCRIPTION: Log Parser for the sched_football.c test ##
24 ## ##
25 ## AUTHOR: Chirag <chirag@linux.vnet.ibm.com ##
26 ## ##
27 ################################################################################
29 from scripts.parser import *
30 import re
31 class SchedFootballLog(Log):
32 def __init__(self,filename):
33 Log.__init__(self,filename)
35 def eval(self):
36 exp1= "Final ball position"
37 flag=False
38 for line in self.read():
39 if exp1 in line:
40 list=line.split(" ")
41 if(list[3]=="0"):
42 return True
43 else:
44 return False
48 def main():
49 if len(sys.argv) < 2:
50 sys.exit("Usage : ./%s <logname>" % sys.argv[0])
51 else:
52 log_file=sys.argv[1]
54 log = SchedFootballLog(log_file)
55 sys.exit("Result: %s " % (["FAIL", "PASS"][log.eval()]))
57 if __name__ == "__main__":
58 main()