]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf test stat+json: Improve metric-only testing
authorIan Rogers <irogers@google.com>
Tue, 11 Nov 2025 21:21:59 +0000 (13:21 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 12 Nov 2025 00:48:35 +0000 (16:48 -0800)
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>
tools/perf/tests/shell/lib/perf_json_output_lint.py
tools/perf/tests/shell/stat+json_output.sh

index c6750ef06c0f8c82de0c295745763868931c389d..1369baaa0361bd20e71b0992eef6463499f16270 100644 (file)
@@ -65,8 +65,6 @@ def check_json_output(expected_items):
       'socket': lambda x: True,
       'thread': lambda x: True,
       'unit': lambda x: True,
-      'insn per cycle': lambda x: isfloat(x),
-      'GHz': lambda x: True,  # FIXME: it seems unintended for --metric-only
   }
   input = '[\n' + ','.join(Lines) + '\n]'
   for item in json.loads(input):
@@ -88,6 +86,8 @@ def check_json_output(expected_items):
                            f' in \'{item}\'')
     for key, value in item.items():
       if key not in checks:
+        if args.metric_only:
+          continue
         raise RuntimeError(f'Unexpected key: key={key} value={value}')
       if not checks[key](value):
         raise RuntimeError(f'Check failed for: key={key} value={value}')
index 98fb65274ac4f722e21872c3e4aca4f0af456fe5..85d1ad7186c6e06b3b9923a133044b2b7e0bdc7e 100755 (executable)
@@ -181,7 +181,7 @@ check_metric_only()
                echo "[Skip] CPU-measurement counter facility not installed"
                return
        fi
-       perf stat -j --metric-only -e instructions,cycles -o "${stat_output}" true
+       perf stat -j --metric-only -M page_faults_per_second -o "${stat_output}" true
        $PYTHON $pythonchecker --metric-only --file "${stat_output}"
        echo "[Success]"
 }