Skip to content

Commit a8f2619

Browse files
James-A-Clarkacmel
authored andcommitted
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: 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 e8478b8 commit a8f2619

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/perf/tests/attr.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ def diff(self, other):
129129
# - needs to specify:
130130
# 'command' - perf command name
131131
# 'args' - special command arguments
132-
# 'ret' - expected command return value (0 by default)
132+
# 'ret' - Skip test if Perf doesn't exit with this value (0 by default)
133+
# 'test_ret'- If set to 'true', fail test instead of skipping for 'ret' argument
133134
# 'arch' - architecture specific test (optional)
134135
# comma separated list, ! at the beginning
135136
# negates it.
@@ -155,6 +156,8 @@ def __init__(self, path, options):
155156
except:
156157
self.ret = 0
157158

159+
self.test_ret = parser.getboolean('config', 'test_ret', fallback=False)
160+
158161
try:
159162
self.arch = parser.get('config', 'arch')
160163
log.warning("test limitation '%s'" % self.arch)
@@ -232,7 +235,10 @@ def run_cmd(self, tempdir):
232235
log.info(" '%s' ret '%s', expected '%s'" % (cmd, str(ret), str(self.ret)))
233236

234237
if not data_equal(str(ret), str(self.ret)):
235-
raise Unsup(self)
238+
if self.test_ret:
239+
raise Fail(self, "Perf exit code failure")
240+
else:
241+
raise Unsup(self)
236242

237243
def compare(self, expect, result):
238244
match = {}

0 commit comments

Comments
 (0)