From: Breno Rodrigues Alves <breno3011alves@gmail.com>
To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
linux-kselftest@vger.kernel.org
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>, Shuah Khan <shuah@kernel.org>,
Breno Rodrigues Alves <breno3011alves@gmail.com>
Subject: [RFC PATCH 5/5] perf/tests: convert check_errors_whitelisted.pl to Python
Date: Sun, 18 Oct 2026 09:56:41 -0300 [thread overview]
Message-ID: <20261018125641.23064-6-breno3011alves@gmail.com> (raw)
In-Reply-To: <20261018125641.23064-1-breno3011alves@gmail.com>
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
next prev parent reply other threads:[~2026-10-18 12:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 12:56 [RFC PATCH 0/5] perf/tests: convert Perl test helpers " 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 ` [RFC PATCH 3/5] perf/tests: convert check_no_patterns_found.pl " Breno Rodrigues Alves
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 [this message]
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 ` [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 ` [RFC PATCH v3 2/2] perf/tests: convert check_*.pl helpers " Breno Rodrigues Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261018125641.23064-6-breno3011alves@gmail.com \
--to=breno3011alves@gmail.com \
--cc=acme@kernel.org \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®