[RFC PATCH v4 0/2] perf/kselftest: convert Perl test helpers to Python

From: Breno Rodrigues Alves

Date: Wed Oct 21 2026 - 16:59:47 EST


This is v4 of the series converting the Perl test helpers to Python.

Changes since v3:
- Fixed pylint W1514 in check_errors_whitelisted.py by passing an
explicit encoding to open():
open(path, encoding="utf-8", errors="surrogateescape")
"surrogateescape" preserves the byte-for-byte behavior of the Perl
original, which reads raw bytes.

- Also fixed two issues found while testing the series locally:
* open() failures on the whitelist now exit with the underlying
errno (matching Perl's die), e.g. ENOENT -> rc 2, instead of
always rc 1.
* stdin/stdout are reconfigured with surrogateescape so that
non-UTF-8 bytes in the log (e.g. oops/KASAN output) do not
raise UnicodeDecodeError/UnicodeEncodeError, preserving the
byte-for-byte behavior of the Perl originals.

- The series is split by tree, addressing Ian's suggestion:
* Patch 1 (kselftest:) touches only tools/testing/selftests/ and can
go through the kselftest tree.
* Patch 2 (perf/tests:) touches only tools/perf/ and can go through
the perf tree.

- Note on pylint-tests: it fails on tools/perf/tests/shell/lib/
perf_json_output_lint.py with:
W4904: Using deprecated class FileType of module argparse
This is pre-existing in perf-tools-next and reproduces on the base
commit without this series. The four files touched by this series
pass pylint 10/10 with the flags used by Makefile.perf.

Signed-off-by: Breno Rodrigues Alves <breno3011alves@xxxxxxxxx>


Breno Rodrigues Alves (2):
kselftest: convert prefix.pl to Python
perf/tests: convert check_*.pl helpers to Python

tools/perf/Makefile.perf | 2 +-
.../base_probe/test_adding_blacklisted.sh | 6 +-
.../shell/base_probe/test_adding_kernel.sh | 44 +++++++-------
.../perf/tests/shell/base_probe/test_basic.sh | 12 ++--
.../shell/base_probe/test_invalid_options.sh | 4 +-
tools/perf/tests/shell/base_report/setup.sh | 4 +-
.../tests/shell/base_report/test_basic.sh | 54 ++++++++---------
.../shell/common/check_all_lines_matched.pl | 39 -------------
.../shell/common/check_all_lines_matched.py | 47 +++++++++++++++
.../shell/common/check_all_patterns_found.pl | 34 -----------
.../shell/common/check_all_patterns_found.py | 37 ++++++++++++
.../shell/common/check_errors_whitelisted.pl | 51 ----------------
.../shell/common/check_errors_whitelisted.py | 58 +++++++++++++++++++
.../shell/common/check_no_patterns_found.pl | 34 -----------
.../shell/common/check_no_patterns_found.py | 37 ++++++++++++
tools/testing/selftests/Makefile | 2 +-
tools/testing/selftests/kselftest/prefix.pl | 24 --------
tools/testing/selftests/kselftest/prefix.py | 24 ++++++++
tools/testing/selftests/kselftest/runner.sh | 4 +-
19 files changed, 269 insertions(+), 248 deletions(-)
delete mode 100755 tools/perf/tests/shell/common/check_all_lines_matched.pl
create mode 100755 tools/perf/tests/shell/common/check_all_lines_matched.py
delete mode 100755 tools/perf/tests/shell/common/check_all_patterns_found.pl
create mode 100755 tools/perf/tests/shell/common/check_all_patterns_found.py
delete mode 100755 tools/perf/tests/shell/common/check_errors_whitelisted.pl
create mode 100755 tools/perf/tests/shell/common/check_errors_whitelisted.py
delete mode 100755 tools/perf/tests/shell/common/check_no_patterns_found.pl
create mode 100755 tools/perf/tests/shell/common/check_no_patterns_found.py
delete mode 100755 tools/testing/selftests/kselftest/prefix.pl
create mode 100755 tools/testing/selftests/kselftest/prefix.py

--
2.56.0