[RFC PATCH 4/5] perf/tests: convert check_all_lines_matched.pl to Python
From: Breno Rodrigues Alves
Date: Sun Oct 18 2026 - 08:58:05 EST
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@xxxxxxxxx>
---
.../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