validate_failures.py: Add support for @include, @remove directives in manifest files.
authorDoug Evans <dje@google.com>
Fri, 30 Nov 2012 21:53:34 +0000 (21:53 +0000)
committerDoug Evans <devans@gcc.gnu.org>
Fri, 30 Nov 2012 21:53:34 +0000 (21:53 +0000)
* testsuite-management/validate_failures.py: Add support for @include,
@remove directives in manifest files.

From-SVN: r194008

contrib/ChangeLog
contrib/testsuite-management/validate_failures.py

index 09b3816459a645e20aa00731348c91bb7f2251ed..cc1c8df33136e6b1d8f81a3419fd4c5b4cafcfef 100644 (file)
@@ -1,5 +1,8 @@
 2012-11-30  Doug Evans  <dje@google.com>
 
+       * testsuite-management/validate_failures.py: Add support for @include,
+       @remove directives in manifest files.
+
        * testsuite-management/validate_failures.py: Add function
        GetManifestPath.  New global _MANIFEST_SUBDIR.
 
index 35ea29b666b7a995df65ac01b2a61cb60e524160..483f466b040892a3de034e398bb8e7b716ad2671 100755 (executable)
@@ -44,6 +44,14 @@ executed it will:
    b- Failures in the build not expected in the manifest.
 6- If all the build failures are expected in the manifest, it exits
    with exit code 0.  Otherwise, it exits with error code 1.
+
+Manifest files contain expected DejaGNU results that are otherwise
+treated as failures.
+They may also contain additional text:
+
+# This is a comment.  - self explanatory
+@include file         - the file is a path relative to the includer
+@remove result text   - result text is removed from the expected set
 """
 
 import datetime
@@ -192,11 +200,13 @@ def ValidBuildDirectory(builddir, target):
   return True
 
 
+def IsComment(line):
+  """Return True if line is a comment."""
+  return line.startswith('#')
+
+
 def IsInterestingResult(line):
-  """Return True if the given line is one of the summary lines we care about."""
-  line = line.strip()
-  if line.startswith('#'):
-    return False
+  """Return True if line is one of the summary lines we care about."""
   if '|' in line:
     (_, line) = line.split('|', 1)
   line = line.strip()
@@ -206,6 +216,58 @@ def IsInterestingResult(line):
   return False
 
 
+def IsInclude(line):
+  """Return True if line is an include of another file."""
+  return line.startswith("@include ")
+
+
+def GetIncludeFile(line, includer):
+  """Extract the name of the include file from line."""
+  includer_dir = os.path.dirname(includer)
+  include_file = line[len("@include "):]
+  return os.path.join(includer_dir, include_file.strip())
+
+
+def IsNegativeResult(line):
+  """Return True if line should be removed from the expected results."""
+  return line.startswith("@remove ")
+
+
+def GetNegativeResult(line):
+  """Extract the name of the negative result from line."""
+  line = line[len("@remove "):]
+  return line.strip()
+
+
+def ParseManifestWorker(result_set, manifest_path):
+  """Read manifest_path, adding the contents to result_set."""
+  if options.verbosity >= 1:
+    print 'Parsing manifest file %s.' % manifest_path
+  manifest_file = open(manifest_path)
+  for line in manifest_file:
+    line = line.strip()
+    if line == "":
+      pass
+    elif IsComment(line):
+      pass
+    elif IsNegativeResult(line):
+      result_set.remove(TestResult(GetNegativeResult(line)))
+    elif IsInclude(line):
+      ParseManifestWorker(result_set, GetIncludeFile(line, manifest_path))
+    elif IsInterestingResult(line):
+      result_set.add(TestResult(line))
+    else:
+      Error('Unrecognized line in manifest file: %s' % line)
+  manifest_file.close()
+
+
+def ParseManifest(manifest_path):
+  """Create a set of TestResult instances from the given manifest file."""
+  result_set = set()
+  ParseManifestWorker(result_set, manifest_path)
+  return result_set
+
+
 def ParseSummary(sum_fname):
   """Create a set of TestResult instances from the given summary file."""
   result_set = set()
@@ -237,7 +299,7 @@ def GetManifest(manifest_path):
   If no manifest file exists for this target, it returns an empty set.
   """
   if os.path.exists(manifest_path):
-    return ParseSummary(manifest_path)
+    return ParseManifest(manifest_path)
   else:
     return set()