[test-suite] r264501 - lit: Log all executed commands in test.log
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 25 21:05:55 PDT 2016
Author: matze
Date: Fri Mar 25 23:05:55 2016
New Revision: 264501
URL: http://llvm.org/viewvc/llvm-project?rev=264501&view=rev
Log:
lit: Log all executed commands in test.log
This should make all steps transparent and reproducible without using
the lit tool.
This also changed hash.py to use the "-o" option of strip instead of
using a shutil.copyfile() operation which would not be reproducible from
the log file.
Modified:
test-suite/trunk/lit.cfg
test-suite/trunk/litsupport/codesize.py
test-suite/trunk/litsupport/hash.py
test-suite/trunk/litsupport/testplan.py
Modified: test-suite/trunk/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/lit.cfg?rev=264501&r1=264500&r2=264501&view=diff
==============================================================================
--- test-suite/trunk/lit.cfg (original)
+++ test-suite/trunk/lit.cfg Fri Mar 25 23:05:55 2016
@@ -1,6 +1,7 @@
import site
import os
import json
+import logging
site.addsitedir(os.path.dirname(__file__))
from litsupport import test
@@ -18,3 +19,13 @@ if previous_results_file:
config.previous_results = json.load(open(previous_results_file))
else:
config.previous_results = None
+
+logger = logging.getLogger()
+logger.setLevel(logging.DEBUG)
+file_log = logging.FileHandler("%s/test.log" % config.test_source_root,
+ mode="w")
+file_log.setLevel(logging.DEBUG)
+logger.addHandler(file_log)
+console_log = logging.StreamHandler()
+console_log.setLevel(logging.WARNING)
+logger.addHandler(console_log)
Modified: test-suite/trunk/litsupport/codesize.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/codesize.py?rev=264501&r1=264500&r2=264501&view=diff
==============================================================================
--- test-suite/trunk/litsupport/codesize.py (original)
+++ test-suite/trunk/litsupport/codesize.py Fri Mar 25 23:05:55 2016
@@ -1,7 +1,7 @@
import lit.Test
import logging
import os.path
-import subprocess
+import testplan
def _getCodeSize(context):
@@ -15,7 +15,7 @@ def _getCodeSize(context):
if llvm_size:
# -format=sysv is easier to parse than darwin/berkeley.
cmdline = [llvm_size, '-format=sysv', context.executable]
- out = subprocess.check_output(cmdline)
+ out = testplan.check_output(cmdline)
lines = out.splitlines()
# First line contains executable name, second line should be a
# "section size addr" header, numbers start after that.
Modified: test-suite/trunk/litsupport/hash.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/hash.py?rev=264501&r1=264500&r2=264501&view=diff
==============================================================================
--- test-suite/trunk/litsupport/hash.py (original)
+++ test-suite/trunk/litsupport/hash.py Fri Mar 25 23:05:55 2016
@@ -2,8 +2,7 @@ from lit.Test import toMetricValue
import lit.Test
import hashlib
import logging
-import subprocess
-import shutil
+import testplan
import platform
import shellcommand
@@ -14,11 +13,11 @@ def compute(context):
# Darwin's "strip" doesn't support these arguments.
if platform.system() != 'Darwin':
stripped_executable = executable + '.stripped'
- shutil.copyfile(executable, stripped_executable)
- subprocess.check_call([context.config.strip_tool,
- '--remove-section=.comment',
- "--remove-section='.note*'",
- stripped_executable])
+ testplan.check_call([context.config.strip_tool,
+ '--remove-section=.comment',
+ "--remove-section='.note*'",
+ '-o', stripped_executable,
+ executable])
executable = stripped_executable
h = hashlib.md5()
Modified: test-suite/trunk/litsupport/testplan.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/testplan.py?rev=264501&r1=264500&r2=264501&view=diff
==============================================================================
--- test-suite/trunk/litsupport/testplan.py (original)
+++ test-suite/trunk/litsupport/testplan.py Fri Mar 25 23:05:55 2016
@@ -7,6 +7,7 @@ import lit.TestRunner
import logging
import os
import shellcommand
+import subprocess
class TestPlan(object):
@@ -93,6 +94,7 @@ def executeScript(context, script, useEx
execdir = os.getcwd()
executeFunc = lit.TestRunner.executeScriptInternal
+ logging.info("\n".join(script))
res = executeFunc(context.test, context.litConfig, context.tmpBase, script,
execdir)
# The executeScript() functions return lit.Test.Result in some error
@@ -113,9 +115,25 @@ def executeScript(context, script, useEx
context.result_output += "\n" + out
context.result_output += "\n" + err
+ logging.info(out)
+ logging.info(err)
+ if exitCode != 0:
+ logging.info("ExitCode: %s" % exitCode)
return (out, err, exitCode, timeoutInfo)
+def check_output(commandline, *aargs, **dargs):
+ """Wrapper around subprocess.check_output that logs the command."""
+ logging.info(" ".join(commandline))
+ return subprocess.check_output(commandline, *aargs, **dargs)
+
+
+def check_call(commandline, *aargs, **dargs):
+ """Wrapper around subprocess.check_call that logs the command."""
+ logging.info(" ".join(commandline))
+ return subprocess.check_call(commandline, *aargs, **dargs)
+
+
def executePlan(context, plan):
"""This is the main driver for executing a benchmark."""
# Execute RUN: part of the test file.
More information about the llvm-commits
mailing list