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

perf test: Add ability to test exit code for attr tests

Currently the return value is used to skip the test, but sometimes it
can be useful to test if a certain command should return a certain exit
code.
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-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e8478b84
...@@ -129,7 +129,8 @@ class Event(dict): ...@@ -129,7 +129,8 @@ class Event(dict):
# - needs to specify: # - needs to specify:
# 'command' - perf command name # 'command' - perf command name
# 'args' - special command arguments # 'args' - special command arguments
# 'ret' - expected command return value (0 by default) # 'ret' - Skip test if Perf doesn't exit with this value (0 by default)
# 'test_ret'- If set to 'true', fail test instead of skipping for 'ret' argument
# 'arch' - architecture specific test (optional) # 'arch' - architecture specific test (optional)
# comma separated list, ! at the beginning # comma separated list, ! at the beginning
# negates it. # negates it.
...@@ -155,6 +156,8 @@ class Test(object): ...@@ -155,6 +156,8 @@ class Test(object):
except: except:
self.ret = 0 self.ret = 0
self.test_ret = parser.getboolean('config', 'test_ret', fallback=False)
try: try:
self.arch = parser.get('config', 'arch') self.arch = parser.get('config', 'arch')
log.warning("test limitation '%s'" % self.arch) log.warning("test limitation '%s'" % self.arch)
...@@ -232,6 +235,9 @@ class Test(object): ...@@ -232,6 +235,9 @@ class Test(object):
log.info(" '%s' ret '%s', expected '%s'" % (cmd, str(ret), str(self.ret))) log.info(" '%s' ret '%s', expected '%s'" % (cmd, str(ret), str(self.ret)))
if not data_equal(str(ret), str(self.ret)): if not data_equal(str(ret), str(self.ret)):
if self.test_ret:
raise Fail(self, "Perf exit code failure")
else:
raise Unsup(self) raise Unsup(self)
def compare(self, expect, result): def compare(self, expect, result):
......
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