[test-suite] r262305 - lit: Determine executable name only once

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 22:05:25 PST 2016


Author: matze
Date: Tue Mar  1 00:05:24 2016
New Revision: 262305

URL: http://llvm.org/viewvc/llvm-project?rev=262305&view=rev
Log:
lit: Determine executable name only once

We need it for several modules so it makes sense to determine the name
of the main executable once and store it in the context.

Modified:
    test-suite/trunk/litsupport/hash.py
    test-suite/trunk/litsupport/profilegen.py
    test-suite/trunk/litsupport/test.py

Modified: test-suite/trunk/litsupport/hash.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/hash.py?rev=262305&r1=262304&r2=262305&view=diff
==============================================================================
--- test-suite/trunk/litsupport/hash.py (original)
+++ test-suite/trunk/litsupport/hash.py Tue Mar  1 00:05:24 2016
@@ -6,26 +6,25 @@ import shutil
 import platform
 import shellcommand
 
+
 def collect(context, result):
+    executable = context.executable
     try:
-        exename = shellcommand.getMainExecutable(context)
-        
         # Darwin's "strip" doesn't support these arguments.
         if platform.system() != 'Darwin':
-            stripped_exename = exename + '.stripped'
-            shutil.copyfile(exename, stripped_exename)
+            stripped_executable = executable + '.stripped'
+            shutil.copyfile(executable, stripped_executable)
             subprocess.check_call(['strip',
                                    '--remove-section=.comment',
                                    '--remove-section=.note',
-                                   stripped_exename])
-            exename = stripped_exename
+                                   stripped_executable])
+            executable = stripped_executable
 
         h = hashlib.md5()
-        h.update(open(exename, 'rb').read())
+        h.update(open(executable, 'rb').read())
         digest = h.hexdigest()
 
         result.addMetric('hash', lit.Test.toMetricValue(digest))
 
     except:
-        logging.info('Could not calculate hash for %s' %
-                     context.test.getFullName())
+        logging.info('Could not calculate hash for %s' % executable)

Modified: test-suite/trunk/litsupport/profilegen.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/profilegen.py?rev=262305&r1=262304&r2=262305&view=diff
==============================================================================
--- test-suite/trunk/litsupport/profilegen.py (original)
+++ test-suite/trunk/litsupport/profilegen.py Tue Mar  1 00:05:24 2016
@@ -24,10 +24,7 @@ def wrapScript(context, script):
 
 
 def getMergeProfilesScript(context):
-    executable = shellcommand.getMainExecutable(context)
-    if not executable:
-        return None
-    datafile = executable + ".profdata"
+    datafile = context.executable + ".profdata"
     mergecmd = [context.config.llvm_profdata, 'merge', '-output=%s' % datafile]
     mergecmd += context.profilefiles
     cmdline = " ".join(map(quote, mergecmd))

Modified: test-suite/trunk/litsupport/test.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/test.py?rev=262305&r1=262304&r2=262305&view=diff
==============================================================================
--- test-suite/trunk/litsupport/test.py (original)
+++ test-suite/trunk/litsupport/test.py Tue Mar  1 00:05:24 2016
@@ -13,6 +13,7 @@ import hash
 import perf
 import profilegen
 import runsafely
+import shellcommand
 import testscript
 import timeit
 
@@ -70,6 +71,10 @@ class TestSuiteTest(FileBasedTest):
                          for k, v in metricscripts.items()}
         context = TestContext(test, litConfig, runscript, verifyscript, tmpDir,
                               tmpBase)
+        context.executable = shellcommand.getMainExecutable(context)
+        if context.executable is None:
+            return lit.Test.Result(Test.UNSUPPORTED,
+                                   'Could not determine executable name')
 
         runscript = runsafely.wrapScript(context, runscript, suffix=".out")
 




More information about the llvm-commits mailing list