[test-suite] r262220 - [cmake] Add support for hashing test binaries

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 05:47:19 PST 2016


Author: jamesm
Date: Mon Feb 29 07:47:19 2016
New Revision: 262220

URL: http://llvm.org/viewvc/llvm-project?rev=262220&view=rev
Log:
[cmake] Add support for hashing test binaries

This adds the "hash" metric as computed by the HashProgramOutput.sh script (used by the Makefile build).

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

Added: test-suite/trunk/litsupport/hash.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/hash.py?rev=262220&view=auto
==============================================================================
--- test-suite/trunk/litsupport/hash.py (added)
+++ test-suite/trunk/litsupport/hash.py Mon Feb 29 07:47:19 2016
@@ -0,0 +1,17 @@
+import lit.Test
+import hashlib
+import logging
+
+def collect(context, result):
+    try:
+        exename = context.test.getFilePath().rsplit('.test', 1)[0]
+
+        h = hashlib.md5()
+        h.update(open(exename).read())
+        digest = h.hexdigest()
+
+        result.addMetric('hash', lit.Test.toMetricValue(digest))
+
+    except:
+        logging.info('Could not calculate hash for %s' %
+                     context.test.getFullName())

Modified: test-suite/trunk/litsupport/test.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/test.py?rev=262220&r1=262219&r2=262220&view=diff
==============================================================================
--- test-suite/trunk/litsupport/test.py (original)
+++ test-suite/trunk/litsupport/test.py Mon Feb 29 07:47:19 2016
@@ -9,6 +9,7 @@ from lit import Test
 from lit.util import to_bytes, to_string
 
 import compiletime
+import hash
 import perf
 import profilegen
 import runsafely
@@ -143,5 +144,6 @@ class TestSuiteTest(FileBasedTest):
         for metric, values in metrics.items():
             result.addMetric(metric, lit.Test.toMetricValue(values[0]))
         compiletime.collect(context, result)
+        hash.collect(context, result)
 
         return result




More information about the llvm-commits mailing list