[test-suite] r262221 - [cmake] hash support: make sure we run strip

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 06:16:38 PST 2016


Author: jamesm
Date: Mon Feb 29 08:16:38 2016
New Revision: 262221

URL: http://llvm.org/viewvc/llvm-project?rev=262221&view=rev
Log:
[cmake] hash support: make sure we run strip

Stripping out certain sections of the binary under test is important to get a stable hash, and is an aspect of the Makefile-based hashing system that I was ignorant of.

Implement this for LIT.

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

Modified: test-suite/trunk/litsupport/hash.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/hash.py?rev=262221&r1=262220&r2=262221&view=diff
==============================================================================
--- test-suite/trunk/litsupport/hash.py (original)
+++ test-suite/trunk/litsupport/hash.py Mon Feb 29 08:16:38 2016
@@ -1,13 +1,25 @@
 import lit.Test
 import hashlib
 import logging
+import subprocess
+import shutil
+import platform
 
 def collect(context, result):
     try:
         exename = context.test.getFilePath().rsplit('.test', 1)[0]
+        backup_exename = exename + '.stripped'
+        shutil.copyfile(exename, backup_exename)
+        
+        # Darwin's "strip" doesn't support these arguments.
+        if platform.system() != 'Darwin':
+            subprocess.check_call(['strip',
+                                   '--remove-section=.comment',
+                                   '--remove-section=.note',
+                                   backup_exename])
 
         h = hashlib.md5()
-        h.update(open(exename).read())
+        h.update(open(backup_exename).read())
         digest = h.hexdigest()
 
         result.addMetric('hash', lit.Test.toMetricValue(digest))




More information about the llvm-commits mailing list