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