diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-11-21 17:22:21 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-11-21 17:22:21 -0800 |
| commit | 4843f6873f7c4835e62f2c73ba0fd538e57a2f22 (patch) | |
| tree | ee620501a1ffbad9a83141e3a70154e1fe641040 /tools/perf/tests/shell/test_gecko_python.sh | |
| download | linux-master.tar.gz linux-master.zip | |
Merge tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctlgraftedHEADmaster
Pull sysctl fix from Joel Granados:
"Fix sysctl jiffy / milliseconds conversion:
- Writing a previously read value "X" shall keep the same "X" value
- Remove truncation that was causing incorrect saturation of valid
timeouts"
* tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl:
sysctl: Do jiffy / ms conversion in ulong space
Diffstat (limited to 'tools/perf/tests/shell/test_gecko_python.sh')
| -rwxr-xr-x | tools/perf/tests/shell/test_gecko_python.sh | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/tools/perf/tests/shell/test_gecko_python.sh b/tools/perf/tests/shell/test_gecko_python.sh new file mode 100755 index 000000000..18e9f5cd2 --- /dev/null +++ b/tools/perf/tests/shell/test_gecko_python.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# gecko python test + +set -e + +shelldir=$(dirname "$0") +# shellcheck source=lib/setup_python.sh +. "${shelldir}"/lib/setup_python.sh + +# If we don't have the perf python module, we can't test +if ! "$PYTHON" -c 'import perf' > /dev/null 2>&1; then + echo "Skipping test, perf python module not found" + exit 2 +fi + +script_dir="$(dirname "$0")/../../python" +script_path="${script_dir}/gecko.py" + +if [ ! -f "$script_path" ]; then + echo "Skipping test, gecko.py not found at $script_path" + exit 2 +fi + +err=0 +temp_data="" +temp_json="" + +cleanup() { + rm -f "${temp_data}" "${temp_json}" +} + +trap 'cleanup' EXIT TERM INT + +temp_data=$(mktemp /tmp/perf.data.XXXXXX) +temp_json=$(mktemp /tmp/perf.gecko.json.XXXXXX) + +test_file_mode() { + echo "Testing gecko.py..." + + # Generate some events with callchains + if ! perf record -B -N --no-bpf-event -g -o "${temp_data}" \ + -- perf test -w noploop >/dev/null 2>&1; then + echo "Skipping test, perf record -g failed (permissions or lack of support)" + exit 2 + fi + + # Run the script in save-only mode with custom product and category colors + if ! perf script gecko -i "${temp_data}" \ + --product "perf-test-product" --user-color blue --kernel-color red \ + --save-only "${temp_json}" >/dev/null; then + echo "File mode test failed." + err=1 + else + # Validate JSON schema and custom CLI option values + if ! "$PYTHON" - "$script_path" "${temp_json}" << 'PYEOF' +import importlib.util +import json +import sys + +with open(sys.argv[2], encoding="utf-8") as f: + data = json.load(f) + +assert data["meta"]["product"] == "perf-test-product" +assert data["meta"]["version"] == 24 +assert isinstance(data["threads"], list) and len(data["threads"]) > 0 + +spec = importlib.util.spec_from_file_location("gecko", sys.argv[1]) +mod = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = mod +spec.loader.exec_module(mod) + +class DummyHandler: + headers = [] + error_code = None + def send_header(self, k, v): + self.headers.append((k, v)) + def send_error(self, code, _msg): + self.error_code = code + +dummy = DummyHandler() +mod.CORSRequestHandler.list_directory(dummy, "/tmp") +assert dummy.error_code == 403 +PYEOF + then + echo "Gecko JSON and CORSRequestHandler validation failed." + err=1 + else + echo "File mode JSON and CORSRequestHandler test passed." + fi + fi +} + +test_file_mode + +exit $err |
