Commit ee26adf6 authored by James Clark's avatar James Clark Committed by Arnaldo Carvalho de Melo

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: default avatarJames Clark <james.clark@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221213114739.2312862-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c3a8f853
......@@ -6,6 +6,7 @@ import os
import sys
import glob
import optparse
import platform
import tempfile
import logging
import re
......@@ -125,6 +126,11 @@ class Event(dict):
if not data_equal(self[t], other[t]):
log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
def parse_version(version):
if not version:
return None
return [int(v) for v in version.split(".")[0:2]]
# Test file description needs to have following sections:
# [config]
# - just single instance in file
......@@ -138,7 +144,9 @@ class Event(dict):
# negates it.
# 'auxv' - Truthy statement that is evaled in the scope of the auxv map. When false,
# the test is skipped. For example 'auxv["AT_HWCAP"] == 10'. (optional)
#
# 'kernel_since' - Inclusive kernel version from which the test will start running. Only the
# first two values are supported, for example "6.1" (optional)
# 'kernel_until' - Exclusive kernel version from which the test will stop running. (optional)
# [eventX:base]
# - one or multiple instances in file
# - expected values assignments
......@@ -169,6 +177,8 @@ class Test(object):
self.arch = ''
self.auxv = parser.get('config', 'auxv', fallback=None)
self.kernel_since = parse_version(parser.get('config', 'kernel_since', fallback=None))
self.kernel_until = parse_version(parser.get('config', 'kernel_until', fallback=None))
self.expect = {}
self.result = {}
log.debug(" loading expected events");
......@@ -180,6 +190,16 @@ class Test(object):
else:
return True
def skip_test_kernel_since(self):
if not self.kernel_since:
return False
return not self.kernel_since <= parse_version(platform.release())
def skip_test_kernel_until(self):
if not self.kernel_until:
return False
return not parse_version(platform.release()) < self.kernel_until
def skip_test_auxv(self):
def new_auxv(a, pattern):
items = list(filter(None, pattern.split(a)))
......@@ -257,6 +277,12 @@ class Test(object):
if self.skip_test_auxv():
raise Notest(self, "auxv skip")
if self.skip_test_kernel_since():
raise Notest(self, "old kernel skip")
if self.skip_test_kernel_until():
raise Notest(self, "new kernel skip")
cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir,
self.perf, self.command, tempdir, self.args)
ret = os.WEXITSTATUS(os.system(cmd))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment