automated: kselftest: update parser
Update to use python to parser the result.
Since there are a lot of subtests in kselftest that produce the same
output like 'clone3 438_result_22_matches_expectation_22' thats why the
subtest number are included into the test name.
The subsuite tests in 'kunit' are uniq, thats why we don't need to
include the subtest number.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
diff --git a/automated/linux/kselftest/kselftest.sh b/automated/linux/kselftest/kselftest.sh
index 0f14d2e..6094155 100755
--- a/automated/linux/kselftest/kselftest.sh
+++ b/automated/linux/kselftest/kselftest.sh
@@ -128,34 +128,7 @@
parse_output() {
- perl -ne '
- if (m|^# selftests: (.*)$|) {
- $testdir = $1;
- $testdir =~ s|[:/]\s*|.|g;
- } elsif (m|^(?:# )*(not )?ok (?:\d+) ([^#]+)(# (SKIP)?)?|) {
- $not = $1;
- $test = $2;
- $skip = $4;
- $test =~ s|\s+$||;
- # If the test name starts with "selftests: " it is "fully qualified".
- if ($test =~ /selftests: (.*)/) {
- $test = $1;
- $test =~ s|[:/]\s*|.|g;
- } else {
- # Otherwise, it likely needs the testdir prepended.
- $test = "$testdir.$test";
- }
- # Any appearance of the SKIP is a skip.
- if ($skip eq "SKIP") {
- $result="skip";
- } elsif ($not eq "not ") {
- $result="fail";
- } else {
- $result="pass";
- }
- print "$test $result\n";
- }
-' "${LOGFILE}" >> "${RESULT_FILE}"
+ ./parse-output.py < "${LOGFILE}" | tee -a "${RESULT_FILE}"
}
install() {
diff --git a/automated/linux/kselftest/parse-output.py b/automated/linux/kselftest/parse-output.py
new file mode 100755
index 0000000..9c0a5c4
--- /dev/null
+++ b/automated/linux/kselftest/parse-output.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+import sys
+import re
+
+
+def slugify(line):
+ non_ascii_pattern = r"[^A-Za-z0-9_-]+"
+ line = re.sub(r"\[\d{1,5}\]", "", line)
+ return re.sub(
+ r"_-", "_", re.sub(r"(^_|_$)", "", re.sub(non_ascii_pattern, "_", line))
+ )
+
+
+tests = ""
+for line in sys.stdin:
+ if "# selftests: " in line:
+ tests = slugify(line.replace("\n", "").split("selftests:")[1])
+ elif re.search(r"^.*?not ok \d{1,5} ", line):
+ match = re.match(r"^.*?not ok (.*?)$", line)
+ ascii_test_line = slugify(re.sub("# .*$", "", match.group(1)))
+ if f"selftests_{tests}" in output:
+ output = re.sub(r"^.*_selftests_", "", output)
+ print(f"{output}")
+ elif re.search(r"^.*?ok \d{1,5} ", line):
+ match = re.match(r"^.*?ok (.*?)$", line)
+ if "# SKIP" in match.group(1):
+ ascii_test_line = slugify(re.sub("# SKIP", "", match.group(1)))
+ output = f"{tests}_{ascii_test_line} skip"
+ else:
+ ascii_test_line = slugify(match.group(1))
+ output = f"{tests}_{ascii_test_line} pass"
+ if f"selftests_{tests}" in output:
+ output = re.sub(r"^.*_selftests_", "", output)
+ print(f"{output}")