Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thomas Richter and committed by
Arnaldo Carvalho de Melo
19508c04 8e70e840

+48
+48
tools/perf/tests/attr.py
··· 16 16 def getMsg(self): 17 17 return '\'%s\' - %s' % (self.test.path, self.msg) 18 18 19 + class 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 + 19 26 class Unsup(Exception): 20 27 def __init__(self, test): 21 28 self.test = test ··· 119 112 # 'command' - perf command name 120 113 # 'args' - special command arguments 121 114 # 'ret' - expected command return value (0 by default) 115 + # 'arch' - architecture specific test (optional) 116 + # comma separated list, ! at the beginning 117 + # negates it. 122 118 # 123 119 # [eventX:base] 124 120 # - one or multiple instances in file ··· 144 134 except: 145 135 self.ret = 0 146 136 137 + try: 138 + self.arch = parser.get('config', 'arch') 139 + log.warning("test limitation '%s'" % self.arch) 140 + except: 141 + self.arch = '' 142 + 147 143 self.expect = {} 148 144 self.result = {} 149 145 log.debug(" loading expected events"); ··· 160 144 return False 161 145 else: 162 146 return True 147 + 148 + def skip_test(self, myarch): 149 + # If architecture not set always run test 150 + if self.arch == '': 151 + # log.warning("test for arch %s is ok" % myarch) 152 + return False 153 + 154 + # Allow multiple values in assignment separated by ',' 155 + arch_list = self.arch.split(',') 156 + 157 + # Handle negated list such as !s390x,ppc 158 + if arch_list[0][0] == '!': 159 + arch_list[0] = arch_list[0][1:] 160 + log.warning("excluded architecture list %s" % arch_list) 161 + for arch_item in arch_list: 162 + # log.warning("test for %s arch is %s" % (arch_item, myarch)) 163 + if arch_item == myarch: 164 + return True 165 + return False 166 + 167 + for arch_item in arch_list: 168 + # log.warning("test for architecture '%s' current '%s'" % (arch_item, myarch)) 169 + if arch_item == myarch: 170 + return False 171 + return True 163 172 164 173 def load_events(self, path, events): 165 174 parser_event = ConfigParser.SafeConfigParser() ··· 209 168 events[section] = e 210 169 211 170 def run_cmd(self, tempdir): 171 + junk1, junk2, junk3, junk4, myarch = (os.uname()) 172 + 173 + if self.skip_test(myarch): 174 + raise Notest(self, myarch) 175 + 212 176 cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir, 213 177 self.perf, self.command, tempdir, self.args) 214 178 ret = os.WEXITSTATUS(os.system(cmd)) ··· 311 265 Test(f, options).run() 312 266 except Unsup, obj: 313 267 log.warning("unsupp %s" % obj.getMsg()) 268 + except Notest, obj: 269 + log.warning("skipped %s" % obj.getMsg()) 314 270 315 271 def setup_log(verbose): 316 272 global log