Skip to content

Commit 1f41873

Browse files
olsajiriacmel
authored andcommitted
perf tests attr: Add optional term
Some of the stat events are quite rare to find on common machines (like front end cycles). Adding an 'optional' term to mark such events in attr tests. Event marked as optional will not fail the test case if it's not found in results. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Richter <tmricht@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/20170703145030.12903-15-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent b78e92e commit 1f41873

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎tools/perf/tests/attr.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def equal(self, other):
105105
return False
106106
return True
107107

108+
def optional(self):
109+
if self.has_key('optional') and self['optional'] == '1':
110+
return True
111+
return False
112+
108113
def diff(self, other):
109114
for t in Event.terms:
110115
if not self.has_key(t) or not other.has_key(t):
@@ -244,9 +249,12 @@ def compare(self, expect, result):
244249
log.debug(" match: [%s] matches %s" % (exp_name, str(exp_list)))
245250

246251
# we did not any matching event - fail
247-
if (not exp_list):
248-
exp_event.diff(res_event)
249-
raise Fail(self, 'match failure');
252+
if not exp_list:
253+
if exp_event.optional():
254+
log.debug(" %s does not match, but is optional" % exp_name)
255+
else:
256+
exp_event.diff(res_event)
257+
raise Fail(self, 'match failure');
250258

251259
match[exp_name] = exp_list
252260

‎tools/perf/tests/attr/test-stat-default‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ config=0
3838
fd=6
3939
type=0
4040
config=7
41+
optional=1
4142

4243
# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND
4344
[event7:base-stat]
4445
fd=7
4546
type=0
4647
config=8
48+
optional=1
4749

4850
# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS
4951
[event8:base-stat]

‎tools/perf/tests/attr/test-stat-detailed-1‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ config=0
3939
fd=6
4040
type=0
4141
config=7
42+
optional=1
4243

4344
# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND
4445
[event7:base-stat]
4546
fd=7
4647
type=0
4748
config=8
49+
optional=1
4850

4951
# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS
5052
[event8:base-stat]

‎tools/perf/tests/attr/test-stat-detailed-2‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ config=0
3939
fd=6
4040
type=0
4141
config=7
42+
optional=1
4243

4344
# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND
4445
[event7:base-stat]
4546
fd=7
4647
type=0
4748
config=8
49+
optional=1
4850

4951
# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS
5052
[event8:base-stat]
@@ -108,6 +110,7 @@ config=65538
108110
fd=15
109111
type=3
110112
config=1
113+
optional=1
111114

112115
# PERF_TYPE_HW_CACHE,
113116
# PERF_COUNT_HW_CACHE_L1I << 0 |

‎tools/perf/tests/attr/test-stat-detailed-3‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ config=0
3939
fd=6
4040
type=0
4141
config=7
42+
optional=1
4243

4344
# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND
4445
[event7:base-stat]
4546
fd=7
4647
type=0
4748
config=8
49+
optional=1
4850

4951
# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS
5052
[event8:base-stat]
@@ -108,6 +110,7 @@ config=65538
108110
fd=15
109111
type=3
110112
config=1
113+
optional=1
111114

112115
# PERF_TYPE_HW_CACHE,
113116
# PERF_COUNT_HW_CACHE_L1I << 0 |
@@ -162,6 +165,7 @@ config=65540
162165
fd=21
163166
type=3
164167
config=512
168+
optional=1
165169

166170
# PERF_TYPE_HW_CACHE,
167171
# PERF_COUNT_HW_CACHE_L1D << 0 |
@@ -171,3 +175,4 @@ config=512
171175
fd=22
172176
type=3
173177
config=66048
178+
optional=1

0 commit comments

Comments
 (0)