aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorThomas Richter <tmricht@linux.vnet.ibm.com>2017-06-22 03:36:25 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-06-26 20:42:00 -0400
commit19508c048a2f90facb64624340bf1b7ee555442e (patch)
tree712b41fa4b4a0a4593e8e1484d5ea97d28dc3c97 /tools/perf
parent8e70e8409102a37ab066bd91007b75fd5d113931 (diff)
perf tests: Add platform dependency to test 15
This patch adds platform dependency into the test case 15 (perf_event_attr). It is based on a suggestion from Jiri Olsa. Add a new optional attribute named 'arch' in the [config] section of the test case file. It is a comma separated list of architecture names this test can be executed on. For example: arch = x86_64,alpha,ppc If this attribute is missing the test is executed on any platform. This does not break existing behavior. The values listed for this attribute should be identical to uname -m output. If the list starts with an exclamation mark (!) the comparison is inverted, for example for arch = !s390x,ppc the test is not executed on s390x or ppc platforms. The exclamation mark must be at the beginnning of the list. Here is an example debug output: [root@s35lp76]# fgrep arch tests/attr/test-stat-C2 arch = x86_64,alpha,ppc [root@s35lp76]# PERF_TEST_ATTR=/tmp /usr/bin/python2 ./tests/attr.py \ -d ./tests/attr/ -p ./perf -vvvvv -t test-stat-C1 provides the following output: running './tests/attr//test-stat-C1' test limitation 'x86_64,alpha,ppc' <--- new loading expected events Event event:base-stat fd = 1 group_fd = -1 ..... Here is the output when a test is skipped: [root@s35lp76]# fgrep arch tests/attr/test-stat-C1 arch = !s390x [root@s35lp76]# PERF_TEST_ATTR=/tmp /usr/bin/python2 ./tests/attr.py \ -d ./tests/attr/ -p ./perf -vvvvv -t test-stat-C1 provides the following output: test limitation '!s390x' <--- new skipped [s390x] './tests/attr//test-stat-C1' <--- new The test is skipped with return code 0. Suggested-and-Acked-by: Jiri Olsa <jolsa@redhat.com> Reviewed-by: Arnaldo Carvalho de Melo <acme@kernel.org> Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com> Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Cc: linux-s390@vger.kernel.org Link: http://lkml.kernel.org/r/20170622073625.86762-1-tmricht@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/tests/attr.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
index 1091bd47adfd..cdf21a9d0c35 100644
--- a/tools/perf/tests/attr.py
+++ b/tools/perf/tests/attr.py
@@ -16,6 +16,13 @@ class Fail(Exception):
16 def getMsg(self): 16 def getMsg(self):
17 return '\'%s\' - %s' % (self.test.path, self.msg) 17 return '\'%s\' - %s' % (self.test.path, self.msg)
18 18
19class Notest(Exception):
20 def __init__(self, test, arch):
21 self.arch = arch
22 self.test = test
23 def getMsg(self):
24 return '[%s] \'%s\'' % (self.arch, self.test.path)
25
19class Unsup(Exception): 26class Unsup(Exception):
20 def __init__(self, test): 27 def __init__(self, test):
21 self.test = test 28 self.test = test
@@ -112,6 +119,9 @@ class Event(dict):
112# 'command' - perf command name 119# 'command' - perf command name
113# 'args' - special command arguments 120# 'args' - special command arguments
114# 'ret' - expected command return value (0 by default) 121# 'ret' - expected command return value (0 by default)
122# 'arch' - architecture specific test (optional)
123# comma separated list, ! at the beginning
124# negates it.
115# 125#
116# [eventX:base] 126# [eventX:base]
117# - one or multiple instances in file 127# - one or multiple instances in file
@@ -134,6 +144,12 @@ class Test(object):
134 except: 144 except:
135 self.ret = 0 145 self.ret = 0
136 146
147 try:
148 self.arch = parser.get('config', 'arch')
149 log.warning("test limitation '%s'" % self.arch)
150 except:
151 self.arch = ''
152
137 self.expect = {} 153 self.expect = {}
138 self.result = {} 154 self.result = {}
139 log.debug(" loading expected events"); 155 log.debug(" loading expected events");
@@ -145,6 +161,31 @@ class Test(object):
145 else: 161 else:
146 return True 162 return True
147 163
164 def skip_test(self, myarch):
165 # If architecture not set always run test
166 if self.arch == '':
167 # log.warning("test for arch %s is ok" % myarch)
168 return False
169
170 # Allow multiple values in assignment separated by ','
171 arch_list = self.arch.split(',')
172
173 # Handle negated list such as !s390x,ppc
174 if arch_list[0][0] == '!':
175 arch_list[0] = arch_list[0][1:]
176 log.warning("excluded architecture list %s" % arch_list)
177 for arch_item in arch_list:
178 # log.warning("test for %s arch is %s" % (arch_item, myarch))
179 if arch_item == myarch:
180 return True
181 return False
182
183 for arch_item in arch_list:
184 # log.warning("test for architecture '%s' current '%s'" % (arch_item, myarch))
185 if arch_item == myarch:
186 return False
187 return True
188
148 def load_events(self, path, events): 189 def load_events(self, path, events):
149 parser_event = ConfigParser.SafeConfigParser() 190 parser_event = ConfigParser.SafeConfigParser()
150 parser_event.read(path) 191 parser_event.read(path)
@@ -168,6 +209,11 @@ class Test(object):
168 events[section] = e 209 events[section] = e
169 210
170 def run_cmd(self, tempdir): 211 def run_cmd(self, tempdir):
212 junk1, junk2, junk3, junk4, myarch = (os.uname())
213
214 if self.skip_test(myarch):
215 raise Notest(self, myarch)
216
171 cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir, 217 cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir,
172 self.perf, self.command, tempdir, self.args) 218 self.perf, self.command, tempdir, self.args)
173 ret = os.WEXITSTATUS(os.system(cmd)) 219 ret = os.WEXITSTATUS(os.system(cmd))
@@ -265,6 +311,8 @@ def run_tests(options):
265 Test(f, options).run() 311 Test(f, options).run()
266 except Unsup, obj: 312 except Unsup, obj:
267 log.warning("unsupp %s" % obj.getMsg()) 313 log.warning("unsupp %s" % obj.getMsg())
314 except Notest, obj:
315 log.warning("skipped %s" % obj.getMsg())
268 316
269def setup_log(verbose): 317def setup_log(verbose):
270 global log 318 global log