* [RFC PATCH 0/5] perf/tests: convert Perl test helpers to Python
@ 2026-10-18 12:56 Breno Rodrigues Alves
2026-10-18 12:56 ` [RFC PATCH 1/5] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves
` (5 more replies)
0 siblings, 6 replies; 21+ messages in thread
From: Breno Rodrigues Alves @ 2026-10-18 12:56 UTC (permalink / raw)
To: linux-kernel, linux-perf-users, linux-kselftest
Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan,
Breno Rodrigues Alves
This series converts five Perl test helpers in tools/ to Python 3,
continuing the Perl-to-Python conversion effort for the kernel's
auxiliary scripts.
Each conversion is a faithful 1:1 port: same CLI, same output,
same exit codes. All use only the Python standard library.
The five scripts are:
- prefix.pl -> prefix.py
- check_all_patterns_found.pl -> check_all_patterns_found.py
- check_no_patterns_found.pl -> check_no_patterns_found.py
- check_all_lines_matched.pl -> check_all_lines_matched.py
- check_errors_whitelisted.pl -> check_errors_whitelisted.py
All five were verified byte-for-byte identical to their Perl
counterparts on synthetic inputs.
These files are used by perf test shell scripts to validate
test output; they have no dependency on the perf binary or its
Python bindings, so they can be converted independently.
Breno Rodrigues Alves (5):
perf/kselftest: convert prefix.pl to Python
perf/tests: convert check_all_patterns_found.pl to Python
perf/tests: convert check_no_patterns_found.pl to Python
perf/tests: convert check_all_lines_matched.pl to Python
perf/tests: convert check_errors_whitelisted.pl to Python
Breno Rodrigues Alves (5):
perf/kselftest: convert prefix.pl to Python
perf/tests: convert check_all_patterns_found.pl to Python
perf/tests: convert check_no_patterns_found.pl to Python
perf/tests: convert check_all_lines_matched.pl to Python
perf/tests: convert check_errors_whitelisted.pl to Python
.../shell/common/check_all_lines_matched.py | 45 +++++++++++++++
.../shell/common/check_all_patterns_found.py | 35 ++++++++++++
.../shell/common/check_errors_whitelisted.py | 55 +++++++++++++++++++
.../shell/common/check_no_patterns_found.py | 35 ++++++++++++
tools/testing/selftests/kselftest/prefix.py | 24 ++++++++
5 files changed, 194 insertions(+)
create mode 100755 tools/perf/tests/shell/common/check_all_lines_matched.py
create mode 100755 tools/perf/tests/shell/common/check_all_patterns_found.py
create mode 100755 tools/perf/tests/shell/common/check_errors_whitelisted.py
create mode 100755 tools/perf/tests/shell/common/check_no_patterns_found.py
create mode 100755 tools/testing/selftests/kselftest/prefix.py
--
2.43.0
^ permalink raw reply [flat|nested] 21+ messages in thread* [RFC PATCH 1/5] perf/kselftest: convert prefix.pl to Python 2026-10-18 12:56 [RFC PATCH 0/5] perf/tests: convert Perl test helpers to Python Breno Rodrigues Alves @ 2026-10-18 12:56 ` Breno Rodrigues Alves 2026-10-18 13:01 ` sashiko-bot 2026-10-18 12:56 ` [RFC PATCH 2/5] perf/tests: convert check_all_patterns_found.pl " Breno Rodrigues Alves ` (4 subsequent siblings) 5 siblings, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 12:56 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementation of tools/testing/selftests/kselftest/ prefix.pl in Python 3 (stdlib only). Same unbuffered stdin-to-stdout processing, same "# " prefix behavior. Verified byte-for-byte identical to the Perl version. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- tools/testing/selftests/kselftest/prefix.py | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 tools/testing/selftests/kselftest/prefix.py diff --git a/tools/testing/selftests/kselftest/prefix.py b/tools/testing/selftests/kselftest/prefix.py new file mode 100755 index 000000000..2bf16b37d --- /dev/null +++ b/tools/testing/selftests/kselftest/prefix.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# Prefix all lines with "# ", unbuffered. + +import sys + + +def main(): + needed = True + while True: + char = sys.stdin.buffer.read(1) + if not char: + return 0 + if needed: + sys.stdout.buffer.write(b"# ") + needed = False + sys.stdout.buffer.write(char) + sys.stdout.buffer.flush() + if char == b"\n": + needed = True + + +if __name__ == "__main__": + sys.exit(main()) \ No newline at end of file -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH 1/5] perf/kselftest: convert prefix.pl to Python 2026-10-18 12:56 ` [RFC PATCH 1/5] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves @ 2026-10-18 13:01 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:01 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] selftests: prefix.py is unused and not installed by Makefile or runner.sh - [Low] selftests: missing trailing newline at end of prefix.py -- commit f99bbafab30726cd18857c0cc9a21eeae2499158 Author: Breno Rodrigues Alves <breno3011alves@gmail.com> perf/kselftest: convert prefix.pl to Python This commit adds a Python 3 re-implementation of tools/testing/selftests/kselftest/prefix.pl to prefix input lines with "# " in an unbuffered manner. > diff --git a/tools/testing/selftests/kselftest/prefix.py b/tools/testing/selftests/kselftest/prefix.py > new file mode 100755 > index 0000000000000..2bf16b37dee63 > --- /dev/null > +++ b/tools/testing/selftests/kselftest/prefix.py > @@ -0,0 +1,24 @@ > +#!/usr/bin/env python3 > +# SPDX-License-Identifier: GPL-2.0 > +# Prefix all lines with "# ", unbuffered. > + > +import sys > + > + > +def main(): [Severity: Medium] Should tools/testing/selftests/kselftest/runner.sh and tools/testing/selftests/Makefile also be updated to use and install prefix.py, and remove prefix.pl? Currently, tap_prefix() in tools/testing/selftests/kselftest/runner.sh still checks for /usr/bin/perl and invokes prefix.pl: tap_prefix() { if [ ! -x /usr/bin/perl ]; then sed -e 's/^/# /' else "$BASE_DIR"/kselftest/prefix.pl fi } And the install target in tools/testing/selftests/Makefile still only installs prefix.pl: install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/ Without updating those callers, prefix.py is never executed or installed. > + needed = True > + while True: > + char = sys.stdin.buffer.read(1) > + if not char: > + return 0 > + if needed: > + sys.stdout.buffer.write(b"# ") > + needed = False > + sys.stdout.buffer.write(char) > + sys.stdout.buffer.flush() > + if char == b"\n": > + needed = True > + > + > +if __name__ == "__main__": > + sys.exit(main()) > \ No newline at end of file [Severity: Low] Could a trailing newline be added at the end of tools/testing/selftests/kselftest/prefix.py? [] -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018125641.23064-1-breno3011alves@gmail.com?part=1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 2/5] perf/tests: convert check_all_patterns_found.pl to Python 2026-10-18 12:56 [RFC PATCH 0/5] perf/tests: convert Perl test helpers to Python Breno Rodrigues Alves 2026-10-18 12:56 ` [RFC PATCH 1/5] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves @ 2026-10-18 12:56 ` Breno Rodrigues Alves 2026-10-18 13:02 ` sashiko-bot 2026-10-18 12:56 ` [RFC PATCH 3/5] perf/tests: convert check_no_patterns_found.pl " Breno Rodrigues Alves ` (3 subsequent siblings) 5 siblings, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 12:56 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementation of tools/perf/tests/shell/common/ check_all_patterns_found.pl in Python 3 (stdlib only). Same regex matching, same TESTLOG_VERBOSITY/TESTLOG_ERR_MSG_MAX_LINES environment handling, same exit codes. Verified byte-for-byte identical to the Perl version. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- .../shell/common/check_all_patterns_found.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 tools/perf/tests/shell/common/check_all_patterns_found.py diff --git a/tools/perf/tests/shell/common/check_all_patterns_found.py b/tools/perf/tests/shell/common/check_all_patterns_found.py new file mode 100755 index 000000000..3eb907af3 --- /dev/null +++ b/tools/perf/tests/shell/common/check_all_patterns_found.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + found = set() + for line in sys.stdin: + line = line.rstrip("\n") + for r in argv: + if re.search(r, line): + found.add(r) + + passed = True + for r in argv: + if r not in found: + if not quiet: + print(f'Regexp not found: "{r}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) \ No newline at end of file -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH 2/5] perf/tests: convert check_all_patterns_found.pl to Python 2026-10-18 12:56 ` [RFC PATCH 2/5] perf/tests: convert check_all_patterns_found.pl " Breno Rodrigues Alves @ 2026-10-18 13:02 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:02 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] perf/tests: check_all_patterns_found.py added without updating callers -- commit 069a51b64d65753bb41f5e2b0b33fd3d38c715f2 Author: Breno Rodrigues Alves <breno3011alves@gmail.com> perf/tests: convert check_all_patterns_found.pl to Python This commit adds a Python 3 implementation of check_all_patterns_found.pl under tools/perf/tests/shell/common/check_all_patterns_found.py. > perf/tests: convert check_all_patterns_found.pl to Python > > Faithful re-implementation of tools/perf/tests/shell/common/ > check_all_patterns_found.pl in Python 3 (stdlib only). Same > regex matching, same TESTLOG_VERBOSITY/TESTLOG_ERR_MSG_MAX_LINES > environment handling, same exit codes. > > Verified byte-for-byte identical to the Perl version. > > Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> > diff --git a/tools/perf/tests/shell/common/check_all_patterns_found.py b/tools/perf/tests/shell/common/check_all_patterns_found.py > new file mode 100755 > index 0000000000000..3eb907af3d6b2 > --- /dev/null > +++ b/tools/perf/tests/shell/common/check_all_patterns_found.py > @@ -0,0 +1,35 @@ > +#!/usr/bin/env python3 > +# SPDX-License-Identifier: GPL-2.0 > + > +import os > +import re > +import sys > + > + > +def main(argv): > + quiet = True > + try: > + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: > + quiet = False > + except ValueError: > + pass [ ... ] > +if __name__ == "__main__": > + sys.exit(main(sys.argv[1:])) > \ No newline at end of file [Severity: Medium] Should the callers, tools/perf/Makefile.perf, and the old Perl script be updated as part of this conversion? This commit adds tools/perf/tests/shell/common/check_all_patterns_found.py, but tools/perf/tests/shell/common/check_all_patterns_found.pl is not removed, and none of the subsequent patches in this series update the callers or build system. All 37 call sites across the 6 test scripts in tools/perf/tests/shell/base_probe/ (test_adding_blacklisted.sh, test_adding_kernel.sh, test_basic.sh, test_invalid_options.sh) and tools/perf/tests/shell/base_report/ (setup.sh, test_basic.sh) still invoke the Perl script directly: "$DIR_PATH/../common/check_all_patterns_found.pl" \ Also, the install-tests target in tools/perf/Makefile.perf only installs .sh and .pl files from tests/shell/common/: $(INSTALL) tests/shell/common/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) tests/shell/common/*.pl '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ Without updating the test scripts and Makefile.perf, the new Python script is unused and is not installed by make install-tests. Additionally, the commit message mentions TESTLOG_ERR_MSG_MAX_LINES handling, which is not present in either check_all_patterns_found.pl or check_all_patterns_found.py, and the new file is missing a trailing newline. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018125641.23064-1-breno3011alves@gmail.com?part=2 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 3/5] perf/tests: convert check_no_patterns_found.pl to Python 2026-10-18 12:56 [RFC PATCH 0/5] perf/tests: convert Perl test helpers to Python Breno Rodrigues Alves 2026-10-18 12:56 ` [RFC PATCH 1/5] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves 2026-10-18 12:56 ` [RFC PATCH 2/5] perf/tests: convert check_all_patterns_found.pl " Breno Rodrigues Alves @ 2026-10-18 12:56 ` Breno Rodrigues Alves 2026-10-18 13:03 ` sashiko-bot 2026-10-18 12:56 ` [RFC PATCH 4/5] perf/tests: convert check_all_lines_matched.pl " Breno Rodrigues Alves ` (2 subsequent siblings) 5 siblings, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 12:56 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementation of tools/perf/tests/shell/common/ check_no_patterns_found.pl in Python 3 (stdlib only). Same regex matching, same environment handling, same exit codes. Verified byte-for-byte identical to the Perl version. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- .../shell/common/check_no_patterns_found.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 tools/perf/tests/shell/common/check_no_patterns_found.py diff --git a/tools/perf/tests/shell/common/check_no_patterns_found.py b/tools/perf/tests/shell/common/check_no_patterns_found.py new file mode 100755 index 000000000..0e5d931b9 --- /dev/null +++ b/tools/perf/tests/shell/common/check_no_patterns_found.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + found = set() + for line in sys.stdin: + line = line.rstrip("\n") + for r in argv: + if re.search(r, line): + found.add(r) + + passed = True + for r in argv: + if r in found: + if not quiet: + print(f'Regexp found: "{r}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) \ No newline at end of file -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH 3/5] perf/tests: convert check_no_patterns_found.pl to Python 2026-10-18 12:56 ` [RFC PATCH 3/5] perf/tests: convert check_no_patterns_found.pl " Breno Rodrigues Alves @ 2026-10-18 13:03 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:03 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] perf tests: check_no_patterns_found.py is unused and not installed - [Low] perf tests: missing EOF newline in check_no_patterns_found.py breaks PYLINT=1 -- commit d6b15fdc56a31f78fa7365cb6aafd5034b2a393d Author: Breno Rodrigues Alves <breno3011alves@gmail.com> perf/tests: convert check_no_patterns_found.pl to Python This commit adds a Python 3 implementation of check_no_patterns_found.pl under tools/perf/tests/shell/common/check_no_patterns_found.py. > diff --git a/tools/perf/tests/shell/common/check_no_patterns_found.py b/tools/perf/tests/shell/common/check_no_patterns_found.py > new file mode 100755 > index 0000000000000..0e5d931b903a2 > --- /dev/null > +++ b/tools/perf/tests/shell/common/check_no_patterns_found.py > @@ -0,0 +1,35 @@ > +#!/usr/bin/env python3 > +# SPDX-License-Identifier: GPL-2.0 [Severity: Medium] Should this commit also update the existing callers, remove tools/perf/tests/shell/common/check_no_patterns_found.pl, and install the new script? All existing call sites in the test suite still invoke check_no_patterns_found.pl: tools/perf/tests/shell/base_probe/test_adding_kernel.sh: "$DIR_PATH/../common/check_no_patterns_found.pl" \ "$RE_SEGFAULT" < $LOGS_DIR/adding_kernel_nonexisting.err tools/perf/tests/shell/base_probe/test_basic.sh: "$DIR_PATH/../common/check_no_patterns_found.pl" \ "No manual entry for" < $LOGS_DIR/basic_helpmsg.err tools/perf/tests/shell/base_report/test_basic.sh: "$DIR_PATH/../common/check_no_patterns_found.pl" \ "No manual entry for" < $LOGS_DIR/basic_helpmsg.err In addition, the install-tests target in tools/perf/Makefile.perf only installs *.sh and *.pl files from tests/shell/common: tools/perf/Makefile.perf: $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) tests/shell/common/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) tests/shell/common/*.pl '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ Without updating the callers and Makefile.perf, check_no_patterns_found.py is never executed or installed. [ ... ] > +if __name__ == "__main__": > + sys.exit(main(sys.argv[1:])) > \ No newline at end of file [Severity: Low] Does the missing trailing newline at the end of check_no_patterns_found.py cause a build failure when building perf with PYLINT=1? In tools/perf/tests/Build, PY_TESTS collects all *.py files under tests/shell to run pylint: tools/perf/tests/Build: ifdef PYLINT PY_TESTS := $(shell find tests/shell -type f -name '*.py') PYLINT_TEST_LOGS := $(PY_TESTS:tests/shell/%=shell/%.pylint_log) Because main() in tools/perf/tests/shell/common/check_no_patterns_found.py ends without a final newline (and without pylint directives or docstrings), pylint reports C0304 (missing-final-newline) and fails the build when PYLINT=1 is enabled. Can a trailing newline be added at the end of the file? -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018125641.23064-1-breno3011alves@gmail.com?part=3 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 4/5] perf/tests: convert check_all_lines_matched.pl to Python 2026-10-18 12:56 [RFC PATCH 0/5] perf/tests: convert Perl test helpers to Python Breno Rodrigues Alves ` (2 preceding siblings ...) 2026-10-18 12:56 ` [RFC PATCH 3/5] perf/tests: convert check_no_patterns_found.pl " Breno Rodrigues Alves @ 2026-10-18 12:56 ` Breno Rodrigues Alves 2026-10-18 13:07 ` sashiko-bot 2026-10-18 12:56 ` [RFC PATCH 5/5] perf/tests: convert check_errors_whitelisted.pl " Breno Rodrigues Alves 2026-10-18 13:30 ` [RFC PATCH v2 0/2] perf: convert Perl test helpers " Breno Rodrigues Alves 5 siblings, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 12:56 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementation of tools/perf/tests/shell/common/ check_all_lines_matched.pl in Python 3 (stdlib only). Same regex matching, same environment handling, same exit codes. Verified byte-for-byte identical to the Perl version. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- .../shell/common/check_all_lines_matched.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 tools/perf/tests/shell/common/check_all_lines_matched.py diff --git a/tools/perf/tests/shell/common/check_all_lines_matched.py b/tools/perf/tests/shell/common/check_all_lines_matched.py new file mode 100755 index 000000000..352a56d8b --- /dev/null +++ b/tools/perf/tests/shell/common/check_all_lines_matched.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + max_printed = 20 + if "TESTLOG_ERR_MSG_MAX_LINES" in os.environ: + try: + max_printed = int(os.environ["TESTLOG_ERR_MSG_MAX_LINES"]) + except ValueError: + pass + + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + passed = True + lines_printed = 0 + + for line in sys.stdin: + line = line.rstrip("\n") + matched = False + for r in argv: + if re.search(r, line): + matched = True + break + if not matched: + show = lines_printed < max_printed + lines_printed += 1 + if show and not quiet: + print(f'Line did not match any pattern: "{line}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) \ No newline at end of file -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH 4/5] perf/tests: convert check_all_lines_matched.pl to Python 2026-10-18 12:56 ` [RFC PATCH 4/5] perf/tests: convert check_all_lines_matched.pl " Breno Rodrigues Alves @ 2026-10-18 13:07 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:07 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] perf tests: check_all_lines_matched.py is never wired up or installed -- commit d9f6b313408b62305572a2fb532ed1583f0179f7 Author: Breno Rodrigues Alves <breno3011alves@gmail.com> perf/tests: convert check_all_lines_matched.pl to Python This commit adds a Python 3 implementation of tools/perf/tests/shell/common/check_all_lines_matched.pl. > diff --git a/tools/perf/tests/shell/common/check_all_lines_matched.py b/tools/perf/tests/shell/common/check_all_lines_matched.py > new file mode 100755 > index 0000000000000..352a56d8b9809 > --- /dev/null > +++ b/tools/perf/tests/shell/common/check_all_lines_matched.py > @@ -0,0 +1,45 @@ > +#!/usr/bin/env python3 > +# SPDX-License-Identifier: GPL-2.0 > + > +import os > +import re > +import sys > + > + > +def main(argv): [Severity: Medium] Should this commit also update the existing callers and installation rules, and remove tools/perf/tests/shell/common/check_all_lines_matched.pl? Currently, check_all_lines_matched.py is added, but the shell test scripts still invoke check_all_lines_matched.pl (which is also not updated in the subsequent commit f4ac81889a75 in this series): tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh: "$DIR_PATH/../common/check_all_lines_matched.pl" \ "$REGEX_SKIP_MESSAGE" "$REGEX_NOT_FOUND_MESSAGE" \ tools/perf/tests/shell/base_probe/test_adding_kernel.sh: "$DIR_PATH/../common/check_all_lines_matched.pl" \ "$RE_LINE_EMPTY" "List of pre-defined events" \ tools/perf/tests/shell/base_report/test_basic.sh: grep -P -v '^#' $LOGS_DIR/basic_pid.log | grep -P '\s+[\d\.]+%' | \ "$DIR_PATH/../common/check_all_lines_matched.pl" "systemd|init" In addition, the install-tests target in tools/perf/Makefile.perf only installs *.sh and *.pl files from tests/shell/common, omitting *.py: tools/perf/Makefile.perf: $(INSTALL) tests/shell/common/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) tests/shell/common/*.pl '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ [ ... ] > +if __name__ == "__main__": > + sys.exit(main(sys.argv[1:])) > \ No newline at end of file -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018125641.23064-1-breno3011alves@gmail.com?part=4 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 5/5] perf/tests: convert check_errors_whitelisted.pl to Python 2026-10-18 12:56 [RFC PATCH 0/5] perf/tests: convert Perl test helpers to Python Breno Rodrigues Alves ` (3 preceding siblings ...) 2026-10-18 12:56 ` [RFC PATCH 4/5] perf/tests: convert check_all_lines_matched.pl " Breno Rodrigues Alves @ 2026-10-18 12:56 ` Breno Rodrigues Alves 2026-10-18 13:02 ` sashiko-bot 2026-10-18 13:30 ` [RFC PATCH v2 0/2] perf: convert Perl test helpers " Breno Rodrigues Alves 5 siblings, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 12:56 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementation of tools/perf/tests/shell/common/ check_errors_whitelisted.pl in Python 3 (stdlib only). Same whitelist file handling, same regex matching, same exit codes. Verified byte-for-byte identical to the Perl version. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- .../shell/common/check_errors_whitelisted.py | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 tools/perf/tests/shell/common/check_errors_whitelisted.py diff --git a/tools/perf/tests/shell/common/check_errors_whitelisted.py b/tools/perf/tests/shell/common/check_errors_whitelisted.py new file mode 100755 index 000000000..352eb1a9d --- /dev/null +++ b/tools/perf/tests/shell/common/check_errors_whitelisted.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + if argv: + whitelist = argv[0] + try: + with open(whitelist) as f: + regexps = [ln.rstrip("\n") for ln in f] + except OSError: + sys.exit(f"Checker error: Unable to open the whitelist file: {whitelist}") + else: + regexps = [] + + max_printed = 20 + if "TESTLOG_ERR_MSG_MAX_LINES" in os.environ: + try: + max_printed = int(os.environ["TESTLOG_ERR_MSG_MAX_LINES"]) + except ValueError: + pass + + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + passed = True + lines_printed = 0 + + for line in sys.stdin: + line = line.rstrip("\n") + matched = False + for r in regexps: + if re.search(r, line): + matched = True + break + if not matched: + show = lines_printed < max_printed + lines_printed += 1 + if show and not quiet: + print(f'Line did not match any pattern: "{line}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) \ No newline at end of file -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH 5/5] perf/tests: convert check_errors_whitelisted.pl to Python 2026-10-18 12:56 ` [RFC PATCH 5/5] perf/tests: convert check_errors_whitelisted.pl " Breno Rodrigues Alves @ 2026-10-18 13:02 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:02 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] perf/tests: check_errors_whitelisted.py is unused and not installed - [Low] perf/tests: missing trailing newline in check_errors_whitelisted.py -- commit f4ac81889a756943e8a2c98f2bfeb3dd3b8cd1a1 Author: Breno Rodrigues Alves <breno3011alves@gmail.com> perf/tests: convert check_errors_whitelisted.pl to Python This patch adds a Python 3 implementation of the error whitelist checker script in tools/perf/tests/shell/common/check_errors_whitelisted.py. > diff --git a/tools/perf/tests/shell/common/check_errors_whitelisted.py b/tools/perf/tests/shell/common/check_errors_whitelisted.py > new file mode 100755 > index 0000000000000..352eb1a9dd06b > --- /dev/null > +++ b/tools/perf/tests/shell/common/check_errors_whitelisted.py > @@ -0,0 +1,55 @@ > +#!/usr/bin/env python3 > +# SPDX-License-Identifier: GPL-2.0 > + > +import os > +import re > +import sys > + > + > +def main(argv): [Severity: Medium] Is this conversion complete? While this patch adds check_errors_whitelisted.py, none of the callers in tools/perf/tests/shell/base_report/test_basic.sh are updated to use it, and instead still invoke check_errors_whitelisted.pl: "$DIR_PATH/../common/check_errors_whitelisted.pl" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_basic.err In addition, the install-tests target in tools/perf/Makefile.perf only installs *.sh and *.pl files from tests/shell/common/ and omits *.py files: $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) tests/shell/common/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) tests/shell/common/*.pl '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ Should test_basic.sh and Makefile.perf be updated to use and install check_errors_whitelisted.py, and should the old tools/perf/tests/shell/common/check_errors_whitelisted.pl file be removed? [ ... ] > + return 0 if passed else 1 > + > + > +if __name__ == "__main__": > + sys.exit(main(sys.argv[1:])) > \ No newline at end of file [Severity: Low] Could a trailing newline be added to the end of tools/perf/tests/shell/common/check_errors_whitelisted.py? -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018125641.23064-1-breno3011alves@gmail.com?part=5 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH v2 0/2] perf: convert Perl test helpers to Python 2026-10-18 12:56 [RFC PATCH 0/5] perf/tests: convert Perl test helpers to Python Breno Rodrigues Alves ` (4 preceding siblings ...) 2026-10-18 12:56 ` [RFC PATCH 5/5] perf/tests: convert check_errors_whitelisted.pl " Breno Rodrigues Alves @ 2026-10-18 13:30 ` Breno Rodrigues Alves 2026-10-18 13:30 ` [RFC PATCH v2 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves ` (2 more replies) 5 siblings, 3 replies; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 13:30 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves v2 changes since v1: - Restructure as 2 commits (prefix.py alone; the 4 check_*.py together, since their callers are heavily intermingled) - Update runner.sh and kselftest/Makefile to invoke/install prefix.py - Update Makefile.perf to install *.py (not just *.sh/*.pl) - Update all call sites in base_probe/ and base_report/ - Remove the 5 original .pl files - Add trailing newlines to all 5 files (pylint C0304) - Fix the check_all_patterns_found commit message: TESTLOG_ERR_MSG_MAX_LINES is only handled by check_all_lines_matched This series converts five Perl test helpers in tools/ to Python 3, continuing the Perl-to-Python conversion effort for the kernel's auxiliary scripts. Each conversion is a faithful 1:1 port: same CLI, same output, same exit codes. All use only the Python standard library. The five scripts are: - prefix.pl -> prefix.py - check_all_patterns_found.pl -> check_all_patterns_found.py - check_no_patterns_found.pl -> check_no_patterns_found.py - check_all_lines_matched.pl -> check_all_lines_matched.py - check_errors_whitelisted.pl -> check_errors_whitelisted.py All five were verified byte-for-byte identical to their Perl counterparts on synthetic inputs. Breno Rodrigues Alves (2): perf/kselftest: convert prefix.pl to Python perf/tests: convert check_*.pl helpers to Python Breno Rodrigues Alves (2): perf/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 | 45 +++++++++++++++ .../shell/common/check_all_patterns_found.pl | 34 ------------ .../shell/common/check_all_patterns_found.py | 35 ++++++++++++ .../shell/common/check_errors_whitelisted.pl | 51 ----------------- .../shell/common/check_errors_whitelisted.py | 55 +++++++++++++++++++ .../shell/common/check_no_patterns_found.pl | 34 ------------ .../shell/common/check_no_patterns_found.py | 35 ++++++++++++ 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 | 7 +-- 19 files changed, 260 insertions(+), 251 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.43.0 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH v2 1/2] perf/kselftest: convert prefix.pl to Python 2026-10-18 13:30 ` [RFC PATCH v2 0/2] perf: convert Perl test helpers " Breno Rodrigues Alves @ 2026-10-18 13:30 ` Breno Rodrigues Alves 2026-10-18 13:35 ` sashiko-bot 2026-10-18 13:30 ` [RFC PATCH v2 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves 2026-10-18 13:43 ` [RFC PATCH v3 0/2] perf: convert Perl test " Breno Rodrigues Alves 2 siblings, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 13:30 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementation of tools/testing/selftests/kselftest/ prefix.pl in Python 3 (stdlib only). Same unbuffered stdin-to-stdout processing, same "# " prefix behavior. Update runner.sh to invoke prefix.py instead of prefix.pl, update the install target to install prefix.py, and remove the old prefix.pl. Verified byte-for-byte identical to the Perl version. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- 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 | 7 ++---- 4 files changed, 27 insertions(+), 30 deletions(-) delete mode 100755 tools/testing/selftests/kselftest/prefix.pl create mode 100755 tools/testing/selftests/kselftest/prefix.py diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index bc4fdb6f5..85ed9af96 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -285,7 +285,7 @@ ifdef INSTALL_PATH mkdir -p $(INSTALL_PATH)/kselftest install -m 744 kselftest/module.sh $(INSTALL_PATH)/kselftest/ install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/ - install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/ + install -m 744 kselftest/prefix.py $(INSTALL_PATH)/kselftest/ install -m 744 kselftest/ktap_helpers.sh $(INSTALL_PATH)/kselftest/ install -m 744 kselftest/ksft.py $(INSTALL_PATH)/kselftest/ install -m 744 run_kselftest.sh $(INSTALL_PATH)/ diff --git a/tools/testing/selftests/kselftest/prefix.pl b/tools/testing/selftests/kselftest/prefix.pl deleted file mode 100755 index 12a7f4ca2..000000000 --- a/tools/testing/selftests/kselftest/prefix.pl +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env perl -# SPDX-License-Identifier: GPL-2.0 -# Prefix all lines with "# ", unbuffered. Command being piped in may need -# to have unbuffering forced with "stdbuf -i0 -o0 -e0 $cmd". -use strict; -use IO::Handle; - -binmode STDIN; -binmode STDOUT; - -STDOUT->autoflush(1); - -my $needed = 1; -while (1) { - my $char; - my $bytes = sysread(STDIN, $char, 1); - exit 0 if ($bytes == 0); - if ($needed) { - print "# "; - $needed = 0; - } - print $char; - $needed = 1 if ($char eq "\n"); -} diff --git a/tools/testing/selftests/kselftest/prefix.py b/tools/testing/selftests/kselftest/prefix.py new file mode 100755 index 000000000..67c4fd0b6 --- /dev/null +++ b/tools/testing/selftests/kselftest/prefix.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# Prefix all lines with "# ", unbuffered. + +import sys + + +def main(): + needed = True + while True: + char = sys.stdin.buffer.read(1) + if not char: + return 0 + if needed: + sys.stdout.buffer.write(b"# ") + needed = False + sys.stdout.buffer.write(char) + sys.stdout.buffer.flush() + if char == b"\n": + needed = True + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 311811dc5..b61ea6c2d 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -29,15 +29,12 @@ TR_CMD=$(command -v tr) # with sed instead of unbuffered output. tap_prefix() { - if [ ! -x /usr/bin/perl ]; then + if [ ! -x /usr/bin/python3 ]; then sed -e 's/^/# /' else - "$BASE_DIR"/kselftest/prefix.pl + "$BASE_DIR"/kselftest/prefix.py fi } - -tap_timeout() -{ # Make sure tests will time out if utility is available. if [ -x /usr/bin/timeout ] ; then /usr/bin/timeout --foreground "$kselftest_timeout" \ -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH v2 1/2] perf/kselftest: convert prefix.pl to Python 2026-10-18 13:30 ` [RFC PATCH v2 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves @ 2026-10-18 13:35 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:35 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] selftests: accidental deletion of tap_timeout() header in runner.sh -- commit 3307ba1d73611e0bd22bd59e12d190de9b29a3a2 Author: Breno Rodrigues Alves <breno3011alves@gmail.com> perf/kselftest: convert prefix.pl to Python This commit replaces tools/testing/selftests/kselftest/prefix.pl with a Python 3 implementation (prefix.py) and updates runner.sh and the selftests Makefile to use and install the new script. > diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh > index 311811dc55a07..b61ea6c2de89d 100644 > --- a/tools/testing/selftests/kselftest/runner.sh > +++ b/tools/testing/selftests/kselftest/runner.sh > @@ -29,15 +29,12 @@ TR_CMD=$(command -v tr) > # with sed instead of unbuffered output. > tap_prefix() > { > - if [ ! -x /usr/bin/perl ]; then > + if [ ! -x /usr/bin/python3 ]; then > sed -e 's/^/# /' > else > - "$BASE_DIR"/kselftest/prefix.pl > + "$BASE_DIR"/kselftest/prefix.py > fi > } > - > -tap_timeout() > -{ > # Make sure tests will time out if utility is available. > if [ -x /usr/bin/timeout ] ; then > /usr/bin/timeout --foreground "$kselftest_timeout" \ [Severity: Medium] Was the removal of the tap_timeout() function header and opening brace here unintentional? Without it, the body of tap_timeout() is left at top-level scope followed by an unmatched closing brace: tools/testing/selftests/kselftest/runner.sh: # Make sure tests will time out if utility is available. if [ -x /usr/bin/timeout ] ; then /usr/bin/timeout --foreground "$kselftest_timeout" \ /usr/bin/timeout "$kselftest_timeout" $1 else $1 fi } When tools/testing/selftests/kselftest/runner.sh is sourced (for example via RUN_TESTS in tools/testing/selftests/lib.mk or tools/testing/selftests/run_kselftest.sh), the shell executes the timeout logic immediately and fails with a syntax error on the closing brace. In addition, tap_timeout() is no longer defined when run_one() invokes it: tools/testing/selftests/kselftest/runner.sh:run_one() { ... (((( tap_timeout "$cmd" 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) | (read xs; exit $xs)) 4>>"$logfile" ... } — AI reviewed your patch. Please follow the URL below to transplant the feedback or give kudos to the AI: https://github.com/kernel-patches/vmtest/wiki 계가 -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018133032.24467-1-breno3011alves@gmail.com?part=1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH v2 2/2] perf/tests: convert check_*.pl helpers to Python 2026-10-18 13:30 ` [RFC PATCH v2 0/2] perf: convert Perl test helpers " Breno Rodrigues Alves 2026-10-18 13:30 ` [RFC PATCH v2 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves @ 2026-10-18 13:30 ` Breno Rodrigues Alves 2026-10-18 13:34 ` sashiko-bot 2026-10-18 13:43 ` [RFC PATCH v3 0/2] perf: convert Perl test " Breno Rodrigues Alves 2 siblings, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 13:30 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementations of the four Perl test helpers in tools/perf/tests/shell/common/: - check_all_patterns_found.pl - check_no_patterns_found.pl - check_all_lines_matched.pl - check_errors_whitelisted.pl Same CLI, same output, same exit codes. All use only the Python standard library. TESTLOG_VERBOSITY and TESTLOG_ERR_MSG_MAX_LINES environment handling is preserved. Update all 37 call sites across base_probe/ and base_report/ to invoke the .py versions. Update Makefile.perf's install-tests target to install *.py files (in addition to *.sh) from tests/shell/common/. Remove the four old .pl files. All four were verified byte-for-byte identical to their Perl counterparts on synthetic inputs. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- 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 | 45 +++++++++++++++ .../shell/common/check_all_patterns_found.pl | 34 ------------ .../shell/common/check_all_patterns_found.py | 35 ++++++++++++ .../shell/common/check_errors_whitelisted.pl | 51 ----------------- .../shell/common/check_errors_whitelisted.py | 55 +++++++++++++++++++ .../shell/common/check_no_patterns_found.pl | 34 ------------ .../shell/common/check_no_patterns_found.py | 35 ++++++++++++ 15 files changed, 233 insertions(+), 221 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 diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 29cfd44c4..c9120eab6 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -885,7 +885,7 @@ install-tests: all install-gtk $(INSTALL) tests/shell/lib/*.py -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) tests/shell/common/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ - $(INSTALL) tests/shell/common/*.pl '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ + $(INSTALL) tests/shell/common/*.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_probe'; \ $(INSTALL) tests/shell/base_probe/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_probe'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_report'; \ diff --git a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh index f74aab5c5..867545a62 100755 --- a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh +++ b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh @@ -54,7 +54,7 @@ for BLACKFUNC in $BLACKFUNC_LIST; do PERF_EXIT_CODE=$? # check for bad DWARF polluting the result - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_MISSING_DECL_LINE" >/dev/null < $LOGS_DIR/adding_blacklisted.err if [ $? -eq 0 ]; then @@ -75,7 +75,7 @@ for BLACKFUNC in $BLACKFUNC_LIST; do fi fi else - "$DIR_PATH/../common/check_all_lines_matched.pl" \ + "$DIR_PATH/../common/check_all_lines_matched.py" \ "$REGEX_SKIP_MESSAGE" "$REGEX_NOT_FOUND_MESSAGE" \ "$REGEX_ERROR_MESSAGE" "$REGEX_SCOPE_FAIL" \ "$REGEX_INVALID_ARGUMENT" "$REGEX_SYMBOL_FAIL" \ @@ -100,7 +100,7 @@ fi $CMD_PERF list probe:\* > $LOGS_DIR/adding_blacklisted_list.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$RE_LINE_EMPTY" "List of pre-defined events" "Metric Groups:" \ < $LOGS_DIR/adding_blacklisted_list.log CHECK_EXIT_CODE=$? diff --git a/tools/perf/tests/shell/base_probe/test_adding_kernel.sh b/tools/perf/tests/shell/base_probe/test_adding_kernel.sh index 555a825d5..3e12e5c38 100755 --- a/tools/perf/tests/shell/base_probe/test_adding_kernel.sh +++ b/tools/perf/tests/shell/base_probe/test_adding_kernel.sh @@ -45,7 +45,7 @@ for opt in "" "-a" "--add"; do $CMD_PERF probe $opt $TEST_PROBE 2> $LOGS_DIR/adding_kernel_add$opt.err PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:$TEST_PROBE" "on $TEST_PROBE" \ < $LOGS_DIR/adding_kernel_add$opt.err CHECK_EXIT_CODE=$? @@ -61,7 +61,7 @@ done $CMD_PERF list probe:\* > $LOGS_DIR/adding_kernel_list.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$RE_LINE_EMPTY" "List of pre-defined events" \ "probe:${TEST_PROBE}(?:_\d+)?\s+\[Tracepoint event\]" \ "Metric Groups:" < $LOGS_DIR/adding_kernel_list.log @@ -77,7 +77,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "listing added probe :: perf list $CMD_PERF probe -l > $LOGS_DIR/adding_kernel_list-l.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "\s*probe:${TEST_PROBE}(?:_\d+)?\s+\(on ${TEST_PROBE}(?:[:\+]$RE_NUMBER_HEX)?@.+\)" \ < $LOGS_DIR/adding_kernel_list-l.log CHECK_EXIT_CODE=$? @@ -101,11 +101,11 @@ REGEX_STAT_VALUES="\s*\d+\s+probe:$TEST_PROBE" # the value should be greater than 1 REGEX_STAT_VALUE_NONZERO="\s*[1-9][0-9]*\s+probe:$TEST_PROBE" REGEX_STAT_TIME="\s*$RE_NUMBER\s+seconds (?:time elapsed|user|sys)" -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$REGEX_STAT_HEADER" "$REGEX_STAT_VALUES" "$REGEX_STAT_TIME" \ "$RE_LINE_COMMENT" "$RE_LINE_EMPTY" < $LOGS_DIR/adding_kernel_using_probe.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_STAT_HEADER" "$REGEX_STAT_VALUE_NONZERO" "$REGEX_STAT_TIME" \ < $LOGS_DIR/adding_kernel_using_probe.log (( CHECK_EXIT_CODE += $? )) @@ -120,7 +120,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "using added probe" $CMD_PERF probe -d $TEST_PROBE\* 2> $LOGS_DIR/adding_kernel_removing.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "Removed event: probe:$TEST_PROBE" < $LOGS_DIR/adding_kernel_removing.err CHECK_EXIT_CODE=$? @@ -134,7 +134,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "deleting added probe" $CMD_PERF list probe:\* > $LOGS_DIR/adding_kernel_list_removed.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$RE_LINE_EMPTY" "List of pre-defined events" "Metric Groups:" \ < $LOGS_DIR/adding_kernel_list_removed.log CHECK_EXIT_CODE=$? @@ -150,7 +150,7 @@ $CMD_PERF probe -n --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_dryrun.err PERF_EXIT_CODE=$? # check for the output (should be the same as usual) -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:$TEST_PROBE" "on $TEST_PROBE" \ < $LOGS_DIR/adding_kernel_dryrun.err CHECK_EXIT_CODE=$? @@ -169,7 +169,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "dry run :: adding probe" $CMD_PERF probe --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_forceadd_01.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:$TEST_PROBE" "on $TEST_PROBE" \ < $LOGS_DIR/adding_kernel_forceadd_01.err CHECK_EXIT_CODE=$? @@ -181,7 +181,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "force-adding probes :: first pro ! $CMD_PERF probe --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_forceadd_02.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Error: event \"$TEST_PROBE\" already exists." \ "Error: Failed to add events." < $LOGS_DIR/adding_kernel_forceadd_02.err CHECK_EXIT_CODE=$? @@ -194,7 +194,7 @@ NO_OF_PROBES=`$CMD_PERF probe -l $TEST_PROBE| wc -l` $CMD_PERF probe --force --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_forceadd_03.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:${TEST_PROBE}_${NO_OF_PROBES}" \ "on $TEST_PROBE" < $LOGS_DIR/adding_kernel_forceadd_03.err CHECK_EXIT_CODE=$? @@ -210,7 +210,7 @@ $CMD_PERF stat -e probe:$TEST_PROBE -e probe:${TEST_PROBE}_${NO_OF_PROBES} -x';' PERF_EXIT_CODE=$? REGEX_LINE="$RE_NUMBER;+probe:${TEST_PROBE}_?(?:$NO_OF_PROBES)?;$RE_NUMBER;$RE_NUMBER" -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$REGEX_LINE" "$RE_LINE_EMPTY" "$RE_LINE_COMMENT" \ < $LOGS_DIR/adding_kernel_using_two.log CHECK_EXIT_CODE=$? @@ -230,7 +230,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "using doubled probe" $CMD_PERF probe --del \* 2> $LOGS_DIR/adding_kernel_removing_wildcard.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "Removed event: probe:$TEST_PROBE" \ "Removed event: probe:${TEST_PROBE}_1" < $LOGS_DIR/adding_kernel_removing_wildcard.err CHECK_EXIT_CODE=$? @@ -244,7 +244,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "removing multiple probes" $CMD_PERF probe -nf --max-probes=512 -a 'vfs_* $params' 2> $LOGS_DIR/adding_kernel_adding_wildcard.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "probe:vfs_mknod" "probe:vfs_create" "probe:vfs_rmdir" \ "probe:vfs_link" "probe:vfs_write" < $LOGS_DIR/adding_kernel_adding_wildcard.err CHECK_EXIT_CODE=$? @@ -269,21 +269,21 @@ test $PERF_EXIT_CODE -ne 139 -a $PERF_EXIT_CODE -ne 0 PERF_EXIT_CODE=$? # check that the error message is reasonable -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Failed to find" \ "somenonexistingrandomstuffwhichisalsoprettylongorevenlongertoexceed64" \ < $LOGS_DIR/adding_kernel_nonexisting.err CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "in this function|at this address" "Error" "Failed to add events" \ < $LOGS_DIR/adding_kernel_nonexisting.err (( CHECK_EXIT_CODE += $? )) -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "Failed to find" "Error" "Probe point .+ not found" "optimized out" \ "Use.+\-\-range option to show.+location range" \ < $LOGS_DIR/adding_kernel_nonexisting.err (( CHECK_EXIT_CODE += $? )) -"$DIR_PATH/../common/check_no_patterns_found.pl" \ +"$DIR_PATH/../common/check_no_patterns_found.py" \ "$RE_SEGFAULT" < $LOGS_DIR/adding_kernel_nonexisting.err (( CHECK_EXIT_CODE += $? )) @@ -302,7 +302,7 @@ fi $CMD_PERF probe --add "$TEST_PROBE%return \$retval" 2> $LOGS_DIR/adding_kernel_func_retval_add.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:$TEST_PROBE" \ "on $TEST_PROBE%return with \\\$retval" \ < $LOGS_DIR/adding_kernel_func_retval_add.err @@ -315,7 +315,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "function with retval :: add" $CMD_PERF record -e probe:$TEST_PROBE\* -o $CURRENT_TEST_DIR/perf.data -- cat /proc/cpuinfo > /dev/null 2> $LOGS_DIR/adding_kernel_func_retval_record.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" \ < $LOGS_DIR/adding_kernel_func_retval_record.err CHECK_EXIT_CODE=$? @@ -328,10 +328,10 @@ $CMD_PERF script -i $CURRENT_TEST_DIR/perf.data > $LOGS_DIR/adding_kernel_func_r PERF_EXIT_CODE=$? REGEX_SCRIPT_LINE="\s*cat\s+$RE_NUMBER\s+\[$RE_NUMBER\]\s+$RE_NUMBER:\s+probe:$TEST_PROBE\w*:\s+\($RE_NUMBER_HEX\s+<\-\s+$RE_NUMBER_HEX\)\s+arg1=$RE_NUMBER_HEX" -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$REGEX_SCRIPT_LINE" < $LOGS_DIR/adding_kernel_func_retval_script.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_SCRIPT_LINE" < $LOGS_DIR/adding_kernel_func_retval_script.log (( CHECK_EXIT_CODE += $? )) diff --git a/tools/perf/tests/shell/base_probe/test_basic.sh b/tools/perf/tests/shell/base_probe/test_basic.sh index 162838ddc..a702be734 100755 --- a/tools/perf/tests/shell/base_probe/test_basic.sh +++ b/tools/perf/tests/shell/base_probe/test_basic.sh @@ -31,24 +31,24 @@ if [ "$PARAM_GENERAL_HELP_TEXT_CHECK" = "y" ]; then $CMD_PERF probe --help > $LOGS_DIR/basic_helpmsg.log 2> $LOGS_DIR/basic_helpmsg.err PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "PERF-PROBE" "NAME" "SYNOPSIS" "DESCRIPTION" "OPTIONS" \ "PROBE\s+SYNTAX" "PROBE\s+ARGUMENT" "LINE\s+SYNTAX" \ < $LOGS_DIR/basic_helpmsg.log CHECK_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "LAZY\s+MATCHING" "FILTER\s+PATTERN" "EXAMPLES" "SEE\s+ALSO" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "vmlinux" "module=" "source=" "verbose" "quiet" "add=" "del=" \ "list.*EVENT" "line=" "vars=" "externs" < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "no-inlines" "funcs.*FILTER" "filter=FILTER" "force" "dry-run" \ "max-probes" "exec=" "demangle-kernel" < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_no_patterns_found.pl" \ + "$DIR_PATH/../common/check_no_patterns_found.py" \ "No manual entry for" < $LOGS_DIR/basic_helpmsg.err (( CHECK_EXIT_CODE += $? )) @@ -64,7 +64,7 @@ fi # without any args perf-probe should print usage $CMD_PERF probe 2> $LOGS_DIR/basic_usage.log > /dev/null -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "[Uu]sage" "perf probe" "verbose" "quiet" "add" "del" "force" \ "line" "vars" "externs" "range" < $LOGS_DIR/basic_usage.log CHECK_EXIT_CODE=$? diff --git a/tools/perf/tests/shell/base_probe/test_invalid_options.sh b/tools/perf/tests/shell/base_probe/test_invalid_options.sh index 44a3ae014..d88bb7ec5 100755 --- a/tools/perf/tests/shell/base_probe/test_invalid_options.sh +++ b/tools/perf/tests/shell/base_probe/test_invalid_options.sh @@ -34,7 +34,7 @@ for opt in '-a' '-d' '-L' '-V'; do ! $CMD_PERF probe $opt 2> $LOGS_DIR/invalid_options_missing_argument$opt.err PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "Error: switch .* requires a value" \ < $LOGS_DIR/invalid_options_missing_argument$opt.err CHECK_EXIT_CODE=$? @@ -69,7 +69,7 @@ for opt in '-a xxx -d xxx' '-a xxx -L foo' '-a xxx -V foo' '-a xxx -l' '-a xxx - ! $CMD_PERF probe $opt > /dev/null 2> $LOGS_DIR/aux.log PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "Error: switch .+ cannot be used with switch .+" < $LOGS_DIR/aux.log CHECK_EXIT_CODE=$? diff --git a/tools/perf/tests/shell/base_report/setup.sh b/tools/perf/tests/shell/base_report/setup.sh index bb49b0fab..10fe4b553 100755 --- a/tools/perf/tests/shell/base_report/setup.sh +++ b/tools/perf/tests/shell/base_report/setup.sh @@ -26,7 +26,7 @@ SW_EVENT="cpu-clock" $CMD_PERF record -asdg -e $SW_EVENT -o $CURRENT_TEST_DIR/perf.data -- $CMD_LONGER_SLEEP 2> $LOGS_DIR/setup.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" < $LOGS_DIR/setup.log CHECK_EXIT_CODE=$? @@ -41,7 +41,7 @@ echo ================== cat $LOGS_DIR/setup-latency.log echo ================== -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" < $LOGS_DIR/setup-latency.log CHECK_EXIT_CODE=$? diff --git a/tools/perf/tests/shell/base_report/test_basic.sh b/tools/perf/tests/shell/base_report/test_basic.sh index 0dfe7e5fd..9bfec0068 100755 --- a/tools/perf/tests/shell/base_report/test_basic.sh +++ b/tools/perf/tests/shell/base_report/test_basic.sh @@ -26,36 +26,36 @@ if [ "$PARAM_GENERAL_HELP_TEXT_CHECK" = "y" ]; then $CMD_PERF report --help > $LOGS_DIR/basic_helpmsg.log 2> $LOGS_DIR/basic_helpmsg.err PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "PERF-REPORT" "NAME" "SYNOPSIS" "DESCRIPTION" "OPTIONS" \ "OVERHEAD\s+CALCULATION" "SEE ALSO" < $LOGS_DIR/basic_helpmsg.log CHECK_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "input" "verbose" "show-nr-samples" "show-cpu-utilization" \ "threads" "comms" "pid" "tid" "dsos" "symbols" "symbol-filter" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "hide-unresolved" "sort" "fields" "parent" "exclude-other" \ "column-widths" "field-separator" "dump-raw-trace" "children" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "call-graph" "max-stack" "inverted" "ignore-callees" "pretty" \ "stdio" "tui" "gtk" "vmlinux" "kallsyms" "modules" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "force" "symfs" "cpu" "disassembler-style" "source" "asm-raw" \ "show-total-period" "show-info" "branch-stack" "group" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "branch-history" "objdump" "demangle" "percent-limit" "percentage" \ "header" "itrace" "full-source-path" "show-ref-call-graph" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_no_patterns_found.pl" \ + "$DIR_PATH/../common/check_no_patterns_found.py" \ "No manual entry for" < $LOGS_DIR/basic_helpmsg.err (( CHECK_EXIT_CODE += $? )) @@ -76,11 +76,11 @@ REGEX_LOST_SAMPLES_INFO="#\s*Total Lost Samples:\s+$RE_NUMBER" REGEX_SAMPLES_INFO="#\s*Samples:\s+(?:$RE_NUMBER)\w?\s+of\s+event\s+'$RE_EVENT_ANY'" REGEX_LINES_HEADER="#\s*Children\s+Self\s+Command\s+Shared Object\s+Symbol" REGEX_LINES="\s*$RE_NUMBER%\s+$RE_NUMBER%\s+\S+\s+\[kernel\.(?:vmlinux)|(?:kallsyms)\]\s+\[[k\.]\]\s+\w+" -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_LOST_SAMPLES_INFO" "$REGEX_SAMPLES_INFO" \ "$REGEX_LINES_HEADER" "$REGEX_LINES" < $LOGS_DIR/basic_basic.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_basic.err (( CHECK_EXIT_CODE += $? )) @@ -96,10 +96,10 @@ PERF_EXIT_CODE=$? REGEX_LINES_HEADER="#\s*Children\s+Self\s+Samples\s+Command\s+Shared Object\s+Symbol" REGEX_LINES="\s*$RE_NUMBER%\s+$RE_NUMBER%\s+$RE_NUMBER\s+\S+\s+\[kernel\.(?:vmlinux)|(?:kallsyms)\]\s+\[[k\.]\]\s+\w+" -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_LINES_HEADER" "$REGEX_LINES" < $LOGS_DIR/basic_nrsamples.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_nrsamples.err (( CHECK_EXIT_CODE += $? )) @@ -122,7 +122,7 @@ REGEX_LINE_CPUS_ONLINE="#\s+nrcpus online\s*:\s*$MY_CPUS_ONLINE" REGEX_LINE_CPUS_AVAIL="#\s+nrcpus avail\s*:\s*$MY_CPUS_AVAILABLE" # disable precise check for "nrcpus avail" in BASIC runmode test $PERFTOOL_TESTSUITE_RUNMODE -lt $RUNMODE_STANDARD && REGEX_LINE_CPUS_AVAIL="#\s+nrcpus avail\s*:\s*$RE_NUMBER" -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_LINE_TIMESTAMP" "$REGEX_LINE_HOSTNAME" "$REGEX_LINE_KERNEL" \ "$REGEX_LINE_PERF" "$REGEX_LINE_ARCH" "$REGEX_LINE_CPUS_ONLINE" \ "$REGEX_LINE_CPUS_AVAIL" < $LOGS_DIR/basic_header.log @@ -156,10 +156,10 @@ PERF_EXIT_CODE=$? REGEX_LINES_HEADER="#\s*Children\s+Self\s+sys\s+usr\s+Command\s+Shared Object\s+Symbol" REGEX_LINES="\s*$RE_NUMBER%\s+$RE_NUMBER%\s+$RE_NUMBER%\s+$RE_NUMBER%\s+\S+\s+\[kernel\.(?:vmlinux)|(?:kallsyms)\]\s+\[[k\.]\]\s+\w+" -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_LINES_HEADER" "$REGEX_LINES" < $LOGS_DIR/basic_cpuut.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_cpuut.err (( CHECK_EXIT_CODE += $? )) @@ -174,9 +174,9 @@ $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data --pid=1 > $LOGS_DIR/basi PERF_EXIT_CODE=$? grep -P -v '^#' $LOGS_DIR/basic_pid.log | grep -P '\s+[\d\.]+%' | \ - "$DIR_PATH/../common/check_all_lines_matched.pl" "systemd|init" + "$DIR_PATH/../common/check_all_lines_matched.py" "systemd|init" CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_pid.err (( CHECK_EXIT_CODE += $? )) @@ -190,10 +190,10 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "pid" $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data --symbols=dummynonexistingsymbol > $LOGS_DIR/basic_symbols.log 2> $LOGS_DIR/basic_symbols.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$RE_LINE_EMPTY" "$RE_LINE_COMMENT" < $LOGS_DIR/basic_symbols.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_symbols.err (( CHECK_EXIT_CODE += $? )) @@ -208,9 +208,9 @@ $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data --symbol-filter=map > $L PERF_EXIT_CODE=$? grep -P -v '^#' $LOGS_DIR/basic_symbolfilter.log | grep -P '\s+[\d\.]+%' | \ - "$DIR_PATH/../common/check_all_lines_matched.pl" "\[[k\.]\]\s+.*map" + "$DIR_PATH/../common/check_all_lines_matched.py" "\[[k\.]\]\s+.*map" CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_symbolfilter.err (( CHECK_EXIT_CODE += $? )) @@ -224,7 +224,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "symbol filter" $CMD_PERF report -i $CURRENT_TEST_DIR/perf.data.1 --stdio --header-only > $LOGS_DIR/latency_header.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ ", context_switch = 1, " < $LOGS_DIR/latency_header.log CHECK_EXIT_CODE=$? @@ -236,10 +236,10 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "latency header" $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/latency_default.log 2> $LOGS_DIR/latency_default.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "# Overhead Latency Command" < $LOGS_DIR/latency_default.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "stderr-whitelist.txt" < $LOGS_DIR/latency_default.err (( CHECK_EXIT_CODE += $? )) @@ -251,10 +251,10 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "default report for latency profi $CMD_PERF report --latency --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/latency_latency.log 2> $LOGS_DIR/latency_latency.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "# Latency Overhead Command" < $LOGS_DIR/latency_latency.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "stderr-whitelist.txt" < $LOGS_DIR/latency_latency.err (( CHECK_EXIT_CODE += $? )) @@ -266,11 +266,11 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "latency report for latency profi $CMD_PERF report --hierarchy --sort latency,parallelism,comm,symbol --parallelism=1,2 --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/parallelism_hierarchy.log 2> $LOGS_DIR/parallelism_hierarchy.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "# Latency Parallelism / Command / Symbol" \ < $LOGS_DIR/parallelism_hierarchy.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "stderr-whitelist.txt" < $LOGS_DIR/parallelism_hierarchy.err (( CHECK_EXIT_CODE += $? )) diff --git a/tools/perf/tests/shell/common/check_all_lines_matched.pl b/tools/perf/tests/shell/common/check_all_lines_matched.pl deleted file mode 100755 index fded48959..000000000 --- a/tools/perf/tests/shell/common/check_all_lines_matched.pl +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl -# SPDX-License-Identifier: GPL-2.0 - -@regexps = @ARGV; - -$max_printed_lines = 20; -$max_printed_lines = $ENV{TESTLOG_ERR_MSG_MAX_LINES} if (defined $ENV{TESTLOG_ERR_MSG_MAX_LINES}); - -$quiet = 1; -$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2); - -$passed = 1; -$lines_printed = 0; - -while (<STDIN>) -{ - s/\n//; - - $line_matched = 0; - for $r (@regexps) - { - if (/$r/) - { - $line_matched = 1; - last; - } - } - - unless ($line_matched) - { - if ($lines_printed++ < $max_printed_lines) - { - print "Line did not match any pattern: \"$_\"\n" unless $quiet; - } - $passed = 0; - } -} - -exit ($passed == 0); diff --git a/tools/perf/tests/shell/common/check_all_lines_matched.py b/tools/perf/tests/shell/common/check_all_lines_matched.py new file mode 100755 index 000000000..2b08b9f86 --- /dev/null +++ b/tools/perf/tests/shell/common/check_all_lines_matched.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + max_printed = 20 + if "TESTLOG_ERR_MSG_MAX_LINES" in os.environ: + try: + max_printed = int(os.environ["TESTLOG_ERR_MSG_MAX_LINES"]) + except ValueError: + pass + + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + passed = True + lines_printed = 0 + + for line in sys.stdin: + line = line.rstrip("\n") + matched = False + for r in argv: + if re.search(r, line): + matched = True + break + if not matched: + show = lines_printed < max_printed + lines_printed += 1 + if show and not quiet: + print(f'Line did not match any pattern: "{line}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/tools/perf/tests/shell/common/check_all_patterns_found.pl b/tools/perf/tests/shell/common/check_all_patterns_found.pl deleted file mode 100755 index 11bdf1d34..000000000 --- a/tools/perf/tests/shell/common/check_all_patterns_found.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -# SPDX-License-Identifier: GPL-2.0 - -@regexps = @ARGV; - -$quiet = 1; -$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2); - -%found = (); -$passed = 1; - -while (<STDIN>) -{ - s/\n//; - - for $r (@regexps) - { - if (/$r/) - { - $found{$r} = 1; # FIXME: maybe add counters -- how many times was the regexp matched - } - } -} - -for $r (@regexps) -{ - unless (exists $found{$r}) - { - print "Regexp not found: \"$r\"\n" unless $quiet; - $passed = 0; - } -} - -exit ($passed == 0); diff --git a/tools/perf/tests/shell/common/check_all_patterns_found.py b/tools/perf/tests/shell/common/check_all_patterns_found.py new file mode 100755 index 000000000..f94487f25 --- /dev/null +++ b/tools/perf/tests/shell/common/check_all_patterns_found.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + found = set() + for line in sys.stdin: + line = line.rstrip("\n") + for r in argv: + if re.search(r, line): + found.add(r) + + passed = True + for r in argv: + if r not in found: + if not quiet: + print(f'Regexp not found: "{r}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/tools/perf/tests/shell/common/check_errors_whitelisted.pl b/tools/perf/tests/shell/common/check_errors_whitelisted.pl deleted file mode 100755 index c57d355dd..000000000 --- a/tools/perf/tests/shell/common/check_errors_whitelisted.pl +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl -# SPDX-License-Identifier: GPL-2.0 - -$whitelist_file = shift; - -if (defined $whitelist_file) -{ - open (INFILE, $whitelist_file) or die "Checker error: Unable to open the whitelist file: $whitelist_file\n"; - @regexps = <INFILE>; - close INFILE or die "Checker error: Unable to close the whitelist file: $whitelist_file\n"; -} -else -{ - @regexps = (); -} - -$max_printed_lines = 20; -$max_printed_lines = $ENV{TESTLOG_ERR_MSG_MAX_LINES} if (defined $ENV{TESTLOG_ERR_MSG_MAX_LINES}); - -$quiet = 1; -$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2); - -$passed = 1; -$lines_printed = 0; - -while (<STDIN>) -{ - s/\n//; - - $line_matched = 0; - for $r (@regexps) - { - chomp $r; - if (/$r/) - { - $line_matched = 1; - last; - } - } - - unless ($line_matched) - { - if ($lines_printed++ < $max_printed_lines) - { - print "Line did not match any pattern: \"$_\"\n" unless $quiet; - } - $passed = 0; - } -} - -exit ($passed == 0); diff --git a/tools/perf/tests/shell/common/check_errors_whitelisted.py b/tools/perf/tests/shell/common/check_errors_whitelisted.py new file mode 100755 index 000000000..86a6a729c --- /dev/null +++ b/tools/perf/tests/shell/common/check_errors_whitelisted.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + if argv: + whitelist = argv[0] + try: + with open(whitelist) as f: + regexps = [ln.rstrip("\n") for ln in f] + except OSError: + sys.exit(f"Checker error: Unable to open the whitelist file: {whitelist}") + else: + regexps = [] + + max_printed = 20 + if "TESTLOG_ERR_MSG_MAX_LINES" in os.environ: + try: + max_printed = int(os.environ["TESTLOG_ERR_MSG_MAX_LINES"]) + except ValueError: + pass + + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + passed = True + lines_printed = 0 + + for line in sys.stdin: + line = line.rstrip("\n") + matched = False + for r in regexps: + if re.search(r, line): + matched = True + break + if not matched: + show = lines_printed < max_printed + lines_printed += 1 + if show and not quiet: + print(f'Line did not match any pattern: "{line}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/tools/perf/tests/shell/common/check_no_patterns_found.pl b/tools/perf/tests/shell/common/check_no_patterns_found.pl deleted file mode 100755 index 770999e87..000000000 --- a/tools/perf/tests/shell/common/check_no_patterns_found.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -# SPDX-License-Identifier: GPL-2.0 - -@regexps = @ARGV; - -$quiet = 1; -$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2); - -%found = (); -$passed = 1; - -while (<STDIN>) -{ - s/\n//; - - for $r (@regexps) - { - if (/$r/) - { - $found{$r} = 1; - } - } -} - -for $r (@regexps) -{ - if (exists $found{$r}) - { - print "Regexp found: \"$r\"\n" unless $quiet; - $passed = 0; - } -} - -exit ($passed == 0); diff --git a/tools/perf/tests/shell/common/check_no_patterns_found.py b/tools/perf/tests/shell/common/check_no_patterns_found.py new file mode 100755 index 000000000..0df0a4961 --- /dev/null +++ b/tools/perf/tests/shell/common/check_no_patterns_found.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + found = set() + for line in sys.stdin: + line = line.rstrip("\n") + for r in argv: + if re.search(r, line): + found.add(r) + + passed = True + for r in argv: + if r in found: + if not quiet: + print(f'Regexp found: "{r}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH v2 2/2] perf/tests: convert check_*.pl helpers to Python 2026-10-18 13:30 ` [RFC PATCH v2 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves @ 2026-10-18 13:34 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:34 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users > Faithful re-implementations of the four Perl test helpers in > tools/perf/tests/shell/common/: > - check_all_patterns_found.pl > - check_no_patterns_found.pl > - check_all_lines_matched.pl > - check_errors_whitelisted.pl > > Same CLI, same output, same exit codes. All use only the Python > standard library. TESTLOG_VERBOSITY and TESTLOG_ERR_MSG_MAX_LINES > environment handling is preserved. > > Update all 37 call sites across base_probe/ and base_report/ to > invoke the .py versions. Update Makefile.perf's install-tests > target to install *.py files (in addition to *.sh) from > tests/shell/common/. Remove the four old .pl files. > > All four were verified byte-for-byte identical to their Perl > counterparts on synthetic inputs. > > Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> Sashiko has reviewed this patch and found no issues. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018133032.24467-1-breno3011alves@gmail.com?part=2 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH v3 0/2] perf: convert Perl test helpers to Python 2026-10-18 13:30 ` [RFC PATCH v2 0/2] perf: convert Perl test helpers " Breno Rodrigues Alves 2026-10-18 13:30 ` [RFC PATCH v2 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves 2026-10-18 13:30 ` [RFC PATCH v2 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves @ 2026-10-18 13:43 ` Breno Rodrigues Alves 2026-10-18 13:43 ` [RFC PATCH v3 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves 2026-10-18 13:43 ` [RFC PATCH v3 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves 2 siblings, 2 replies; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 13:43 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves v3 changes since v2: - Fix accidental deletion of the tap_timeout() function header and opening brace in runner.sh (Sashiko finding). The v2 runner.sh left the body of tap_timeout() at top level with an orphan closing brace, which would fail with a shell syntax error when sourced by run_kselftest.sh. v2 changes since v1: - Restructure as 2 commits (prefix.py alone; the 4 check_*.py together, since their callers are heavily intermingled) - Update runner.sh and kselftest/Makefile to invoke/install prefix.py - Update Makefile.perf to install *.py (not just *.sh/*.pl) - Update all call sites in base_probe/ and base_report/ - Remove the 5 original .pl files - Add trailing newlines to all 5 files (pylint C0304) - Fix the check_all_patterns_found commit message: TESTLOG_ERR_MSG_MAX_LINES is only handled by check_all_lines_matched This series converts five Perl test helpers in tools/ to Python 3, continuing the Perl-to-Python conversion effort for the kernel's auxiliary scripts. Each conversion is a faithful 1:1 port: same CLI, same output, same exit codes. All use only the Python standard library. The five scripts are: - prefix.pl -> prefix.py - check_all_patterns_found.pl -> check_all_patterns_found.py - check_no_patterns_found.pl -> check_no_patterns_found.py - check_all_lines_matched.pl -> check_all_lines_matched.py - check_errors_whitelisted.pl -> check_errors_whitelisted.py All five were verified byte-for-byte identical to their Perl counterparts on synthetic inputs. Breno Rodrigues Alves (2): perf/kselftest: convert prefix.pl to Python perf/tests: convert check_*.pl helpers to Python Breno Rodrigues Alves (2): perf/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 | 45 +++++++++++++++ .../shell/common/check_all_patterns_found.pl | 34 ------------ .../shell/common/check_all_patterns_found.py | 35 ++++++++++++ .../shell/common/check_errors_whitelisted.pl | 51 ----------------- .../shell/common/check_errors_whitelisted.py | 55 +++++++++++++++++++ .../shell/common/check_no_patterns_found.pl | 34 ------------ .../shell/common/check_no_patterns_found.py | 35 ++++++++++++ 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, 260 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.43.0 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH v3 1/2] perf/kselftest: convert prefix.pl to Python 2026-10-18 13:43 ` [RFC PATCH v3 0/2] perf: convert Perl test " Breno Rodrigues Alves @ 2026-10-18 13:43 ` Breno Rodrigues Alves 2026-10-18 13:46 ` sashiko-bot 2026-10-18 13:43 ` [RFC PATCH v3 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves 1 sibling, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 13:43 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementation of tools/testing/selftests/kselftest/ prefix.pl in Python 3 (stdlib only). Same unbuffered stdin-to-stdout processing, same "# " prefix behavior. Update runner.sh to invoke prefix.py instead of prefix.pl, update the install target to install prefix.py, and remove the old prefix.pl. Verified byte-for-byte identical to the Perl version. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- 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 ++-- 4 files changed, 27 insertions(+), 27 deletions(-) delete mode 100755 tools/testing/selftests/kselftest/prefix.pl create mode 100755 tools/testing/selftests/kselftest/prefix.py diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index bc4fdb6f5..85ed9af96 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -285,7 +285,7 @@ ifdef INSTALL_PATH mkdir -p $(INSTALL_PATH)/kselftest install -m 744 kselftest/module.sh $(INSTALL_PATH)/kselftest/ install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/ - install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/ + install -m 744 kselftest/prefix.py $(INSTALL_PATH)/kselftest/ install -m 744 kselftest/ktap_helpers.sh $(INSTALL_PATH)/kselftest/ install -m 744 kselftest/ksft.py $(INSTALL_PATH)/kselftest/ install -m 744 run_kselftest.sh $(INSTALL_PATH)/ diff --git a/tools/testing/selftests/kselftest/prefix.pl b/tools/testing/selftests/kselftest/prefix.pl deleted file mode 100755 index 12a7f4ca2..000000000 --- a/tools/testing/selftests/kselftest/prefix.pl +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env perl -# SPDX-License-Identifier: GPL-2.0 -# Prefix all lines with "# ", unbuffered. Command being piped in may need -# to have unbuffering forced with "stdbuf -i0 -o0 -e0 $cmd". -use strict; -use IO::Handle; - -binmode STDIN; -binmode STDOUT; - -STDOUT->autoflush(1); - -my $needed = 1; -while (1) { - my $char; - my $bytes = sysread(STDIN, $char, 1); - exit 0 if ($bytes == 0); - if ($needed) { - print "# "; - $needed = 0; - } - print $char; - $needed = 1 if ($char eq "\n"); -} diff --git a/tools/testing/selftests/kselftest/prefix.py b/tools/testing/selftests/kselftest/prefix.py new file mode 100755 index 000000000..67c4fd0b6 --- /dev/null +++ b/tools/testing/selftests/kselftest/prefix.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# Prefix all lines with "# ", unbuffered. + +import sys + + +def main(): + needed = True + while True: + char = sys.stdin.buffer.read(1) + if not char: + return 0 + if needed: + sys.stdout.buffer.write(b"# ") + needed = False + sys.stdout.buffer.write(char) + sys.stdout.buffer.flush() + if char == b"\n": + needed = True + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 311811dc5..1944c74f1 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -29,10 +29,10 @@ TR_CMD=$(command -v tr) # with sed instead of unbuffered output. tap_prefix() { - if [ ! -x /usr/bin/perl ]; then + if [ ! -x /usr/bin/python3 ]; then sed -e 's/^/# /' else - "$BASE_DIR"/kselftest/prefix.pl + "$BASE_DIR"/kselftest/prefix.py fi } -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH v3 1/2] perf/kselftest: convert prefix.pl to Python 2026-10-18 13:43 ` [RFC PATCH v3 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves @ 2026-10-18 13:46 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:46 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users > Faithful re-implementation of tools/testing/selftests/kselftest/ > prefix.pl in Python 3 (stdlib only). Same unbuffered stdin-to-stdout > processing, same "# " prefix behavior. > > Update runner.sh to invoke prefix.py instead of prefix.pl, update > the install target to install prefix.py, and remove the old > prefix.pl. > > Verified byte-for-byte identical to the Perl version. > > Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> Sashiko has reviewed this patch and found no issues. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018134322.26445-1-breno3011alves@gmail.com?part=1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH v3 2/2] perf/tests: convert check_*.pl helpers to Python 2026-10-18 13:43 ` [RFC PATCH v3 0/2] perf: convert Perl test " Breno Rodrigues Alves 2026-10-18 13:43 ` [RFC PATCH v3 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves @ 2026-10-18 13:43 ` Breno Rodrigues Alves 2026-10-18 13:45 ` sashiko-bot 1 sibling, 1 reply; 21+ messages in thread From: Breno Rodrigues Alves @ 2026-10-18 13:43 UTC (permalink / raw) To: linux-kernel, linux-perf-users, linux-kselftest Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Shuah Khan, Breno Rodrigues Alves Faithful re-implementations of the four Perl test helpers in tools/perf/tests/shell/common/: - check_all_patterns_found.pl - check_no_patterns_found.pl - check_all_lines_matched.pl - check_errors_whitelisted.pl Same CLI, same output, same exit codes. All use only the Python standard library. TESTLOG_VERBOSITY and TESTLOG_ERR_MSG_MAX_LINES environment handling is preserved. Update all 37 call sites across base_probe/ and base_report/ to invoke the .py versions. Update Makefile.perf's install-tests target to install *.py files (in addition to *.sh) from tests/shell/common/. Remove the four old .pl files. All four were verified byte-for-byte identical to their Perl counterparts on synthetic inputs. Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> --- 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 | 45 +++++++++++++++ .../shell/common/check_all_patterns_found.pl | 34 ------------ .../shell/common/check_all_patterns_found.py | 35 ++++++++++++ .../shell/common/check_errors_whitelisted.pl | 51 ----------------- .../shell/common/check_errors_whitelisted.py | 55 +++++++++++++++++++ .../shell/common/check_no_patterns_found.pl | 34 ------------ .../shell/common/check_no_patterns_found.py | 35 ++++++++++++ 15 files changed, 233 insertions(+), 221 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 diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 29cfd44c4..c9120eab6 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -885,7 +885,7 @@ install-tests: all install-gtk $(INSTALL) tests/shell/lib/*.py -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) tests/shell/common/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ - $(INSTALL) tests/shell/common/*.pl '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ + $(INSTALL) tests/shell/common/*.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_probe'; \ $(INSTALL) tests/shell/base_probe/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_probe'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_report'; \ diff --git a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh index f74aab5c5..867545a62 100755 --- a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh +++ b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh @@ -54,7 +54,7 @@ for BLACKFUNC in $BLACKFUNC_LIST; do PERF_EXIT_CODE=$? # check for bad DWARF polluting the result - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_MISSING_DECL_LINE" >/dev/null < $LOGS_DIR/adding_blacklisted.err if [ $? -eq 0 ]; then @@ -75,7 +75,7 @@ for BLACKFUNC in $BLACKFUNC_LIST; do fi fi else - "$DIR_PATH/../common/check_all_lines_matched.pl" \ + "$DIR_PATH/../common/check_all_lines_matched.py" \ "$REGEX_SKIP_MESSAGE" "$REGEX_NOT_FOUND_MESSAGE" \ "$REGEX_ERROR_MESSAGE" "$REGEX_SCOPE_FAIL" \ "$REGEX_INVALID_ARGUMENT" "$REGEX_SYMBOL_FAIL" \ @@ -100,7 +100,7 @@ fi $CMD_PERF list probe:\* > $LOGS_DIR/adding_blacklisted_list.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$RE_LINE_EMPTY" "List of pre-defined events" "Metric Groups:" \ < $LOGS_DIR/adding_blacklisted_list.log CHECK_EXIT_CODE=$? diff --git a/tools/perf/tests/shell/base_probe/test_adding_kernel.sh b/tools/perf/tests/shell/base_probe/test_adding_kernel.sh index 555a825d5..3e12e5c38 100755 --- a/tools/perf/tests/shell/base_probe/test_adding_kernel.sh +++ b/tools/perf/tests/shell/base_probe/test_adding_kernel.sh @@ -45,7 +45,7 @@ for opt in "" "-a" "--add"; do $CMD_PERF probe $opt $TEST_PROBE 2> $LOGS_DIR/adding_kernel_add$opt.err PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:$TEST_PROBE" "on $TEST_PROBE" \ < $LOGS_DIR/adding_kernel_add$opt.err CHECK_EXIT_CODE=$? @@ -61,7 +61,7 @@ done $CMD_PERF list probe:\* > $LOGS_DIR/adding_kernel_list.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$RE_LINE_EMPTY" "List of pre-defined events" \ "probe:${TEST_PROBE}(?:_\d+)?\s+\[Tracepoint event\]" \ "Metric Groups:" < $LOGS_DIR/adding_kernel_list.log @@ -77,7 +77,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "listing added probe :: perf list $CMD_PERF probe -l > $LOGS_DIR/adding_kernel_list-l.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "\s*probe:${TEST_PROBE}(?:_\d+)?\s+\(on ${TEST_PROBE}(?:[:\+]$RE_NUMBER_HEX)?@.+\)" \ < $LOGS_DIR/adding_kernel_list-l.log CHECK_EXIT_CODE=$? @@ -101,11 +101,11 @@ REGEX_STAT_VALUES="\s*\d+\s+probe:$TEST_PROBE" # the value should be greater than 1 REGEX_STAT_VALUE_NONZERO="\s*[1-9][0-9]*\s+probe:$TEST_PROBE" REGEX_STAT_TIME="\s*$RE_NUMBER\s+seconds (?:time elapsed|user|sys)" -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$REGEX_STAT_HEADER" "$REGEX_STAT_VALUES" "$REGEX_STAT_TIME" \ "$RE_LINE_COMMENT" "$RE_LINE_EMPTY" < $LOGS_DIR/adding_kernel_using_probe.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_STAT_HEADER" "$REGEX_STAT_VALUE_NONZERO" "$REGEX_STAT_TIME" \ < $LOGS_DIR/adding_kernel_using_probe.log (( CHECK_EXIT_CODE += $? )) @@ -120,7 +120,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "using added probe" $CMD_PERF probe -d $TEST_PROBE\* 2> $LOGS_DIR/adding_kernel_removing.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "Removed event: probe:$TEST_PROBE" < $LOGS_DIR/adding_kernel_removing.err CHECK_EXIT_CODE=$? @@ -134,7 +134,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "deleting added probe" $CMD_PERF list probe:\* > $LOGS_DIR/adding_kernel_list_removed.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$RE_LINE_EMPTY" "List of pre-defined events" "Metric Groups:" \ < $LOGS_DIR/adding_kernel_list_removed.log CHECK_EXIT_CODE=$? @@ -150,7 +150,7 @@ $CMD_PERF probe -n --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_dryrun.err PERF_EXIT_CODE=$? # check for the output (should be the same as usual) -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:$TEST_PROBE" "on $TEST_PROBE" \ < $LOGS_DIR/adding_kernel_dryrun.err CHECK_EXIT_CODE=$? @@ -169,7 +169,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "dry run :: adding probe" $CMD_PERF probe --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_forceadd_01.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:$TEST_PROBE" "on $TEST_PROBE" \ < $LOGS_DIR/adding_kernel_forceadd_01.err CHECK_EXIT_CODE=$? @@ -181,7 +181,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "force-adding probes :: first pro ! $CMD_PERF probe --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_forceadd_02.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Error: event \"$TEST_PROBE\" already exists." \ "Error: Failed to add events." < $LOGS_DIR/adding_kernel_forceadd_02.err CHECK_EXIT_CODE=$? @@ -194,7 +194,7 @@ NO_OF_PROBES=`$CMD_PERF probe -l $TEST_PROBE| wc -l` $CMD_PERF probe --force --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_forceadd_03.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:${TEST_PROBE}_${NO_OF_PROBES}" \ "on $TEST_PROBE" < $LOGS_DIR/adding_kernel_forceadd_03.err CHECK_EXIT_CODE=$? @@ -210,7 +210,7 @@ $CMD_PERF stat -e probe:$TEST_PROBE -e probe:${TEST_PROBE}_${NO_OF_PROBES} -x';' PERF_EXIT_CODE=$? REGEX_LINE="$RE_NUMBER;+probe:${TEST_PROBE}_?(?:$NO_OF_PROBES)?;$RE_NUMBER;$RE_NUMBER" -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$REGEX_LINE" "$RE_LINE_EMPTY" "$RE_LINE_COMMENT" \ < $LOGS_DIR/adding_kernel_using_two.log CHECK_EXIT_CODE=$? @@ -230,7 +230,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "using doubled probe" $CMD_PERF probe --del \* 2> $LOGS_DIR/adding_kernel_removing_wildcard.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "Removed event: probe:$TEST_PROBE" \ "Removed event: probe:${TEST_PROBE}_1" < $LOGS_DIR/adding_kernel_removing_wildcard.err CHECK_EXIT_CODE=$? @@ -244,7 +244,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "removing multiple probes" $CMD_PERF probe -nf --max-probes=512 -a 'vfs_* $params' 2> $LOGS_DIR/adding_kernel_adding_wildcard.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "probe:vfs_mknod" "probe:vfs_create" "probe:vfs_rmdir" \ "probe:vfs_link" "probe:vfs_write" < $LOGS_DIR/adding_kernel_adding_wildcard.err CHECK_EXIT_CODE=$? @@ -269,21 +269,21 @@ test $PERF_EXIT_CODE -ne 139 -a $PERF_EXIT_CODE -ne 0 PERF_EXIT_CODE=$? # check that the error message is reasonable -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Failed to find" \ "somenonexistingrandomstuffwhichisalsoprettylongorevenlongertoexceed64" \ < $LOGS_DIR/adding_kernel_nonexisting.err CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "in this function|at this address" "Error" "Failed to add events" \ < $LOGS_DIR/adding_kernel_nonexisting.err (( CHECK_EXIT_CODE += $? )) -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "Failed to find" "Error" "Probe point .+ not found" "optimized out" \ "Use.+\-\-range option to show.+location range" \ < $LOGS_DIR/adding_kernel_nonexisting.err (( CHECK_EXIT_CODE += $? )) -"$DIR_PATH/../common/check_no_patterns_found.pl" \ +"$DIR_PATH/../common/check_no_patterns_found.py" \ "$RE_SEGFAULT" < $LOGS_DIR/adding_kernel_nonexisting.err (( CHECK_EXIT_CODE += $? )) @@ -302,7 +302,7 @@ fi $CMD_PERF probe --add "$TEST_PROBE%return \$retval" 2> $LOGS_DIR/adding_kernel_func_retval_add.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "Added new events?:" "probe:$TEST_PROBE" \ "on $TEST_PROBE%return with \\\$retval" \ < $LOGS_DIR/adding_kernel_func_retval_add.err @@ -315,7 +315,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "function with retval :: add" $CMD_PERF record -e probe:$TEST_PROBE\* -o $CURRENT_TEST_DIR/perf.data -- cat /proc/cpuinfo > /dev/null 2> $LOGS_DIR/adding_kernel_func_retval_record.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" \ < $LOGS_DIR/adding_kernel_func_retval_record.err CHECK_EXIT_CODE=$? @@ -328,10 +328,10 @@ $CMD_PERF script -i $CURRENT_TEST_DIR/perf.data > $LOGS_DIR/adding_kernel_func_r PERF_EXIT_CODE=$? REGEX_SCRIPT_LINE="\s*cat\s+$RE_NUMBER\s+\[$RE_NUMBER\]\s+$RE_NUMBER:\s+probe:$TEST_PROBE\w*:\s+\($RE_NUMBER_HEX\s+<\-\s+$RE_NUMBER_HEX\)\s+arg1=$RE_NUMBER_HEX" -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$REGEX_SCRIPT_LINE" < $LOGS_DIR/adding_kernel_func_retval_script.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_SCRIPT_LINE" < $LOGS_DIR/adding_kernel_func_retval_script.log (( CHECK_EXIT_CODE += $? )) diff --git a/tools/perf/tests/shell/base_probe/test_basic.sh b/tools/perf/tests/shell/base_probe/test_basic.sh index 162838ddc..a702be734 100755 --- a/tools/perf/tests/shell/base_probe/test_basic.sh +++ b/tools/perf/tests/shell/base_probe/test_basic.sh @@ -31,24 +31,24 @@ if [ "$PARAM_GENERAL_HELP_TEXT_CHECK" = "y" ]; then $CMD_PERF probe --help > $LOGS_DIR/basic_helpmsg.log 2> $LOGS_DIR/basic_helpmsg.err PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "PERF-PROBE" "NAME" "SYNOPSIS" "DESCRIPTION" "OPTIONS" \ "PROBE\s+SYNTAX" "PROBE\s+ARGUMENT" "LINE\s+SYNTAX" \ < $LOGS_DIR/basic_helpmsg.log CHECK_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "LAZY\s+MATCHING" "FILTER\s+PATTERN" "EXAMPLES" "SEE\s+ALSO" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "vmlinux" "module=" "source=" "verbose" "quiet" "add=" "del=" \ "list.*EVENT" "line=" "vars=" "externs" < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "no-inlines" "funcs.*FILTER" "filter=FILTER" "force" "dry-run" \ "max-probes" "exec=" "demangle-kernel" < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_no_patterns_found.pl" \ + "$DIR_PATH/../common/check_no_patterns_found.py" \ "No manual entry for" < $LOGS_DIR/basic_helpmsg.err (( CHECK_EXIT_CODE += $? )) @@ -64,7 +64,7 @@ fi # without any args perf-probe should print usage $CMD_PERF probe 2> $LOGS_DIR/basic_usage.log > /dev/null -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "[Uu]sage" "perf probe" "verbose" "quiet" "add" "del" "force" \ "line" "vars" "externs" "range" < $LOGS_DIR/basic_usage.log CHECK_EXIT_CODE=$? diff --git a/tools/perf/tests/shell/base_probe/test_invalid_options.sh b/tools/perf/tests/shell/base_probe/test_invalid_options.sh index 44a3ae014..d88bb7ec5 100755 --- a/tools/perf/tests/shell/base_probe/test_invalid_options.sh +++ b/tools/perf/tests/shell/base_probe/test_invalid_options.sh @@ -34,7 +34,7 @@ for opt in '-a' '-d' '-L' '-V'; do ! $CMD_PERF probe $opt 2> $LOGS_DIR/invalid_options_missing_argument$opt.err PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "Error: switch .* requires a value" \ < $LOGS_DIR/invalid_options_missing_argument$opt.err CHECK_EXIT_CODE=$? @@ -69,7 +69,7 @@ for opt in '-a xxx -d xxx' '-a xxx -L foo' '-a xxx -V foo' '-a xxx -l' '-a xxx - ! $CMD_PERF probe $opt > /dev/null 2> $LOGS_DIR/aux.log PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "Error: switch .+ cannot be used with switch .+" < $LOGS_DIR/aux.log CHECK_EXIT_CODE=$? diff --git a/tools/perf/tests/shell/base_report/setup.sh b/tools/perf/tests/shell/base_report/setup.sh index bb49b0fab..10fe4b553 100755 --- a/tools/perf/tests/shell/base_report/setup.sh +++ b/tools/perf/tests/shell/base_report/setup.sh @@ -26,7 +26,7 @@ SW_EVENT="cpu-clock" $CMD_PERF record -asdg -e $SW_EVENT -o $CURRENT_TEST_DIR/perf.data -- $CMD_LONGER_SLEEP 2> $LOGS_DIR/setup.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" < $LOGS_DIR/setup.log CHECK_EXIT_CODE=$? @@ -41,7 +41,7 @@ echo ================== cat $LOGS_DIR/setup-latency.log echo ================== -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" < $LOGS_DIR/setup-latency.log CHECK_EXIT_CODE=$? diff --git a/tools/perf/tests/shell/base_report/test_basic.sh b/tools/perf/tests/shell/base_report/test_basic.sh index 0dfe7e5fd..9bfec0068 100755 --- a/tools/perf/tests/shell/base_report/test_basic.sh +++ b/tools/perf/tests/shell/base_report/test_basic.sh @@ -26,36 +26,36 @@ if [ "$PARAM_GENERAL_HELP_TEXT_CHECK" = "y" ]; then $CMD_PERF report --help > $LOGS_DIR/basic_helpmsg.log 2> $LOGS_DIR/basic_helpmsg.err PERF_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "PERF-REPORT" "NAME" "SYNOPSIS" "DESCRIPTION" "OPTIONS" \ "OVERHEAD\s+CALCULATION" "SEE ALSO" < $LOGS_DIR/basic_helpmsg.log CHECK_EXIT_CODE=$? - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "input" "verbose" "show-nr-samples" "show-cpu-utilization" \ "threads" "comms" "pid" "tid" "dsos" "symbols" "symbol-filter" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "hide-unresolved" "sort" "fields" "parent" "exclude-other" \ "column-widths" "field-separator" "dump-raw-trace" "children" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "call-graph" "max-stack" "inverted" "ignore-callees" "pretty" \ "stdio" "tui" "gtk" "vmlinux" "kallsyms" "modules" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "force" "symfs" "cpu" "disassembler-style" "source" "asm-raw" \ "show-total-period" "show-info" "branch-stack" "group" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_all_patterns_found.pl" \ + "$DIR_PATH/../common/check_all_patterns_found.py" \ "branch-history" "objdump" "demangle" "percent-limit" "percentage" \ "header" "itrace" "full-source-path" "show-ref-call-graph" \ < $LOGS_DIR/basic_helpmsg.log (( CHECK_EXIT_CODE += $? )) - "$DIR_PATH/../common/check_no_patterns_found.pl" \ + "$DIR_PATH/../common/check_no_patterns_found.py" \ "No manual entry for" < $LOGS_DIR/basic_helpmsg.err (( CHECK_EXIT_CODE += $? )) @@ -76,11 +76,11 @@ REGEX_LOST_SAMPLES_INFO="#\s*Total Lost Samples:\s+$RE_NUMBER" REGEX_SAMPLES_INFO="#\s*Samples:\s+(?:$RE_NUMBER)\w?\s+of\s+event\s+'$RE_EVENT_ANY'" REGEX_LINES_HEADER="#\s*Children\s+Self\s+Command\s+Shared Object\s+Symbol" REGEX_LINES="\s*$RE_NUMBER%\s+$RE_NUMBER%\s+\S+\s+\[kernel\.(?:vmlinux)|(?:kallsyms)\]\s+\[[k\.]\]\s+\w+" -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_LOST_SAMPLES_INFO" "$REGEX_SAMPLES_INFO" \ "$REGEX_LINES_HEADER" "$REGEX_LINES" < $LOGS_DIR/basic_basic.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_basic.err (( CHECK_EXIT_CODE += $? )) @@ -96,10 +96,10 @@ PERF_EXIT_CODE=$? REGEX_LINES_HEADER="#\s*Children\s+Self\s+Samples\s+Command\s+Shared Object\s+Symbol" REGEX_LINES="\s*$RE_NUMBER%\s+$RE_NUMBER%\s+$RE_NUMBER\s+\S+\s+\[kernel\.(?:vmlinux)|(?:kallsyms)\]\s+\[[k\.]\]\s+\w+" -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_LINES_HEADER" "$REGEX_LINES" < $LOGS_DIR/basic_nrsamples.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_nrsamples.err (( CHECK_EXIT_CODE += $? )) @@ -122,7 +122,7 @@ REGEX_LINE_CPUS_ONLINE="#\s+nrcpus online\s*:\s*$MY_CPUS_ONLINE" REGEX_LINE_CPUS_AVAIL="#\s+nrcpus avail\s*:\s*$MY_CPUS_AVAILABLE" # disable precise check for "nrcpus avail" in BASIC runmode test $PERFTOOL_TESTSUITE_RUNMODE -lt $RUNMODE_STANDARD && REGEX_LINE_CPUS_AVAIL="#\s+nrcpus avail\s*:\s*$RE_NUMBER" -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_LINE_TIMESTAMP" "$REGEX_LINE_HOSTNAME" "$REGEX_LINE_KERNEL" \ "$REGEX_LINE_PERF" "$REGEX_LINE_ARCH" "$REGEX_LINE_CPUS_ONLINE" \ "$REGEX_LINE_CPUS_AVAIL" < $LOGS_DIR/basic_header.log @@ -156,10 +156,10 @@ PERF_EXIT_CODE=$? REGEX_LINES_HEADER="#\s*Children\s+Self\s+sys\s+usr\s+Command\s+Shared Object\s+Symbol" REGEX_LINES="\s*$RE_NUMBER%\s+$RE_NUMBER%\s+$RE_NUMBER%\s+$RE_NUMBER%\s+\S+\s+\[kernel\.(?:vmlinux)|(?:kallsyms)\]\s+\[[k\.]\]\s+\w+" -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "$REGEX_LINES_HEADER" "$REGEX_LINES" < $LOGS_DIR/basic_cpuut.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_cpuut.err (( CHECK_EXIT_CODE += $? )) @@ -174,9 +174,9 @@ $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data --pid=1 > $LOGS_DIR/basi PERF_EXIT_CODE=$? grep -P -v '^#' $LOGS_DIR/basic_pid.log | grep -P '\s+[\d\.]+%' | \ - "$DIR_PATH/../common/check_all_lines_matched.pl" "systemd|init" + "$DIR_PATH/../common/check_all_lines_matched.py" "systemd|init" CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_pid.err (( CHECK_EXIT_CODE += $? )) @@ -190,10 +190,10 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "pid" $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data --symbols=dummynonexistingsymbol > $LOGS_DIR/basic_symbols.log 2> $LOGS_DIR/basic_symbols.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_lines_matched.pl" \ +"$DIR_PATH/../common/check_all_lines_matched.py" \ "$RE_LINE_EMPTY" "$RE_LINE_COMMENT" < $LOGS_DIR/basic_symbols.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_symbols.err (( CHECK_EXIT_CODE += $? )) @@ -208,9 +208,9 @@ $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data --symbol-filter=map > $L PERF_EXIT_CODE=$? grep -P -v '^#' $LOGS_DIR/basic_symbolfilter.log | grep -P '\s+[\d\.]+%' | \ - "$DIR_PATH/../common/check_all_lines_matched.pl" "\[[k\.]\]\s+.*map" + "$DIR_PATH/../common/check_all_lines_matched.py" "\[[k\.]\]\s+.*map" CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/basic_symbolfilter.err (( CHECK_EXIT_CODE += $? )) @@ -224,7 +224,7 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "symbol filter" $CMD_PERF report -i $CURRENT_TEST_DIR/perf.data.1 --stdio --header-only > $LOGS_DIR/latency_header.log PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ ", context_switch = 1, " < $LOGS_DIR/latency_header.log CHECK_EXIT_CODE=$? @@ -236,10 +236,10 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "latency header" $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/latency_default.log 2> $LOGS_DIR/latency_default.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "# Overhead Latency Command" < $LOGS_DIR/latency_default.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "stderr-whitelist.txt" < $LOGS_DIR/latency_default.err (( CHECK_EXIT_CODE += $? )) @@ -251,10 +251,10 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "default report for latency profi $CMD_PERF report --latency --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/latency_latency.log 2> $LOGS_DIR/latency_latency.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "# Latency Overhead Command" < $LOGS_DIR/latency_latency.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "stderr-whitelist.txt" < $LOGS_DIR/latency_latency.err (( CHECK_EXIT_CODE += $? )) @@ -266,11 +266,11 @@ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "latency report for latency profi $CMD_PERF report --hierarchy --sort latency,parallelism,comm,symbol --parallelism=1,2 --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/parallelism_hierarchy.log 2> $LOGS_DIR/parallelism_hierarchy.err PERF_EXIT_CODE=$? -"$DIR_PATH/../common/check_all_patterns_found.pl" \ +"$DIR_PATH/../common/check_all_patterns_found.py" \ "# Latency Parallelism / Command / Symbol" \ < $LOGS_DIR/parallelism_hierarchy.log CHECK_EXIT_CODE=$? -"$DIR_PATH/../common/check_errors_whitelisted.pl" \ +"$DIR_PATH/../common/check_errors_whitelisted.py" \ "stderr-whitelist.txt" < $LOGS_DIR/parallelism_hierarchy.err (( CHECK_EXIT_CODE += $? )) diff --git a/tools/perf/tests/shell/common/check_all_lines_matched.pl b/tools/perf/tests/shell/common/check_all_lines_matched.pl deleted file mode 100755 index fded48959..000000000 --- a/tools/perf/tests/shell/common/check_all_lines_matched.pl +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl -# SPDX-License-Identifier: GPL-2.0 - -@regexps = @ARGV; - -$max_printed_lines = 20; -$max_printed_lines = $ENV{TESTLOG_ERR_MSG_MAX_LINES} if (defined $ENV{TESTLOG_ERR_MSG_MAX_LINES}); - -$quiet = 1; -$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2); - -$passed = 1; -$lines_printed = 0; - -while (<STDIN>) -{ - s/\n//; - - $line_matched = 0; - for $r (@regexps) - { - if (/$r/) - { - $line_matched = 1; - last; - } - } - - unless ($line_matched) - { - if ($lines_printed++ < $max_printed_lines) - { - print "Line did not match any pattern: \"$_\"\n" unless $quiet; - } - $passed = 0; - } -} - -exit ($passed == 0); diff --git a/tools/perf/tests/shell/common/check_all_lines_matched.py b/tools/perf/tests/shell/common/check_all_lines_matched.py new file mode 100755 index 000000000..2b08b9f86 --- /dev/null +++ b/tools/perf/tests/shell/common/check_all_lines_matched.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + max_printed = 20 + if "TESTLOG_ERR_MSG_MAX_LINES" in os.environ: + try: + max_printed = int(os.environ["TESTLOG_ERR_MSG_MAX_LINES"]) + except ValueError: + pass + + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + passed = True + lines_printed = 0 + + for line in sys.stdin: + line = line.rstrip("\n") + matched = False + for r in argv: + if re.search(r, line): + matched = True + break + if not matched: + show = lines_printed < max_printed + lines_printed += 1 + if show and not quiet: + print(f'Line did not match any pattern: "{line}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/tools/perf/tests/shell/common/check_all_patterns_found.pl b/tools/perf/tests/shell/common/check_all_patterns_found.pl deleted file mode 100755 index 11bdf1d34..000000000 --- a/tools/perf/tests/shell/common/check_all_patterns_found.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -# SPDX-License-Identifier: GPL-2.0 - -@regexps = @ARGV; - -$quiet = 1; -$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2); - -%found = (); -$passed = 1; - -while (<STDIN>) -{ - s/\n//; - - for $r (@regexps) - { - if (/$r/) - { - $found{$r} = 1; # FIXME: maybe add counters -- how many times was the regexp matched - } - } -} - -for $r (@regexps) -{ - unless (exists $found{$r}) - { - print "Regexp not found: \"$r\"\n" unless $quiet; - $passed = 0; - } -} - -exit ($passed == 0); diff --git a/tools/perf/tests/shell/common/check_all_patterns_found.py b/tools/perf/tests/shell/common/check_all_patterns_found.py new file mode 100755 index 000000000..f94487f25 --- /dev/null +++ b/tools/perf/tests/shell/common/check_all_patterns_found.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + found = set() + for line in sys.stdin: + line = line.rstrip("\n") + for r in argv: + if re.search(r, line): + found.add(r) + + passed = True + for r in argv: + if r not in found: + if not quiet: + print(f'Regexp not found: "{r}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/tools/perf/tests/shell/common/check_errors_whitelisted.pl b/tools/perf/tests/shell/common/check_errors_whitelisted.pl deleted file mode 100755 index c57d355dd..000000000 --- a/tools/perf/tests/shell/common/check_errors_whitelisted.pl +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl -# SPDX-License-Identifier: GPL-2.0 - -$whitelist_file = shift; - -if (defined $whitelist_file) -{ - open (INFILE, $whitelist_file) or die "Checker error: Unable to open the whitelist file: $whitelist_file\n"; - @regexps = <INFILE>; - close INFILE or die "Checker error: Unable to close the whitelist file: $whitelist_file\n"; -} -else -{ - @regexps = (); -} - -$max_printed_lines = 20; -$max_printed_lines = $ENV{TESTLOG_ERR_MSG_MAX_LINES} if (defined $ENV{TESTLOG_ERR_MSG_MAX_LINES}); - -$quiet = 1; -$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2); - -$passed = 1; -$lines_printed = 0; - -while (<STDIN>) -{ - s/\n//; - - $line_matched = 0; - for $r (@regexps) - { - chomp $r; - if (/$r/) - { - $line_matched = 1; - last; - } - } - - unless ($line_matched) - { - if ($lines_printed++ < $max_printed_lines) - { - print "Line did not match any pattern: \"$_\"\n" unless $quiet; - } - $passed = 0; - } -} - -exit ($passed == 0); diff --git a/tools/perf/tests/shell/common/check_errors_whitelisted.py b/tools/perf/tests/shell/common/check_errors_whitelisted.py new file mode 100755 index 000000000..86a6a729c --- /dev/null +++ b/tools/perf/tests/shell/common/check_errors_whitelisted.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + if argv: + whitelist = argv[0] + try: + with open(whitelist) as f: + regexps = [ln.rstrip("\n") for ln in f] + except OSError: + sys.exit(f"Checker error: Unable to open the whitelist file: {whitelist}") + else: + regexps = [] + + max_printed = 20 + if "TESTLOG_ERR_MSG_MAX_LINES" in os.environ: + try: + max_printed = int(os.environ["TESTLOG_ERR_MSG_MAX_LINES"]) + except ValueError: + pass + + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + passed = True + lines_printed = 0 + + for line in sys.stdin: + line = line.rstrip("\n") + matched = False + for r in regexps: + if re.search(r, line): + matched = True + break + if not matched: + show = lines_printed < max_printed + lines_printed += 1 + if show and not quiet: + print(f'Line did not match any pattern: "{line}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/tools/perf/tests/shell/common/check_no_patterns_found.pl b/tools/perf/tests/shell/common/check_no_patterns_found.pl deleted file mode 100755 index 770999e87..000000000 --- a/tools/perf/tests/shell/common/check_no_patterns_found.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -# SPDX-License-Identifier: GPL-2.0 - -@regexps = @ARGV; - -$quiet = 1; -$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2); - -%found = (); -$passed = 1; - -while (<STDIN>) -{ - s/\n//; - - for $r (@regexps) - { - if (/$r/) - { - $found{$r} = 1; - } - } -} - -for $r (@regexps) -{ - if (exists $found{$r}) - { - print "Regexp found: \"$r\"\n" unless $quiet; - $passed = 0; - } -} - -exit ($passed == 0); diff --git a/tools/perf/tests/shell/common/check_no_patterns_found.py b/tools/perf/tests/shell/common/check_no_patterns_found.py new file mode 100755 index 000000000..0df0a4961 --- /dev/null +++ b/tools/perf/tests/shell/common/check_no_patterns_found.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import os +import re +import sys + + +def main(argv): + quiet = True + try: + if int(os.environ.get("TESTLOG_VERBOSITY", "0")) >= 2: + quiet = False + except ValueError: + pass + + found = set() + for line in sys.stdin: + line = line.rstrip("\n") + for r in argv: + if re.search(r, line): + found.add(r) + + passed = True + for r in argv: + if r in found: + if not quiet: + print(f'Regexp found: "{r}"') + passed = False + + return 0 if passed else 1 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [RFC PATCH v3 2/2] perf/tests: convert check_*.pl helpers to Python 2026-10-18 13:43 ` [RFC PATCH v3 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves @ 2026-10-18 13:45 ` sashiko-bot 0 siblings, 0 replies; 21+ messages in thread From: sashiko-bot @ 2026-10-18 13:45 UTC (permalink / raw) To: Breno Rodrigues Alves, linux-perf-users > Faithful re-implementations of the four Perl test helpers in > tools/perf/tests/shell/common/: > - check_all_patterns_found.pl > - check_no_patterns_found.pl > - check_all_lines_matched.pl > - check_errors_whitelisted.pl > > Same CLI, same output, same exit codes. All use only the Python > standard library. TESTLOG_VERBOSITY and TESTLOG_ERR_MSG_MAX_LINES > environment handling is preserved. > > Update all 37 call sites across base_probe/ and base_report/ to > invoke the .py versions. Update Makefile.perf's install-tests > target to install *.py files (in addition to *.sh) from > tests/shell/common/. Remove the four old .pl files. > > All four were verified byte-for-byte identical to their Perl > counterparts on synthetic inputs. > > Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com> Sashiko has reviewed this patch and found no issues. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261018134322.26445-1-breno3011alves@gmail.com?part=2 ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2026-10-18 13:46 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-18 12:56 [RFC PATCH 0/5] perf/tests: convert Perl test helpers to Python Breno Rodrigues Alves 2026-10-18 12:56 ` [RFC PATCH 1/5] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves 2026-10-18 13:01 ` sashiko-bot 2026-10-18 12:56 ` [RFC PATCH 2/5] perf/tests: convert check_all_patterns_found.pl " Breno Rodrigues Alves 2026-10-18 13:02 ` sashiko-bot 2026-10-18 12:56 ` [RFC PATCH 3/5] perf/tests: convert check_no_patterns_found.pl " Breno Rodrigues Alves 2026-10-18 13:03 ` sashiko-bot 2026-10-18 12:56 ` [RFC PATCH 4/5] perf/tests: convert check_all_lines_matched.pl " Breno Rodrigues Alves 2026-10-18 13:07 ` sashiko-bot 2026-10-18 12:56 ` [RFC PATCH 5/5] perf/tests: convert check_errors_whitelisted.pl " Breno Rodrigues Alves 2026-10-18 13:02 ` sashiko-bot 2026-10-18 13:30 ` [RFC PATCH v2 0/2] perf: convert Perl test helpers " Breno Rodrigues Alves 2026-10-18 13:30 ` [RFC PATCH v2 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves 2026-10-18 13:35 ` sashiko-bot 2026-10-18 13:30 ` [RFC PATCH v2 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves 2026-10-18 13:34 ` sashiko-bot 2026-10-18 13:43 ` [RFC PATCH v3 0/2] perf: convert Perl test " Breno Rodrigues Alves 2026-10-18 13:43 ` [RFC PATCH v3 1/2] perf/kselftest: convert prefix.pl " Breno Rodrigues Alves 2026-10-18 13:46 ` sashiko-bot 2026-10-18 13:43 ` [RFC PATCH v3 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves 2026-10-18 13:45 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox