From: Michael Petlan <mpetlan@redhat.com>
To: linux-perf-users@vger.kernel.org, acme@kernel.org
Cc: acme@redhat.com, qzhao@redhat.com, cjense@google.com
Subject: [PATCH 2/2] perf test: Fix JSON format linter test checks
Date: Fri, 20 Jan 2023 14:40:39 +0100 [thread overview]
Message-ID: <20230120134039.17788-3-mpetlan@redhat.com> (raw)
In-Reply-To: <20230120134039.17788-1-mpetlan@redhat.com>
The test fails on CPUs with topdown metrics, where it is common to print
two metrics per line. Since these are included in default event set for
`perf stat -- something`, it causes the "no args" subtest to fail due to
unexpected member count. We need to accept 7 or 9 members in that case.
Coming to that, counting commas in the JSON line and consider it a number
of elements is incorrect and misleading. There should be +1 element than
the count of commas, while also, commas can potentially appear in the
event names. Count " : " substrings rather, since these better fit to
what should be actually counted.
Fixes: 0c343af2a2f8 ("perf test: JSON format checking")
Signed-off-by: Michael Petlan <mpetlan@redhat.com>
---
.../tests/shell/lib/perf_json_output_lint.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/perf/tests/shell/lib/perf_json_output_lint.py b/tools/perf/tests/shell/lib/perf_json_output_lint.py
index d90f8d102eb9..4f1bbb3f07ec 100644
--- a/tools/perf/tests/shell/lib/perf_json_output_lint.py
+++ b/tools/perf/tests/shell/lib/perf_json_output_lint.py
@@ -40,17 +40,17 @@ def is_counter_value(num):
return isfloat(num) or num == '<not counted>' or num == '<not supported>'
def check_json_output(expected_items):
- if expected_items != -1:
+ if expected_items:
for line in Lines:
if 'failed' not in line:
count = 0
- count = line.count(',')
- if count != expected_items and count >= 1 and count <= 3 and 'metric-value' in line:
+ count = line.count(' : ')
+ if count not in expected_items and count >= 2 and count <= 4 and 'metric-value' in line:
# Events that generate >1 metric may have isolated metric
# values and possibly other prefixes like interval, core and
# aggregate-number.
continue
- if count != expected_items:
+ if count not in expected_items:
raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}'
f' in \'{line}\'')
checks = {
@@ -82,14 +82,14 @@ def check_json_output(expected_items):
try:
if args.no_args or args.system_wide or args.event:
- expected_items = 6
+ expected_items = [7, 9]
elif args.interval or args.per_thread or args.system_wide_no_aggr:
- expected_items = 7
+ expected_items = [8, 10]
elif args.per_core or args.per_socket or args.per_node or args.per_die:
- expected_items = 8
+ expected_items = [9, 11]
else:
# If no option is specified, don't check the number of items.
- expected_items = -1
+ expected_items = []
check_json_output(expected_items)
except:
print('Test failed for input:\n' + '\n'.join(Lines))
--
2.18.4
next prev parent reply other threads:[~2023-01-20 13:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-20 13:40 [PATCH 0/2] perf test: Fix JSON linter Michael Petlan
2023-01-20 13:40 ` [PATCH 1/2] perf stat: Fix JSON metric printout for multiple metrics per line Michael Petlan
2023-01-23 6:31 ` Namhyung Kim
2023-05-22 12:11 ` Michael Petlan
2023-06-06 11:16 ` Michael Petlan
2023-01-20 13:40 ` Michael Petlan [this message]
2023-01-23 6:36 ` [PATCH 2/2] perf test: Fix JSON format linter test checks Namhyung Kim
2023-01-24 16:49 ` Michael Petlan
2023-01-24 17:26 ` Namhyung Kim
2023-01-27 12:26 ` Arnaldo Carvalho de Melo
2023-01-27 12:30 ` Arnaldo Carvalho de Melo
2023-01-31 17:14 ` Michael Petlan
2023-02-02 1:18 ` Arnaldo Carvalho de Melo
2023-01-20 17:37 ` [PATCH 0/2] perf test: Fix JSON linter Ian Rogers
2023-01-23 6:48 ` Namhyung Kim
2023-01-23 13:38 ` Arnaldo Carvalho de Melo
2023-01-24 17:39 ` Michael Petlan
2023-01-25 0:37 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230120134039.17788-3-mpetlan@redhat.com \
--to=mpetlan@redhat.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=cjense@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=qzhao@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).