validate_failures.py: Only consider summary lines if there's a tool defined
When parsing a summary or manifest file, if we're not either after a tool
line (e.g. "=== gdb tests ===") or before a summary line (e.g.,
"=== gdb Summary ===") then the current line can't be a valid result line
so ignore it.
This addresses a failure mode in the GDB testsuite where it produces a
valid summary file, but then after the "=== gdb Summary ===" section it
outputs a series of error that confuse the parsing logic.
For example, this is the end of gdb.sum:
=== gdb Summary ===
/home/tcwg-buildslave/workspace/tcwg_gnu_3/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gdb-gdb.git~master/gdb/gdb version 14.0.50.20230612-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /home/tcwg-buildslave/workspace/tcwg_gnu_3/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gdb-gdb.git~master/gdb/data-directory
ERROR: -------------------------------------------
ERROR: in testcase /home/tcwg-buildslave/workspace/tcwg_gnu_3/abe/snapshots/gdb.git~master/gdb/testsuite/gdb.dap/scopes.exp
ERROR: key "body" not known in dictionary
ERROR: tcl error code TCL LOOKUP DICT body
ERROR: tcl error info:
key "body" not known in dictionary
while executing
"dict get [lindex $scopes 0] body scopes"
(file "/home/tcwg-buildslave/workspace/tcwg_gnu_3/abe/snapshots/gdb.git~master/gdb/testsuite/gdb.dap/scopes.exp" line 53)
invoked from within
"source /home/tcwg-buildslave/workspace/tcwg_gnu_3/abe/snapshots/gdb.git~master/gdb/testsuite/gdb.dap/scopes.exp"
("uplevel" body line 1)
invoked from within
"uplevel #0 source /home/tcwg-buildslave/workspace/tcwg_gnu_3/abe/snapshots/gdb.git~master/gdb/testsuite/gdb.dap/scopes.exp"
invoked from within
"catch "uplevel #0 source $test_file_name" msg"
--------------------------------------------------
And it causes the following error in validate_failures.py:
05: 14:32 .sum file seems to be broken: tool="None", exp="None", summary_line="ERROR: -------------------------------------------"
05: 14:32 Traceback (most recent call last):
05: 14:32 File "/home/tcwg-buildslave/workspace/tcwg_gnu_3/gcc-compare-results/contrib/testsuite-management/validate_failures.py", line 706, in <module>
05: 14:32 retval = Main(sys.argv)
05: 14:32 File "/home/tcwg-buildslave/workspace/tcwg_gnu_3/gcc-compare-results/contrib/testsuite-management/validate_failures.py", line 697, in Main
05: 14:32 retval = CheckExpectedResults()
05: 14:32 File "/home/tcwg-buildslave/workspace/tcwg_gnu_3/gcc-compare-results/contrib/testsuite-management/validate_failures.py", line 572, in CheckExpectedResults
05: 14:32 actual = GetResults(sum_files)
05: 14:32 File "/home/tcwg-buildslave/workspace/tcwg_gnu_3/gcc-compare-results/contrib/testsuite-management/validate_failures.py", line 447, in GetResults
05: 14:32 build_results.update(ParseSummary(sum_fname))
05: 14:32 File "/home/tcwg-buildslave/workspace/tcwg_gnu_3/gcc-compare-results/contrib/testsuite-management/validate_failures.py", line 389, in ParseSummary
05: 14:32 result = result_set.MakeTestResult(line, ordinal)
05: 14:32 File "/home/tcwg-buildslave/workspace/tcwg_gnu_3/gcc-compare-results/contrib/testsuite-management/validate_failures.py", line 236, in MakeTestResult
05: 14:32 return TestResult(summary_line, ordinal,
05: 14:32 File "/home/tcwg-buildslave/workspace/tcwg_gnu_3/gcc-compare-results/contrib/testsuite-management/validate_failures.py", line 148, in __init__
05: 14:32 raise
Change-Id: Ic3e40b26c624a3e53970ec05e5a6c4f069c13117
diff --git a/contrib/testsuite-management/validate_failures.py b/contrib/testsuite-management/validate_failures.py
index 4dfd9cd..11bb6f7 100755
--- a/contrib/testsuite-management/validate_failures.py
+++ b/contrib/testsuite-management/validate_failures.py
@@ -295,10 +295,20 @@
return (attrs, line)
-def IsInterestingResult(line):
+def IsInterestingResult(result_set, line):
"""Return True if line is one of the summary lines we care about."""
(_, line) = SplitAttributesFromSummaryLine(line)
- return bool(_VALID_TEST_RESULTS_REX.match(line))
+ valid_result = bool(_VALID_TEST_RESULTS_REX.match(line))
+
+ # If there's no tool defined it means that either the results section hasn't
+ # started yet, or it is already over.
+ if valid_result and result_set.current_tool is None:
+ if _OPTIONS.verbosity >= 3:
+ print(f'WARNING: Result "{line}" found outside sum file boundaries.',
+ file=sys.stderr)
+ return False
+
+ return valid_result
def IsToolLine(line):
@@ -354,7 +364,7 @@
result_set.remove(result_set.MakeTestResult(GetNegativeResult(line)))
elif IsInclude(line):
ParseManifestWorker(result_set, GetIncludeFile(line, manifest_path))
- elif IsInterestingResult(line):
+ elif IsInterestingResult(result_set, line):
result = result_set.MakeTestResult(line)
if result.HasExpired():
# Ignore expired manifest entries.
@@ -391,7 +401,7 @@
ordinal=0
sum_file = open(sum_fname, encoding='latin-1', mode='r')
for line in sum_file:
- if IsInterestingResult(line):
+ if IsInterestingResult(result_set, line):
result = result_set.MakeTestResult(line, ordinal)
ordinal += 1
if result.HasExpired():