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/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}")