Skip to contentSkip to conversation

perf tests: Fix "perf stat JSON output linter" test for new output

PATCH Applied James Clark 5 participants 9 messages Nov 30, 2022 – Dec 5, 2022 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 perf tests: Fix "perf stat JSON output linter" test for new output

Commit c4b41b83c250 ("perf stat: Rename "aggregate-number" to "cpu-count" in JSON") renamed a field, so update the tests to reflect this.

This fixes the following failure:

  $ sudo ./perf test "json output" -vvv
   96: perf stat JSON output linter                                    :
  --- start ---
  test child forked, pid 327720
  Checking json output: no args [Success]
  Checking json output: system wide [Success]
  Checking json output: interval [Success]
  Checking json output: event [Success]
  Checking json output: per thread [Success]
  Checking json output: per node Test failed for input:
  ...
  Traceback (most recent call last):
    File "./tools/perf/tests/shell/lib/perf_json_output_lint.py", line 93, in <module>
      check_json_output(expected_items)
    File "./tools/perf/tests/shell/lib/perf_json_output_lint.py", line 78, in check_json_output
      raise RuntimeError(f'Unexpected key: key={key} value={value}')
  RuntimeError: Unexpected key: key=cpu-count value=16
  test child finished with -1
  ---- end ----
  perf stat JSON output linter: FAILED!
Fixes c4b41b83c250 ("perf stat: Rename "aggregate-number" to "cpu-count" in JSON")
---
 tools/perf/tests/shell/lib/perf_json_output_lint.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/lib/perf_json_output_lint.py +1 -1
index d90f8d102eb9..9c073e257d33 100644
@@ -54,7 +54,7 @@ def check_json_output(expected_items):
           raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}'
                              f' in \'{line}\'')
   checks = {
-      'aggregate-number': lambda x: isfloat(x),
+      'cpu-count': lambda x: isfloat(x),
       'core': lambda x: True,
       'counter-value': lambda x: is_counter_value(x),
       'cgroup': lambda x: True,
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 perf stat: Fix invalid output handle

In this context, 'os' is already a pointer so the extra dereference isn't required. This fixes the following test failure on aarch64:

  $ ./perf test "json output" -vvv
  92: perf stat JSON output linter                                    :
  --- start ---
  Checking json output: no args Test failed for input:
  ...
  Fatal error: glibc detected an invalid stdio handle
  ---- end ----
  perf stat JSON output linter: FAILED!
Fixes e7f4da312259 ("perf stat: Pass struct outstate to printout()")
---
 tools/perf/util/stat-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/stat-display.c +1 -1
index 847acdb5dc40..eac5ac3a734c 100644
@@ -741,7 +741,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
 		perf_stat__print_shadow_stats(config, counter, uval, map_idx,
 					      &out, &config->metric_events, &rt_stat);
 	} else {
-		pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
+		pm(config, os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
 	}
 
 	if (!config->metric_only) {
Signature · 1 line
2.25.1
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] perf stat: Fix invalid output handle

Quoted 13 lines · James Clark

In this context, 'os' is already a pointer so the extra dereference isn't required. This fixes the following test failure on aarch64:

  $ ./perf test "json output" -vvv
  92: perf stat JSON output linter                                    :
  --- start ---
  Checking json output: no args Test failed for input:
  ...
  Fatal error: glibc detected an invalid stdio handle
  ---- end ----
  perf stat JSON output linter: FAILED!
Quoted 2 lines
Fixes e7f4da312259 ("perf stat: Pass struct outstate to printout()")

Thanks for fixing this. I'm not sure how I missed it.. :(

Thanks,
Namhyung

Quoted 20 lines
---
 tools/perf/util/stat-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/stat-display.c +1 -2
index 847acdb5dc40..eac5ac3a734c 100644
@@ -741,7 +741,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
                perf_stat__print_shadow_stats(config, counter, uval, map_idx,
                                              &out, &config->metric_events, &rt_stat);
        } else {
-               pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
+               pm(config, os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
        }
 
        if (!config->metric_only) {
--

2.25.1

#3 lore raw

Re: [PATCH 2/2] perf stat: Fix invalid output handle

Quoted 14 lines · Namhyung Kim
Quoted 13 lines · James Clark

In this context, 'os' is already a pointer so the extra dereference isn't required. This fixes the following test failure on aarch64:

  $ ./perf test "json output" -vvv
  92: perf stat JSON output linter                                    :
  --- start ---
  Checking json output: no args Test failed for input:
  ...
  Fatal error: glibc detected an invalid stdio handle
  ---- end ----
  perf stat JSON output linter: FAILED!
Quoted 5 lines
Quoted 2 lines
Fixes e7f4da312259 ("perf stat: Pass struct outstate to printout()")

Thanks for fixing this. I'm not sure how I missed it.. :(

It seems to only go down that path on some configuration. At least on x86 the test was passing fine for me.

Quoted 1 line

Thanks for the review!

Quoted 25 lines

Thanks,
Namhyung

Quoted 20 lines
---
 tools/perf/util/stat-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/stat-display.c +1 -2
index 847acdb5dc40..eac5ac3a734c 100644
@@ -741,7 +741,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
                perf_stat__print_shadow_stats(config, counter, uval, map_idx,
                                              &out, &config->metric_events, &rt_stat);
        } else {
-               pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
+               pm(config, os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
        }
 
        if (!config->metric_only) {
--

2.25.1

Tested-by
#4 lore raw

Re: [PATCH 2/2] perf stat: Fix invalid output handle

Quoted 27 lines · James Clark
Quoted 14 lines · Namhyung Kim
Quoted 13 lines · James Clark

In this context, 'os' is already a pointer so the extra dereference isn't required. This fixes the following test failure on aarch64:

 $ ./perf test "json output" -vvv
 92: perf stat JSON output linter                                    :
 --- start ---
 Checking json output: no args Test failed for input:
 ...
 Fatal error: glibc detected an invalid stdio handle
 ---- end ----
 perf stat JSON output linter: FAILED!
Quoted 5 lines
Quoted 2 lines
Fixes e7f4da312259 ("perf stat: Pass struct outstate to printout()")

Thanks for fixing this. I'm not sure how I missed it.. :(

Quoted 6 lines

It seems to only go down that path on some configuration. At least on x86 the test was passing fine for me.

Quoted 1 line

Thanks for the review!

Faced same issue on powerpc. Tested with this change and it works with this patch.

Thanks
Athira

Quoted 25 lines
Quoted 25 lines

Thanks,
Namhyung

Quoted 19 lines

---
tools/perf/util/stat-display.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/stat-display.c +1 -2
index 847acdb5dc40..eac5ac3a734c 100644
@@ -741,7 +741,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
               perf_stat__print_shadow_stats(config, counter, uval, map_idx,
                                             &out, &config->metric_events, &rt_stat);
       } else {
-               pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
+               pm(config, os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0);
       }
 
       if (!config->metric_only) {
--

2.25.1

maintainer Applied
#5 lore raw

Re: [PATCH 2/2] perf stat: Fix invalid output handle

Em Sun, Dec 04, 2022 at 10:38:28PM +0530, Athira Rajeev escreveu:

Quoted 30 lines
Quoted 30 lines · James Clark
Quoted 14 lines · Namhyung Kim
Quoted 13 lines · James Clark

In this context, 'os' is already a pointer so the extra dereference isn't required. This fixes the following test failure on aarch64:

 $ ./perf test "json output" -vvv
 92: perf stat JSON output linter                                    :
 --- start ---
 Checking json output: no args Test failed for input:
 ...
 Fatal error: glibc detected an invalid stdio handle
 ---- end ----
 perf stat JSON output linter: FAILED!
Quoted 5 lines
Quoted 2 lines
Fixes e7f4da312259 ("perf stat: Pass struct outstate to printout()")

Thanks for fixing this. I'm not sure how I missed it.. :(

It seems to only go down that path on some configuration. At least on x86 the test was passing fine for me.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks for the review!

Faced same issue on powerpc. Tested with this change and it works with this patch.

Thanks, applied.

- Arnaldo

reviewer
#6 lore raw
In reply to James Clark
Quoted 28 lines · James Clark

Commit c4b41b83c250 ("perf stat: Rename "aggregate-number" to "cpu-count" in JSON") renamed a field, so update the tests to reflect this.

This fixes the following failure:

  $ sudo ./perf test "json output" -vvv
   96: perf stat JSON output linter                                    :
  --- start ---
  test child forked, pid 327720
  Checking json output: no args [Success]
  Checking json output: system wide [Success]
  Checking json output: interval [Success]
  Checking json output: event [Success]
  Checking json output: per thread [Success]
  Checking json output: per node Test failed for input:
  ...
  Traceback (most recent call last):
    File "./tools/perf/tests/shell/lib/perf_json_output_lint.py", line 93, in <module>
      check_json_output(expected_items)
    File "./tools/perf/tests/shell/lib/perf_json_output_lint.py", line 78, in check_json_output
      raise RuntimeError(f'Unexpected key: key={key} value={value}')
  RuntimeError: Unexpected key: key=cpu-count value=16
  test child finished with -1
  ---- end ----
  perf stat JSON output linter: FAILED!
Quoted 2 lines
Fixes c4b41b83c250 ("perf stat: Rename "aggregate-number" to "cpu-count" in JSON")

Namhyung mentioned reverting change c4b41b83c250, in which case merging this would break the test again. I think the revert is better.

Thanks,
Ian

Quoted 20 lines
---
 tools/perf/tests/shell/lib/perf_json_output_lint.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/lib/perf_json_output_lint.py +1 -2
index d90f8d102eb9..9c073e257d33 100644
@@ -54,7 +54,7 @@ def check_json_output(expected_items):
           raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}'
                              f' in \'{line}\'')
   checks = {
-      'aggregate-number': lambda x: isfloat(x),
+      'cpu-count': lambda x: isfloat(x),
       'core': lambda x: True,
       'counter-value': lambda x: is_counter_value(x),
       'cgroup': lambda x: True,
--

2.25.1

maintainer
#7 lore raw

Hi,

Quoted 30 lines · Ian Rogers
Quoted 28 lines · James Clark

Commit c4b41b83c250 ("perf stat: Rename "aggregate-number" to "cpu-count" in JSON") renamed a field, so update the tests to reflect this.

This fixes the following failure:

  $ sudo ./perf test "json output" -vvv
   96: perf stat JSON output linter                                    :
  --- start ---
  test child forked, pid 327720
  Checking json output: no args [Success]
  Checking json output: system wide [Success]
  Checking json output: interval [Success]
  Checking json output: event [Success]
  Checking json output: per thread [Success]
  Checking json output: per node Test failed for input:
  ...
  Traceback (most recent call last):
    File "./tools/perf/tests/shell/lib/perf_json_output_lint.py", line 93, in <module>
      check_json_output(expected_items)
    File "./tools/perf/tests/shell/lib/perf_json_output_lint.py", line 78, in check_json_output
      raise RuntimeError(f'Unexpected key: key={key} value={value}')
  RuntimeError: Unexpected key: key=cpu-count value=16
  test child finished with -1
  ---- end ----
  perf stat JSON output linter: FAILED!
Quoted 5 lines
Quoted 2 lines
Fixes c4b41b83c250 ("perf stat: Rename "aggregate-number" to "cpu-count" in JSON")

Namhyung mentioned reverting change c4b41b83c250, in which case merging this would break the test again. I think the revert is better.

Yep, I will send the revert soon.

Thanks,
Namhyung

#8 lore raw
In reply to Ian Rogers

Em Wed, Nov 30, 2022 at 10:18:49AM -0800, Ian Rogers escreveu:

Quoted 29 lines · James Clark
Quoted 28 lines

Commit c4b41b83c250 ("perf stat: Rename "aggregate-number" to "cpu-count" in JSON") renamed a field, so update the tests to reflect this.

This fixes the following failure:

  $ sudo ./perf test "json output" -vvv
   96: perf stat JSON output linter                                    :
  --- start ---
  test child forked, pid 327720
  Checking json output: no args [Success]
  Checking json output: system wide [Success]
  Checking json output: interval [Success]
  Checking json output: event [Success]
  Checking json output: per thread [Success]
  Checking json output: per node Test failed for input:
  ...
  Traceback (most recent call last):
    File "./tools/perf/tests/shell/lib/perf_json_output_lint.py", line 93, in <module>
      check_json_output(expected_items)
    File "./tools/perf/tests/shell/lib/perf_json_output_lint.py", line 78, in check_json_output
      raise RuntimeError(f'Unexpected key: key={key} value={value}')
  RuntimeError: Unexpected key: key=cpu-count value=16
  test child finished with -1
  ---- end ----
  perf stat JSON output linter: FAILED!
Quoted 5 lines
Quoted 2 lines
Fixes c4b41b83c250 ("perf stat: Rename "aggregate-number" to "cpu-count" in JSON")

Namhyung mentioned reverting change c4b41b83c250, in which case merging this would break the test again. I think the revert is better.

Applied the revert, with an Acked-by: you.

Quoted 23 lines

Thanks,
Ian

Quoted 20 lines
---
 tools/perf/tests/shell/lib/perf_json_output_lint.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/lib/perf_json_output_lint.py +1 -2
index d90f8d102eb9..9c073e257d33 100644
@@ -54,7 +54,7 @@ def check_json_output(expected_items):
           raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}'
                              f' in \'{line}\'')
   checks = {
-      'aggregate-number': lambda x: isfloat(x),
+      'cpu-count': lambda x: isfloat(x),
       'core': lambda x: True,
       'counter-value': lambda x: is_counter_value(x),
       'cgroup': lambda x: True,
--

2.25.1

Signature · 1 line
- Arnaldo