jjb: binutils-gdb: catch ERRORs in gdb.sum
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 25 Apr 2023 18:28:47 +0000 (14:28 -0400)
committerMichael Jeanson <mjeanson@efficios.com>
Tue, 25 Apr 2023 20:12:03 +0000 (16:12 -0400)
When tests encounter a fatal error, it is reported as:

    ERROR: blah blah blah

Unlike normal test result lines, they don't include the name of the .exp
file currently running.  It would still be nice to catch them and
consider them failures, as they are abnormal.  Update the Python gdb.sum
processing script to remember the name of the current .exp, by looking
at the "Running" lines.  And when it encounters an ERROR, generate a
junit failure.

Change-Id: If99d73992241370afe9a9b59cb9abe491272d05f

scripts/binutils-gdb/build.sh

index 55475308ee664bca5a41695e3342f581ed2f6738..43ea6e99e9aa6aa95389263870c00be110d520c2 100755 (executable)
@@ -38,6 +38,8 @@ from xml.etree.ElementTree import ElementTree, Element, SubElement
 line_re = re.compile(
     r"^(PASS|XPASS|FAIL|XFAIL|KFAIL|DUPLICATE|UNTESTED|UNSUPPORTED|UNRESOLVED): (.*?\.exp): (.*)"
 )
+running_re = re.compile(r"^Running .*/(gdb\.[^/]+/.*\.exp)")
+error_re = re.compile(r"^ERROR: (.*)")
 
 pass_count = 0
 fail_count = 0
@@ -65,7 +67,29 @@ testsuite = SubElement(
 )
 SubElement(testsuite, "properties")
 
+cur_test = None
+
 for line in sys.stdin:
+    m = running_re.match(line)
+    if m:
+        cur_test = m.group(1)
+        continue
+
+    m = error_re.match(line)
+    if m:
+        test = cur_test if cur_test else "<unknown test>"
+        msg = m.group(1)
+        print("ERROR: {} - {}".format(test, msg), file=sys.stderr)
+        error_count += 1
+
+        testcase_name = test
+        testcase = SubElement(
+            testsuite,
+            "testcase",
+            {"name": testcase_name, "classname": "classname", "time": "0"},
+        )
+        SubElement(testcase, "error", {"type": "ERROR"})
+
     m = line_re.match(line)
     if not m:
         continue
@@ -96,7 +120,7 @@ for line in sys.stdin:
     else:
         assert False
 
-testsuite.attrib["tests"] = str(pass_count + fail_count + skip_count)
+testsuite.attrib["tests"] = str(pass_count + fail_count + skip_count + error_count)
 testsuite.attrib["failures"] = str(fail_count)
 testsuite.attrib["skipped"] = str(skip_count)
 testsuite.attrib["errors"] = str(error_count)
@@ -872,7 +896,7 @@ known_failures_file="known-failures-${target_board}"
 known_failures_re_file="known-failures-re-${target_board}"
 grep --invert-match --fixed-strings --file="$known_failures_file" "${WORKSPACE}/results/gdb.sum" | \
     grep --invert-match --extended-regexp --file="$known_failures_re_file" > "${WORKSPACE}/results/gdb.filtered.sum"
-grep --extended-regexp --regexp="^(FAIL|XPASS|UNRESOLVED|DUPLICATE):" "${WORKSPACE}/results/gdb.filtered.sum" > "${WORKSPACE}/results/gdb.fail.sum" || true
+grep --extended-regexp --regexp="^(FAIL|XPASS|UNRESOLVED|DUPLICATE|ERROR):" "${WORKSPACE}/results/gdb.filtered.sum" > "${WORKSPACE}/results/gdb.fail.sum" || true
 
 # For informational purposes: check if some known failure lines did not appear
 # in the gdb.sum.
This page took 0.025445 seconds and 4 git commands to generate.