<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160108] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160108">160108</a></dd>
<dt>Author</dt> <dd>mhahnenberg@apple.com</dd>
<dt>Date</dt> <dd>2013-12-04 11:17:03 -0800 (Wed, 04 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>run-jsc-stress-tests can only run locally
https://bugs.webkit.org/show_bug.cgi?id=124551

Reviewed by Filip Pizlo.

* Scripts/jsc-stress-test-helpers/shell-runner.sh: Fixed a couple issues. One was if the script was
killed before the lock directory was removed, future executions wouldn't make any progress. Also
added a couple more signals to handle gracefully at shutdown.
* Scripts/run-javascriptcore-tests: Pass through the --remote argument to run-jsc-stress-tests.
* Scripts/run-jsc-stress-tests: Added support for the --remote flag. It accepts a hostname, user, and port.
The script then generates the test bundle, tars it up, and copies it to the remote host via ssh where
it then untars the bundle and executes the shell-based test runner. Also refactored some of the logic
toward the end of the script to make it easier to tell which of the various modes do what.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsjscstresstesthelpersshellrunnersh">trunk/Tools/Scripts/jsc-stress-test-helpers/shell-runner.sh</a></li>
<li><a href="#trunkToolsScriptsrunjavascriptcoretests">trunk/Tools/Scripts/run-javascriptcore-tests</a></li>
<li><a href="#trunkToolsScriptsrunjscstresstests">trunk/Tools/Scripts/run-jsc-stress-tests</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (160107 => 160108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2013-12-04 19:15:58 UTC (rev 160107)
+++ trunk/Tools/ChangeLog        2013-12-04 19:17:03 UTC (rev 160108)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2013-12-04  Mark Hahnenberg  &lt;mhahnenberg@apple.com&gt;
+
+        run-jsc-stress-tests can only run locally
+        https://bugs.webkit.org/show_bug.cgi?id=124551
+
+        Reviewed by Filip Pizlo.
+
+        * Scripts/jsc-stress-test-helpers/shell-runner.sh: Fixed a couple issues. One was if the script was
+        killed before the lock directory was removed, future executions wouldn't make any progress. Also 
+        added a couple more signals to handle gracefully at shutdown. 
+        * Scripts/run-javascriptcore-tests: Pass through the --remote argument to run-jsc-stress-tests.
+        * Scripts/run-jsc-stress-tests: Added support for the --remote flag. It accepts a hostname, user, and port.
+        The script then generates the test bundle, tars it up, and copies it to the remote host via ssh where
+        it then untars the bundle and executes the shell-based test runner. Also refactored some of the logic
+        toward the end of the script to make it easier to tell which of the various modes do what.
+
</ins><span class="cx"> 2013-12-04  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL][WK2] Buildfix after r160104
</span></span></pre></div>
<a id="trunkToolsScriptsjscstresstesthelpersshellrunnersh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/jsc-stress-test-helpers/shell-runner.sh (160107 => 160108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/jsc-stress-test-helpers/shell-runner.sh        2013-12-04 19:15:58 UTC (rev 160107)
+++ trunk/Tools/Scripts/jsc-stress-test-helpers/shell-runner.sh        2013-12-04 19:17:03 UTC (rev 160108)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx"> tempFile=&quot;.temp.txt&quot;
</span><span class="cx"> lockDir=&quot;.lock_dir&quot;
</span><span class="cx"> 
</span><del>-trap &quot;kill -9 0&quot; SIGINT
</del><ins>+trap &quot;kill -9 0&quot; SIGINT SIGHUP SIGTERM
</ins><span class="cx"> 
</span><span class="cx"> echo 0 &gt; ${indexFile}
</span><span class="cx"> ls test_script_* &gt; ${testList}
</span><span class="lines">@@ -49,6 +49,11 @@
</span><span class="cx">     rmdir ${lockDir}
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+if [ -d ${lockDir} ]
+then
+    rmdir ${lockDir}
+fi
+
</ins><span class="cx"> total=`wc -l &lt; &quot;${testList}&quot; | sed 's/ //g'`
</span><span class="cx"> for proc in `seq ${numProcs}`
</span><span class="cx"> do
</span></span></pre></div>
<a id="trunkToolsScriptsrunjavascriptcoretests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-javascriptcore-tests (160107 => 160108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-javascriptcore-tests        2013-12-04 19:15:58 UTC (rev 160107)
+++ trunk/Tools/Scripts/run-javascriptcore-tests        2013-12-04 19:17:03 UTC (rev 160108)
</span><span class="lines">@@ -80,6 +80,7 @@
</span><span class="cx"> my $enableFTL = 0;
</span><span class="cx"> 
</span><span class="cx"> my $createTarball = 0;
</span><ins>+my $remoteHost = 0;
</ins><span class="cx"> 
</span><span class="cx"> my $programName = basename($0);
</span><span class="cx"> my $buildJSCDefault = $buildJSC ? &quot;will check&quot; : &quot;will not check&quot;;
</span><span class="lines">@@ -97,6 +98,7 @@
</span><span class="cx">   --[no-]testapi                Run (or don't run) testapi (default: $testapiDefault)
</span><span class="cx">   --[no-]jsc-stress             Run (or don't run) the JSC stress tests (default: $jscStressDefault)
</span><span class="cx">   --tarball                     Create a tarball of the bundle produced by running the JSC stress tests.
</span><ins>+  --remote=                     Run the JSC stress tests on the specified remote host. Implies --tarball.
</ins><span class="cx"> EOF
</span><span class="cx"> 
</span><span class="cx"> GetOptions(
</span><span class="lines">@@ -108,6 +110,7 @@
</span><span class="cx">     'testapi!' =&gt; \$runTestAPI,
</span><span class="cx">     'jsc-stress!' =&gt; \$runJSCStress,
</span><span class="cx">     'tarball!' =&gt; \$createTarball,
</span><ins>+    'remote=s' =&gt; \$remoteHost,
</ins><span class="cx">     'help' =&gt; \$showHelp
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="lines">@@ -246,6 +249,10 @@
</span><span class="cx">     if ($createTarball) {
</span><span class="cx">         push(@jscStressDriverCmd, &quot;--tarball&quot;);
</span><span class="cx">     }
</span><ins>+    if ($remoteHost) {
+        push(@jscStressDriverCmd, &quot;--remote&quot;);
+        push(@jscStressDriverCmd, $remoteHost);
+    }
</ins><span class="cx">     if (defined($extraTests)) {
</span><span class="cx">         push(@jscStressDriverCmd, $extraTests);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkToolsScriptsrunjscstresstests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-jsc-stress-tests (160107 => 160108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-jsc-stress-tests        2013-12-04 19:15:58 UTC (rev 160107)
+++ trunk/Tools/Scripts/run-jsc-stress-tests        2013-12-04 19:17:03 UTC (rev 160108)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> require 'fileutils'
</span><span class="cx"> require 'getoptlong'
</span><span class="cx"> require 'pathname'
</span><ins>+require 'uri'
</ins><span class="cx"> require 'yaml'
</span><span class="cx"> 
</span><span class="cx"> THIS_SCRIPT_PATH = Pathname.new(__FILE__).realpath
</span><span class="lines">@@ -93,6 +94,10 @@
</span><span class="cx"> $tarball = false
</span><span class="cx"> $copyVM = false
</span><span class="cx"> $testRunnerType = :make
</span><ins>+$remoteUser = nil
+$remoteHost = nil
+$remotePort = nil
+$remoteDirectory = nil
</ins><span class="cx"> 
</span><span class="cx"> def usage
</span><span class="cx">     puts &quot;run-jsc-stress-tests -j &lt;shell path&gt; &lt;collections path&gt; [&lt;collections path&gt; ...]&quot;
</span><span class="lines">@@ -105,6 +110,7 @@
</span><span class="cx">     puts &quot;--tarball                   Creates a tarball of the final bundle.&quot;
</span><span class="cx">     puts &quot;--shell-runner              Uses the shell-based test runner instead of the default make-based runner.&quot;
</span><span class="cx">     puts &quot;                            In general the shell runner is slower than the make runner.&quot;
</span><ins>+    puts &quot;--remote                    Specify a remote host on which to run tests.&quot;
</ins><span class="cx">     puts &quot;--help               (-h)   Print this message.&quot;
</span><span class="cx">     exit 1
</span><span class="cx"> end
</span><span class="lines">@@ -117,6 +123,7 @@
</span><span class="cx">                ['--tarball', GetoptLong::NO_ARGUMENT],
</span><span class="cx">                ['--force-vm-copy', GetoptLong::NO_ARGUMENT],
</span><span class="cx">                ['--shell-runner', GetoptLong::NO_ARGUMENT],
</span><ins>+               ['--remote', GetoptLong::REQUIRED_ARGUMENT],
</ins><span class="cx">                ['--verbose', '-v', GetoptLong::NO_ARGUMENT]).each {
</span><span class="cx">     | opt, arg |
</span><span class="cx">     case opt
</span><span class="lines">@@ -139,6 +146,13 @@
</span><span class="cx">         $copyVM = true
</span><span class="cx">     when '--shell-runner'
</span><span class="cx">         $testRunnerType = :shell
</span><ins>+    when '--remote'
+        $copyVM = true
+        $testRunnerType = :shell
+        $tarball = true
+        $remote = true
+        uri = URI(&quot;ftp://&quot; + arg)
+        $remoteUser, $remoteHost, $remotePort = uri.user, uri.host, uri.port
</ins><span class="cx">     end
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -161,15 +175,11 @@
</span><span class="cx"> $runlist = []
</span><span class="cx"> 
</span><span class="cx"> def frameworkFromJSCPath(jscPath)
</span><del>-    if jscPath.dirname.basename.to_s == &quot;Resources&quot; and jscPath.dirname.dirname.basename.to_s == &quot;JavaScriptCore.framework&quot;
-        jscPath.dirname.dirname
-    elsif jscPath.dirname.dirname.basename.to_s == &quot;WebKitBuild&quot;
-        parentDirName = jscPath.dirname.basename.to_s
-        if parentDirName == &quot;Debug&quot; or parentDirName == &quot;Release&quot; 
-            jscPath.dirname + &quot;JavaScriptCore.framework&quot;
-        else
-            raise &quot;Unknown JSC path, cannot copy full framework: #{jscPath}&quot;
-        end
</del><ins>+    parentDirectory = jscPath.dirname
+    if parentDirectory.basename.to_s == &quot;Resources&quot; and parentDirectory.dirname.basename.to_s == &quot;JavaScriptCore.framework&quot;
+        parentDirectory.dirname
+    elsif parentDirectory.basename.to_s =~ /^Debug/ or parentDirectory.basename.to_s =~ /^Release/
+        jscPath.dirname + &quot;JavaScriptCore.framework&quot;
</ins><span class="cx">     else
</span><span class="cx">         $stderr.puts &quot;Warning: cannot identify JSC framework, doing generic VM copy.&quot;
</span><span class="cx">         nil
</span><span class="lines">@@ -885,6 +895,8 @@
</span><span class="cx">         | collection |
</span><span class="cx">         handleCollection(collection)
</span><span class="cx">     }
</span><ins>+
+    puts
</ins><span class="cx"> end
</span><span class="cx"> 
</span><span class="cx"> def cleanOldResults
</span><span class="lines">@@ -1050,13 +1062,41 @@
</span><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><del>-def runShellTestRunner
-    Dir.chdir($runnerDir) {
-        mysys(&quot;sh&quot;, &quot;runscript&quot;)
</del><ins>+def sshRead(cmd)
+    raise unless $remote
+
+    result = &quot;&quot;
+    IO.popen(&quot;ssh -p #{$remotePort} #{$remoteUser}@#{$remoteHost} '#{cmd}'&quot;, &quot;r&quot;) {
+      | inp |
+      inp.each_line {
+        | line |
+        result += line
+      }
</ins><span class="cx">     }
</span><ins>+    raise &quot;#{$?}&quot; unless $?.success?
+    result
</ins><span class="cx"> end
</span><span class="cx"> 
</span><ins>+def runShellTestRunner
+    if $remote
+        $remoteDirectory = JSON::parse(sshRead(&quot;cat ~/.bencher&quot;))[&quot;tempPath&quot;]
+        mysys(&quot;scp&quot;, &quot;-P&quot;, $remotePort.to_s, ($outputDir.dirname + &quot;payload.tar.gz&quot;).to_s, &quot;#{$remoteUser}@#{$remoteHost}:#{$remoteDirectory}&quot;)
+        remoteScript = &quot;&quot;
+        remoteScript += &quot;cd #{$remoteDirectory} &amp;&amp; &quot;
+        remoteScript += &quot;rm -rf #{$outputDir.basename} &amp;&amp; &quot;
+        remoteScript += &quot;tar xzf payload.tar.gz &amp;&amp; &quot;
+        remoteScript += &quot;cd #{$outputDir.basename}/.runner &amp;&amp; &quot;
+        remoteScript += &quot;DYLD_FRAMEWORK_PATH=$(cd ../#{$frameworkPath.dirname}; pwd) sh runscript&quot; 
+        system(&quot;ssh&quot;, &quot;-p&quot;, $remotePort.to_s, &quot;#{$remoteUser}@#{$remoteHost}&quot;, remoteScript)
+    else
+        Dir.chdir($runnerDir) {
+            mysys(&quot;sh&quot;, &quot;runscript&quot;)
+        }
+    end
+end
+
</ins><span class="cx"> def runMakeTestRunner
</span><ins>+    raise if $remote
</ins><span class="cx">     Dir.chdir($runnerDir) {
</span><span class="cx">         # -1 for the Makefile, and -2 for '..' and '.'
</span><span class="cx">         numberOfTests = Dir.entries(&quot;.&quot;).count - 3
</span><span class="lines">@@ -1126,11 +1166,20 @@
</span><span class="cx"> def detectFailures
</span><span class="cx">     raise if $bundle
</span><span class="cx"> 
</span><del>-    Dir.foreach($runnerDir) {
-        | filename |
-        next unless filename =~ /test_fail_/
-        appendFailure($runlist[$~.post_match.to_i])
-    }
</del><ins>+    if $remote
+        output = sshRead(&quot;cd #{$remoteDirectory}/#{$outputDir.basename}/.runner &amp;&amp; (ls test_fail_* 2&gt; /dev/null || true)&quot;)
+        output.split(/\n/).each {
+            | line |
+            next unless line =~ /test_fail_/
+            appendFailure($runlist[$~.post_match.to_i])
+        }
+    else
+        Dir.foreach($runnerDir) {
+            | filename |
+            next unless filename =~ /test_fail_/
+            appendFailure($runlist[$~.post_match.to_i])
+        }
+    end
</ins><span class="cx"> end
</span><span class="cx"> 
</span><span class="cx"> def compressBundle
</span><span class="lines">@@ -1154,14 +1203,49 @@
</span><span class="cx"> $outputDir = $outputDir.realpath
</span><span class="cx"> $runnerDir = $outputDir + &quot;.runner&quot;
</span><span class="cx"> 
</span><del>-prepareBundle unless $bundle
</del><ins>+def runBundle
+    raise unless $bundle
</ins><span class="cx"> 
</span><del>-puts
</del><ins>+    cleanRunnerDirectory
+    cleanOldResults
+    runTestRunner
+    cleanEmptyResultFiles
+end
</ins><span class="cx"> 
</span><del>-prepareTestRunner unless $bundle
-cleanRunnerDirectory if $bundle
-cleanOldResults if $bundle
-runTestRunner
-cleanEmptyResultFiles
-detectFailures unless $bundle
-compressBundle if $tarball
</del><ins>+def runNormal
+    raise if $bundle or $tarball
+
+    prepareBundle
+    prepareTestRunner
+    runTestRunner
+    cleanEmptyResultFiles
+    detectFailures
+end
+
+def runTarball
+    raise unless $tarball
+
+    prepareBundle 
+    prepareTestRunner
+    compressBundle
+end
+
+def runRemote
+    raise unless $remote
+
+    prepareBundle
+    prepareTestRunner
+    compressBundle
+    runTestRunner
+    detectFailures
+end
+
+if $bundle
+    runBundle
+elsif $remote
+    runRemote
+elsif $tarball
+    runTarball
+else
+    runNormal
+end
</ins></span></pre>
</div>
</div>

</body>
</html>