[test-suite] r262253 - lit: Improve executable hashing
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 29 12:47:04 PST 2016
Author: matze
Date: Mon Feb 29 14:47:04 2016
New Revision: 262253
URL: http://llvm.org/viewvc/llvm-project?rev=262253&view=rev
Log:
lit: Improve executable hashing
I had a similar hashing support lying around in my personal repository
for weeks now, thinking that I needed to get
http://reviews.llvm.org/rL262220 accepted first. Turns out I didn't :)
This does some code cleanup and merges some things from my commmit: Use
'rb' open mode and shellcommand.getMainExecutable() to get the name of
the executable.
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=262253&r1=262252&r2=262253&view=diff
==============================================================================
--- test-suite/trunk/litsupport/hash.py (original)
+++ test-suite/trunk/litsupport/hash.py Mon Feb 29 14:47:04 2016
@@ -4,22 +4,24 @@ import logging
import subprocess
import shutil
import platform
+import shellcommand
def collect(context, result):
try:
- exename = context.test.getFilePath().rsplit('.test', 1)[0]
- backup_exename = exename + '.stripped'
- shutil.copyfile(exename, backup_exename)
+ 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)
subprocess.check_call(['strip',
'--remove-section=.comment',
'--remove-section=.note',
- backup_exename])
+ stripped_exename])
+ exename = stripped_exename
h = hashlib.md5()
- h.update(open(backup_exename).read())
+ h.update(open(exename, 'rb').read())
digest = h.hexdigest()
result.addMetric('hash', lit.Test.toMetricValue(digest))
More information about the llvm-commits
mailing list