Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test stat+json: Improve metric-only testing

When testing metric-only, pass a metric to perf rather than expecting
a hard coded metric value to be generated.

Remove keys that were really metric-only units and instead don't
expect metric only to have a matching json key as it encodes metrics
as {"metric_name", "metric_value"}.

Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
2c240484 1bcd6271

+3 -3
+2 -2
tools/perf/tests/shell/lib/perf_json_output_lint.py
··· 65 65 'socket': lambda x: True, 66 66 'thread': lambda x: True, 67 67 'unit': lambda x: True, 68 - 'insn per cycle': lambda x: isfloat(x), 69 - 'GHz': lambda x: True, # FIXME: it seems unintended for --metric-only 70 68 } 71 69 input = '[\n' + ','.join(Lines) + '\n]' 72 70 for item in json.loads(input): ··· 86 88 f' in \'{item}\'') 87 89 for key, value in item.items(): 88 90 if key not in checks: 91 + if args.metric_only: 92 + continue 89 93 raise RuntimeError(f'Unexpected key: key={key} value={value}') 90 94 if not checks[key](value): 91 95 raise RuntimeError(f'Check failed for: key={key} value={value}')
+1 -1
tools/perf/tests/shell/stat+json_output.sh
··· 181 181 echo "[Skip] CPU-measurement counter facility not installed" 182 182 return 183 183 fi 184 - perf stat -j --metric-only -e instructions,cycles -o "${stat_output}" true 184 + perf stat -j --metric-only -M page_faults_per_second -o "${stat_output}" true 185 185 $PYTHON $pythonchecker --metric-only --file "${stat_output}" 186 186 echo "[Success]" 187 187 }