Skip to content

Commit ee26adf

Browse files
James-A-Clarkacmel
authored andcommitted
perf test: Add mechanism for skipping attr tests on kernel versions
The first two version numbers are used since that is where the ABI changes happen, so seems to be the most useful for now. 'Until' is exclusive and 'since' is inclusive so that the same version number can be used to mark a point where the change comes into effect. This allows keeping the tests in a state where new tests will also pass on older kernels if the existence of a new feature isn't explicitly broadcast by the kernel. For example extended user regs are currently discovered by trial and error calls to perf_event_open. Signed-off-by: James Clark <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c3a8f85 commit ee26adf

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tools/perf/tests/attr.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import glob
88
import optparse
9+
import platform
910
import tempfile
1011
import logging
1112
import re
@@ -125,6 +126,11 @@ def diff(self, other):
125126
if not data_equal(self[t], other[t]):
126127
log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
127128

129+
def parse_version(version):
130+
if not version:
131+
return None
132+
return [int(v) for v in version.split(".")[0:2]]
133+
128134
# Test file description needs to have following sections:
129135
# [config]
130136
# - just single instance in file
@@ -138,7 +144,9 @@ def diff(self, other):
138144
# negates it.
139145
# 'auxv' - Truthy statement that is evaled in the scope of the auxv map. When false,
140146
# the test is skipped. For example 'auxv["AT_HWCAP"] == 10'. (optional)
141-
#
147+
# 'kernel_since' - Inclusive kernel version from which the test will start running. Only the
148+
# first two values are supported, for example "6.1" (optional)
149+
# 'kernel_until' - Exclusive kernel version from which the test will stop running. (optional)
142150
# [eventX:base]
143151
# - one or multiple instances in file
144152
# - expected values assignments
@@ -169,6 +177,8 @@ def __init__(self, path, options):
169177
self.arch = ''
170178

171179
self.auxv = parser.get('config', 'auxv', fallback=None)
180+
self.kernel_since = parse_version(parser.get('config', 'kernel_since', fallback=None))
181+
self.kernel_until = parse_version(parser.get('config', 'kernel_until', fallback=None))
172182
self.expect = {}
173183
self.result = {}
174184
log.debug(" loading expected events");
@@ -180,6 +190,16 @@ def is_event(self, name):
180190
else:
181191
return True
182192

193+
def skip_test_kernel_since(self):
194+
if not self.kernel_since:
195+
return False
196+
return not self.kernel_since <= parse_version(platform.release())
197+
198+
def skip_test_kernel_until(self):
199+
if not self.kernel_until:
200+
return False
201+
return not parse_version(platform.release()) < self.kernel_until
202+
183203
def skip_test_auxv(self):
184204
def new_auxv(a, pattern):
185205
items = list(filter(None, pattern.split(a)))
@@ -257,6 +277,12 @@ def run_cmd(self, tempdir):
257277
if self.skip_test_auxv():
258278
raise Notest(self, "auxv skip")
259279

280+
if self.skip_test_kernel_since():
281+
raise Notest(self, "old kernel skip")
282+
283+
if self.skip_test_kernel_until():
284+
raise Notest(self, "new kernel skip")
285+
260286
cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir,
261287
self.perf, self.command, tempdir, self.args)
262288
ret = os.WEXITSTATUS(os.system(cmd))

0 commit comments

Comments
 (0)