[test-suite] r263534 - lit: Skip RunSafely.sh and invoke timeit directly
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 14 22:12:28 PDT 2016
Author: matze
Date: Tue Mar 15 00:12:28 2016
New Revision: 263534
URL: http://llvm.org/viewvc/llvm-project?rev=263534&view=rev
Log:
lit: Skip RunSafely.sh and invoke timeit directly
This also allows us to split run_under and remove device handling into
separate modules.
Added:
test-suite/trunk/litsupport/remote.py
test-suite/trunk/litsupport/run_under.py
Removed:
test-suite/trunk/litsupport/runsafely.py
Modified:
test-suite/trunk/lit.cfg
test-suite/trunk/litsupport/test.py
test-suite/trunk/litsupport/timeit.py
Modified: test-suite/trunk/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/lit.cfg?rev=263534&r1=263533&r2=263534&view=diff
==============================================================================
--- test-suite/trunk/lit.cfg (original)
+++ test-suite/trunk/lit.cfg Tue Mar 15 00:12:28 2016
@@ -8,6 +8,7 @@ config.name = 'test-suite'
config.test_format = test.TestSuiteTest()
config.suffixes = ['.test']
config.excludes = ['ABI-Testsuite']
+config.remote_flags = ""
config.traditional_output = True
if 'SSH_AUTH_SOCK' in os.environ:
config.environment['SSH_AUTH_SOCK'] = os.environ['SSH_AUTH_SOCK']
Added: test-suite/trunk/litsupport/remote.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/remote.py?rev=263534&view=auto
==============================================================================
--- test-suite/trunk/litsupport/remote.py (added)
+++ test-suite/trunk/litsupport/remote.py Tue Mar 15 00:12:28 2016
@@ -0,0 +1,30 @@
+import logging
+import testplan
+
+
+def mutateCommandline(context, commandline):
+ shfilename = context.tmpBase + ".sh"
+ shfile = open(shfilename, "w")
+ shfile.write(commandline + "\n")
+ logging.info("Created shfile '%s'", shfilename)
+ shfile.close()
+
+ config = context.config
+ remote_commandline = config.remote_client
+ if config.remote_user:
+ remote_commandline += " -l %s" % config.remote_user
+ if config.remote_port:
+ remote_commandline += " -rp %s" % config.remote_port
+ if config.remote_flags:
+ remote_commandline += config.remote_flags
+ remote_commandline += " %s" % config.remote_host
+ remote_commandline += " /bin/sh %s" % shfilename
+ return remote_commandline
+
+
+def mutateScript(context, script):
+ return testplan.mutateScript(context, script, mutateCommandline)
+
+
+def mutatePlan(context, plan):
+ plan.runscript = mutateScript(context, plan.runscript)
Added: test-suite/trunk/litsupport/run_under.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/run_under.py?rev=263534&view=auto
==============================================================================
--- test-suite/trunk/litsupport/run_under.py (added)
+++ test-suite/trunk/litsupport/run_under.py Tue Mar 15 00:12:28 2016
@@ -0,0 +1,13 @@
+import shellcommand
+import testplan
+
+
+def mutateCommandLine(context, commandline):
+ return context.config.run_under + commandline
+
+
+def mutatePlan(context, plan):
+ run_under = context.config.run_under
+ if run_under:
+ plan.runscript = testplan.mutateScript(context, plan.runscript,
+ mutateCommandLine)
Removed: test-suite/trunk/litsupport/runsafely.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/runsafely.py?rev=263533&view=auto
==============================================================================
--- test-suite/trunk/litsupport/runsafely.py (original)
+++ test-suite/trunk/litsupport/runsafely.py (removed)
@@ -1,72 +0,0 @@
-import lit.Test
-import shellcommand
-import testplan
-import timeit
-
-
-def mutateCommandline(context, commandline):
- outfile = context.tmpBase + ".out"
- timefile = outfile + ".time"
- config = context.config
- cmd = shellcommand.parse(commandline)
-
- runsafely = "%s/RunSafely.sh" % config.test_suite_root
- runsafely_prefix = []
- if cmd.workdir is not None:
- runsafely_prefix += ["-d", cmd.workdir]
- cmd.workdir = None
- timeit = "%s/tools/timeit" % config.test_source_root
- if config.remote_host:
- timeit = "%s/tools/timeit-target" % config.test_source_root
- runsafely_prefix += ["-r", config.remote_host]
- if config.remote_user:
- runsafely_prefix += ["-l", config.remote_user]
- if config.remote_client:
- runsafely_prefix += ["-rc", config.remote_client]
- if config.remote_port:
- runsafely_prefix += ["-rp", config.remote_port]
- if config.run_under:
- runsafely_prefix += ["-u", config.run_under]
- if not config.traditional_output:
- runsafely_prefix += ["-n"]
- if cmd.stdout is not None:
- runsafely_prefix += ["-o", cmd.stdout]
- cmd.stdout = None
- if cmd.stderr is not None:
- runsafely_prefix += ["-e", cmd.stderr]
- cmd.stderr = None
- else:
- if cmd.stdout is not None or cmd.stderr is not None:
- raise Exception("Separate stdout/stderr redirection not " +
- "possible with traditional output")
- timeout = "7200"
- if cmd.stdin is not None:
- stdin = cmd.stdin
- cmd.stdin = None
- else:
- stdin = "/dev/null"
- runsafely_prefix += ["-t", timeit, timeout, stdin, outfile]
-
- context.timefiles.append(outfile + ".time")
-
- cmd.wrap(runsafely, runsafely_prefix)
- return cmd.toCommandline()
-
-
-def mutateScript(context, script):
- return testplan.mutateScript(context, script, mutateCommandline)
-
-
-def _getTime(context, timefiles, metric_name='exec_time'):
- time = 0.0
- for timefile in timefiles:
- time += timeit.getUserTime(timefile)
- return {metric_name: lit.Test.toMetricValue(time)}
-
-
-def mutatePlan(context, plan):
- context.timefiles = []
- plan.runscript = mutateScript(context, plan.runscript)
- plan.metric_collectors.append(
- lambda context: _getTime(context, context.timefiles)
- )
Modified: test-suite/trunk/litsupport/test.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/test.py?rev=263534&r1=263533&r2=263534&view=diff
==============================================================================
--- test-suite/trunk/litsupport/test.py (original)
+++ test-suite/trunk/litsupport/test.py Tue Mar 15 00:12:28 2016
@@ -13,9 +13,11 @@ import compiletime
import hash
import perf
import profilegen
-import runsafely
+import remote
+import run_under
import shellcommand
import testplan
+import timeit
SKIPPED = lit.Test.ResultCode('SKIPPED', False)
@@ -76,12 +78,15 @@ class TestSuiteTest(FileBasedTest):
lit.util.mkdir_p(os.path.dirname(tmpBase))
# Prepare test plan
- runsafely.mutatePlan(context, plan)
+ run_under.mutatePlan(context, plan)
+ timeit.mutatePlan(context, plan)
compiletime.mutatePlan(context, plan)
codesize.mutatePlan(context, plan)
hash.mutatePlan(context, plan)
if config.profile_generate:
profilegen.mutatePlan(context, plan)
+ if config.remote_host:
+ remote.mutatePlan(context, plan)
if litConfig.params.get('profile') == 'perf':
perf.mutatePlan(context, plan)
Modified: test-suite/trunk/litsupport/timeit.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/timeit.py?rev=263534&r1=263533&r2=263534&view=diff
==============================================================================
--- test-suite/trunk/litsupport/timeit.py (original)
+++ test-suite/trunk/litsupport/timeit.py Tue Mar 15 00:12:28 2016
@@ -1,4 +1,71 @@
+import lit.Test
import re
+import shellcommand
+import testplan
+
+
+def mutateCommandLine(context, commandline):
+ outfile = context.tmpBase + ".out"
+ timefile = context.tmpBase + ".time"
+ config = context.config
+ cmd = shellcommand.parse(commandline)
+
+ timeit = "%s/tools/timeit" % config.test_source_root
+ if config.remote_host:
+ timeit = "%s/tools/timeit-target" % config.test_source_root
+ args = ["--limit-core", "0"]
+ args += ["--limit-cpu", "7200"]
+ args += ["--timeout", "7200"]
+ args += ["--limit-file-size", "104857600"]
+ args += ["--limit-rss-size", "838860800"]
+ if cmd.workdir is not None:
+ args += ["--chdir", cmd.workdir]
+ cmd.workdir = None
+ if not config.traditional_output:
+ if cmd.stdout is not None:
+ args += ["--redirect-stdout", cmd.stdout]
+ cmd.stdout = None
+ if cmd.stderr is not None:
+ args += ["--redirect-stderr", cmd.stderr]
+ cmd.stderr = None
+ else:
+ if cmd.stdout is not None or cmd.stderr is not None:
+ raise Exception("Separate stdout/stderr redirection not " +
+ "possible with traditional output")
+ args += ["--append-exitstatus"]
+ args += ["--redirect-output", outfile]
+ if cmd.stdin is not None:
+ args += ["--redirect-input", cmd.stdin]
+ cmd.stdin = None
+ else:
+ args += ["--redirect-input", "/dev/null"]
+ args += ["--summary", timefile]
+ # Remember timefilename for later
+ context.timefiles.append(timefile)
+
+ cmd.wrap(timeit, args)
+ return cmd.toCommandline()
+
+
+def mutateScript(context, script):
+ if not hasattr(context, "timefiles"):
+ context.timefiles = []
+ return testplan.mutateScript(context, script, mutateCommandLine)
+
+
+def _collectTime(context, timefiles, metric_name='exec_time'):
+ time = 0.0
+ for timefile in timefiles:
+ time += getUserTime(timefile)
+ return { metric_name: lit.Test.toMetricValue(time) }
+
+
+def mutatePlan(context, plan):
+ context.timefiles = []
+ plan.runscript = mutateScript(context, plan.runscript)
+ plan.metric_collectors.append(
+ lambda context: _collectTime(context, context.timefiles)
+ )
def getUserTime(filename):
More information about the llvm-commits
mailing list