linux/tools/perf/tests/shell/lib
James Clark 967364894e perf stat: Fix trailing comma when there is no metric unit
Now that printing metric-value and metric-unit is optional,
print_running_json() shouldn't add the comma in case it becomes
trailing.

Replace all manual JSON comma stuff with a json_out() function that uses
the existing os->first tracking and auto inserts a comma if it's needed.
Update the test to handle that two of the fields can be missing.

This fixes the following test failure on Cortex A57 where the branch
misses metric is missing a required event:

  $ perf test -vvv "json output"

  106: perf stat JSON output linter:
  --- start ---
  test child forked, pid 665682
  Checking json output: no args Test failed for input:

  {"counter-value" : "3112.000000", "unit" : "",
   "event" : "armv8_pmuv3_1/branch-misses/",
   "event-runtime" : 20699340, "pcnt-running" : 100.00, }
  ...
  json.decoder.JSONDecodeError: Expecting property name enclosed in
  double quotes: line 12 column 144 (char 2109)
  ---- end(-1) ----
  106: perf stat JSON output linter                 : FAILED!

Fixes: e1cc918b6c ("perf stat: Drop metric-unit if unit is NULL")
Signed-off-by: James Clark <james.clark@linaro.org>
Tested-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20241112160048.951213-2-james.clark@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-12-26 12:20:43 -03:00
..
attr.py perf test: Move attr files into shell directory where they are used 2024-10-17 13:17:36 -07:00
coresight.sh perf test: Speed up some tests using perf list 2024-10-17 09:55:58 -07:00
perf_has_symbol.sh perf tests: Avoid fork in perf_has_symbol test 2024-02-22 09:12:04 -08:00
perf_json_output_lint.py perf stat: Fix trailing comma when there is no metric unit 2024-12-26 12:20:43 -03:00
perf_metric_validation.py perf test: make metric validation test return early when there is no metric supported on the test system 2024-07-31 16:58:18 -03:00
perf_metric_validation_rules.json perf test: Add skip list for metrics known would fail 2023-06-21 22:23:57 -07:00
probe.sh perf tests lib probe: Fix shellcheck warning about about missing shebang 2023-08-03 17:01:26 -03:00
probe_vfs_getname.sh perf test shell probe_vfs_getname: Remove extraneous '=' from probe line number regex 2024-09-11 09:35:34 -03:00
setup_python.sh perf test: Use common python setup library 2023-12-05 15:48:52 -03:00
stat_output.sh perf test: Stat output per thread of just the parent process 2024-03-21 13:54:39 -03:00
waiting.sh perf tests lib waiting: Fix the shellcheck warnings about missing shebang 2023-08-03 17:01:26 -03:00