public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [contrib] validate_failures.py: Don't consider summary line in wrong place
@ 2023-06-16 12:02 Thiago Jung Bauermann
  2023-06-17 22:03 ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Thiago Jung Bauermann @ 2023-06-16 12:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: Thiago Jung Bauermann

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 problem we're seeing when running the GDB testsuite in
our CI environment where it produces a valid summary file, but then after
the "=== gdb Summary ===" section it outputs a series of Tcl errors that
match _VALID_TEST_RESULTS_REX and thus confuse the parsing logic:

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 "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 706, in <module>
05: 14:32     retval = Main(sys.argv)
05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 697, in Main
05: 14:32     retval = CheckExpectedResults()
05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 572, in CheckExpectedResults
05: 14:32     actual = GetResults(sum_files)
05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 447, in GetResults
05: 14:32     build_results.update(ParseSummary(sum_fname))
05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 389, in ParseSummary
05: 14:32     result = result_set.MakeTestResult(line, ordinal)
05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 236, in MakeTestResult
05: 14:32     return TestResult(summary_line, ordinal,
05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 148, in __init__
05: 14:32     raise

contrib/ChangeLog:

	* testsuite-management/validate_failures.py (IsInterestingResult):
	Add result_set argument and use it.  Adjust callers.
---
 .../testsuite-management/validate_failures.py  | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/contrib/testsuite-management/validate_failures.py b/contrib/testsuite-management/validate_failures.py
index 4dfd9cda4e24..11bb6f7e9c7c 100755
--- a/contrib/testsuite-management/validate_failures.py
+++ b/contrib/testsuite-management/validate_failures.py
@@ -295,10 +295,20 @@ def SplitAttributesFromSummaryLine(line):
   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 @@ def ParseManifestWorker(result_set, manifest_path):
       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 @@ def ParseSummary(sum_fname):
   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():

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [contrib] validate_failures.py: Don't consider summary line in wrong place
  2023-06-16 12:02 [PATCH] [contrib] validate_failures.py: Don't consider summary line in wrong place Thiago Jung Bauermann
@ 2023-06-17 22:03 ` Jeff Law
  2023-06-19 10:04   ` Thiago Jung Bauermann
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2023-06-17 22:03 UTC (permalink / raw)
  To: Thiago Jung Bauermann, gcc-patches



On 6/16/23 06:02, Thiago Jung Bauermann via Gcc-patches wrote:
> 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 problem we're seeing when running the GDB testsuite in
> our CI environment where it produces a valid summary file, but then after
> the "=== gdb Summary ===" section it outputs a series of Tcl errors that
> match _VALID_TEST_RESULTS_REX and thus confuse the parsing logic:
> 
> 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 "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 706, in <module>
> 05: 14:32     retval = Main(sys.argv)
> 05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 697, in Main
> 05: 14:32     retval = CheckExpectedResults()
> 05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 572, in CheckExpectedResults
> 05: 14:32     actual = GetResults(sum_files)
> 05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 447, in GetResults
> 05: 14:32     build_results.update(ParseSummary(sum_fname))
> 05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 389, in ParseSummary
> 05: 14:32     result = result_set.MakeTestResult(line, ordinal)
> 05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 236, in MakeTestResult
> 05: 14:32     return TestResult(summary_line, ordinal,
> 05: 14:32   File "/path/to/gcc/contrib/testsuite-management/validate_failures.py", line 148, in __init__
> 05: 14:32     raise
> 
> contrib/ChangeLog:
> 
> 	* testsuite-management/validate_failures.py (IsInterestingResult):
> 	Add result_set argument and use it.  Adjust callers.
Thanks.  I pushed this to the trunk.
jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [contrib] validate_failures.py: Don't consider summary line in wrong place
  2023-06-17 22:03 ` Jeff Law
@ 2023-06-19 10:04   ` Thiago Jung Bauermann
  0 siblings, 0 replies; 3+ messages in thread
From: Thiago Jung Bauermann @ 2023-06-19 10:04 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches


Jeff Law <jeffreyalaw@gmail.com> writes:

> On 6/16/23 06:02, Thiago Jung Bauermann via Gcc-patches wrote:
>> contrib/ChangeLog:
>> 	* testsuite-management/validate_failures.py (IsInterestingResult):
>> 	Add result_set argument and use it.  Adjust callers.
> Thanks.  I pushed this to the trunk.

Thank you!

-- 
Thiago

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-19 10:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-16 12:02 [PATCH] [contrib] validate_failures.py: Don't consider summary line in wrong place Thiago Jung Bauermann
2023-06-17 22:03 ` Jeff Law
2023-06-19 10:04   ` Thiago Jung Bauermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).