Patchwork [RFA,7/8] validate_failures.py: New options --manifest_subdir, --manifest_name

login
register
mail settings
Submitter Doug Evans
Date Nov. 24, 2012, 10:58 p.m.
Message ID <yjt2vccu621d.fsf@ruffy2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/201486/
State New
Headers show

Comments

Doug Evans - Nov. 24, 2012, 10:58 p.m.
Hi.
This seventh patch adds new options --manifest_subdir, --manifest_name.
Useful when using validate_failures.py with a different tool, instead of gcc.

Ok to check in?

2012-11-24  Doug Evans  <dje@google.com>

	* testsuite-management/validate_failures.py: New options --manifest_subdir,
	--manifest_name.
Diego Novillo - Nov. 25, 2012, 3:43 p.m.
On Sat, Nov 24, 2012 at 5:58 PM, Doug Evans <dje@google.com> wrote:
> Hi.
> This seventh patch adds new options --manifest_subdir, --manifest_name.
> Useful when using validate_failures.py with a different tool, instead of gcc.
>
> Ok to check in?
>
> 2012-11-24  Doug Evans  <dje@google.com>
>
>         * testsuite-management/validate_failures.py: New options --manifest_subdir,
>         --manifest_name.

OK.


Diego.

Patch

--- validate_failures.py.with-first-6-patches	2012-11-24 13:47:44.410137689 -0800
+++ validate_failures.py	2012-11-24 13:53:40.253541475 -0800
@@ -37,7 +37,7 @@  executed it will:
 1- Determine the target built: TARGET
 2- Determine the source directory: SRCDIR
 3- Look for a failure manifest file in
-   <SRCDIR>/contrib/testsuite-management/<TARGET>.xfail
+   <SRCDIR>/<MANIFEST_SUBDIR>/<MANIFEST_NAME>.xfail
 4- Collect all the <tool>.sum files from the build tree.
 5- Produce a report stating:
    a- Failures expected in the manifest but not present in the build.
@@ -55,10 +55,15 @@  import sys
 # Handled test results.
 _VALID_TEST_RESULTS = [ 'FAIL', 'UNRESOLVED', 'XPASS', 'ERROR' ]
 
-# Pattern for naming manifest files.  The first argument should be
-# the toplevel GCC source directory.  The second argument is the
-# target triple used during the build.
-_MANIFEST_PATH_PATTERN = '%s/contrib/testsuite-management/%s.xfail'
+# Default subdirectory of srcdir in which to find the manifest file.
+_MANIFEST_DEFAULT_SUBDIR = 'contrib/testsuite-management'
+
+# Pattern for naming manifest files.
+# The first argument should be the toplevel GCC(/GNU tool) source directory.
+# The second argument is the manifest subdir.
+# The third argument is the manifest target, which defaults to the target
+# triplet used during the build.
+_MANIFEST_PATH_PATTERN = '%s/%s/%s.xfail'
 
 # The options passed to the program.
 options = None
@@ -284,6 +289,22 @@  def CompareResults(manifest, actual):
   return actual_vs_manifest, manifest_vs_actual
 
 
+def GetManifestPath(srcdir, target, user_provided_must_exist):
+  """Return the full path to the manifest file."""
+  manifest_path = None
+  if options.manifest_path:
+    manifest_path = options.manifest_path
+  elif options.manifest_name:
+    manifest_path = _MANIFEST_PATH_PATTERN % (
+      srcdir, options.manifest_subdir, options.manifest_name)
+  if manifest_path:
+    if user_provided_must_exist and not os.path.exists(manifest_path):
+      Error('Manifest does not exist: %s' % manifest_path)
+    return manifest_path
+  else:
+    return _MANIFEST_PATH_PATTERN % (srcdir, options.manifest_subdir, target)
+
+
 def GetBuildData():
   target = GetMakefileValue('%s/Makefile' % options.build_dir, 'target_alias=')
   srcdir = GetMakefileValue('%s/Makefile' % options.build_dir, 'srcdir =')
@@ -333,14 +354,8 @@  def PerformComparison(expected, actual, 
 
 
 def CheckExpectedResults():
-  if not options.manifest:
-    (srcdir, target) = GetBuildData()
-    manifest_path = _MANIFEST_PATH_PATTERN % (srcdir, target)
-  else:
-    manifest_path = options.manifest
-    if not os.path.exists(manifest_path):
-      Error('Manifest file %s does not exist.' % manifest_path)
-
+  (srcdir, target) = GetBuildData()
+  manifest_path = GetManifestPath(srcdir, target, True)
   print 'Manifest:         %s' % manifest_path
   manifest = GetManifest(manifest_path)
   sum_files = GetSumFiles(options.results, options.build_dir)
@@ -355,7 +370,8 @@  def CheckExpectedResults():
 
 def ProduceManifest():
   (srcdir, target) = GetBuildData()
-  manifest_path = _MANIFEST_PATH_PATTERN % (srcdir, target)
+  manifest_path = GetManifestPath(srcdir, target, False)
+  print 'Manifest:         %s' % manifest_path
   if os.path.exists(manifest_path) and not options.force:
     Error('Manifest file %s already exists.\nUse --force to overwrite.' %
           manifest_path)
@@ -418,6 +434,16 @@  def Main(argv):
                     dest='produce_manifest', default=False,
                     help='Produce the manifest for the current '
                     'build (default = False)')
+  parser.add_option('--manifest_subdir', action='store', type='string',
+                    dest='manifest_subdir',
+                    default=_MANIFEST_DEFAULT_SUBDIR,
+                    help=('Subdirectory of srcdir to find manifest file in\n'
+                          '(default = %s)' % _MANIFEST_DEFAULT_SUBDIR))
+  parser.add_option('--manifest_name', action='store', type='string',
+                    dest='manifest_name',
+                    default=None,
+                    help=('Name of manifest file, sans .xfail suffix'
+                          ' (default = target_alias)'))
   parser.add_option('--results', action='store', type='string',
                     dest='results', default=None, help='Space-separated list '
                     'of .sum files with the testing results to check. The '