<!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>[163998] 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/163998">163998</a></dd>
<dt>Author</dt> <dd>dfarler@apple.com</dd>
<dt>Date</dt> <dd>2014-02-12 16:38:25 -0800 (Wed, 12 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Upstream iOS old-run-webkit-tests for use with DumpRenderTree in the iOS Simulator
https://bugs.webkit.org/show_bug.cgi?id=127694

Reviewed by Simon Fraser.

This is a short-term effort to get layout tests working in the iOS simulator again.

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
Pass PLATFORM_NAME to the makefile.
* DumpRenderTree/ios/PerlSupport/Makefile:
Cleanup.
* Scripts/old-run-webkit-tests:
Added functions and some exceptions for the simulator.
(installAndLaunchDumpRenderTreeAppUsingNotification):
(openIPhoneSimulator):
(quitDumpRenderTreeAppUsingNotification):
(quitIPhoneSimulator):
(simulatorSessionUUID):
(openDiffTool):
(buildDumpTool):
(openDumpTool):
(closeDumpTool):
(dumpToolDidCrash):
(expectedDirectoryForTest):
(buildPlatformResultHierarchy):
* Scripts/webkitdirs.pm:
Support functions for old-run-webkit-tests.
(determineIPhoneSimulatorVersion):
(iPhoneSimulatorVersion):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreeDumpRenderTreexcodeprojprojectpbxproj">trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsDumpRenderTreeiosPerlSupportMakefile">trunk/Tools/DumpRenderTree/ios/PerlSupport/Makefile</a></li>
<li><a href="#trunkToolsScriptsoldrunwebkittests">trunk/Tools/Scripts/old-run-webkit-tests</a></li>
<li><a href="#trunkToolsScriptswebkitdirspm">trunk/Tools/Scripts/webkitdirs.pm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (163997 => 163998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-02-13 00:17:49 UTC (rev 163997)
+++ trunk/Tools/ChangeLog        2014-02-13 00:38:25 UTC (rev 163998)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2014-02-12  David Farler  &lt;dfarler@apple.com&gt;
+
+        Upstream iOS old-run-webkit-tests for use with DumpRenderTree in the iOS Simulator
+        https://bugs.webkit.org/show_bug.cgi?id=127694
+
+        Reviewed by Simon Fraser.
+
+        This is a short-term effort to get layout tests working in the iOS simulator again.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        Pass PLATFORM_NAME to the makefile.
+        * DumpRenderTree/ios/PerlSupport/Makefile:
+        Cleanup.
+        * Scripts/old-run-webkit-tests:
+        Added functions and some exceptions for the simulator.
+        (installAndLaunchDumpRenderTreeAppUsingNotification):
+        (openIPhoneSimulator):
+        (quitDumpRenderTreeAppUsingNotification):
+        (quitIPhoneSimulator):
+        (simulatorSessionUUID):
+        (openDiffTool):
+        (buildDumpTool):
+        (openDumpTool):
+        (closeDumpTool):
+        (dumpToolDidCrash):
+        (expectedDirectoryForTest):
+        (buildPlatformResultHierarchy):
+        * Scripts/webkitdirs.pm:
+        Support functions for old-run-webkit-tests.
+        (determineIPhoneSimulatorVersion):
+        (iPhoneSimulatorVersion):
+
</ins><span class="cx"> 2014-02-12  Mark Hahnenberg  &lt;mhahnenberg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Basic framework for a modern jsc CLI
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeDumpRenderTreexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (163997 => 163998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj        2014-02-13 00:17:49 UTC (rev 163997)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj        2014-02-13 00:38:25 UTC (rev 163998)
</span><span class="lines">@@ -800,7 +800,7 @@
</span><span class="cx"> /* Begin PBXLegacyTarget section */
</span><span class="cx">                 A1158D6218927AF00088C17B /* Perl Support */ = {
</span><span class="cx">                         isa = PBXLegacyTarget;
</span><del>-                        buildArgumentsString = &quot;$(ACTION)&quot;;
</del><ins>+                        buildArgumentsString = &quot;$(ACTION) PLATFORM_NAME=$(PLATFORM_NAME)&quot;;
</ins><span class="cx">                         buildConfigurationList = A1158D6318927AF00088C17B /* Build configuration list for PBXLegacyTarget &quot;Perl Support&quot; */;
</span><span class="cx">                         buildPhases = (
</span><span class="cx">                         );
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeiosPerlSupportMakefile"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/ios/PerlSupport/Makefile (163997 => 163998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/ios/PerlSupport/Makefile        2014-02-13 00:17:49 UTC (rev 163997)
+++ trunk/Tools/DumpRenderTree/ios/PerlSupport/Makefile        2014-02-13 00:38:25 UTC (rev 163998)
</span><span class="lines">@@ -21,10 +21,10 @@
</span><span class="cx"> # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><span class="cx"> # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
</span><span class="cx"> 
</span><del>-ifneq ($(filter iphoneos iphonesimulator, $(PLATFORM_NAME)), )
</del><ins>+ifneq (,$(filter iphonesimulator, $(PLATFORM_NAME)))
</ins><span class="cx"> 
</span><del>-CONFIGURATION_BUILD_DIR ?= .
-OUTPUT_DIR=$(CONFIGURATION_BUILD_DIR)
</del><ins>+TARGET_BUILD_DIR ?= .
+OUTPUT_DIR=$(TARGET_BUILD_DIR)
</ins><span class="cx"> 
</span><span class="cx"> WRAPPER_DIR=$(OUTPUT_DIR)/DerivedSources/DumpRenderTree
</span><span class="cx"> ifneq ($(PLATFORM_NAME),iphoneos)
</span><span class="lines">@@ -40,30 +40,9 @@
</span><span class="cx"> # FIXME: We shouldn't hard code these architectures. See &lt;rdar://problem/9047171&gt; for more discussion on why we have to.
</span><span class="cx"> ARCHS=i386 x86_64
</span><span class="cx"> 
</span><del>-OSX_VERSION = $(shell sw_vers -productVersion | cut -d. -f 2)
-ifeq &quot;$(OSX_VERSION)&quot; &quot;5&quot;
-GENERATE_WRAPPER = YES
-endif
-ifeq &quot;$(OSX_VERSION)&quot; &quot;6&quot;
-GENERATE_WRAPPER = NO
-endif
</del><span class="cx"> 
</span><del>-ifeq &quot;$(GENERATE_WRAPPER)&quot; &quot;YES&quot;
-
-SWIG=/usr/bin/swig
-
</del><span class="cx"> all: $(DYLIB) $(PERL_MODULE)
</span><span class="cx"> 
</span><del>-$(WRAPPER) $(PERL_MODULE): DumpRenderTreeSupport.c $(DUMPRENDERTREE)
-        mkdir -p $(WRAPPER_DIR)
-        $(SWIG) -o $(WRAPPER) -outdir $(OUTPUT_DIR) -perl -module DumpRenderTreeSupport $&lt;
-
-
-else
-
-
-all: $(DYLIB) $(PERL_MODULE)
-
</del><span class="cx"> $(WRAPPER): DumpRenderTreeSupport_wrapPregenerated.c $(DUMPRENDERTREE)
</span><span class="cx">         mkdir -p $(WRAPPER_DIR)
</span><span class="cx">         cp DumpRenderTreeSupport_wrapPregenerated.c $(WRAPPER)
</span><span class="lines">@@ -71,13 +50,8 @@
</span><span class="cx"> $(PERL_MODULE): DumpRenderTreeSupportPregenerated.pm $(DUMPRENDERTREE)
</span><span class="cx">         cp DumpRenderTreeSupportPregenerated.pm $(PERL_MODULE)
</span><span class="cx"> 
</span><del>-
-endif
-
-OS_X_SDK = $(if $(shell xcrun --show-sdk-path -sdk &quot;macosx&quot; 2&gt; /dev/null),macosx, /)
-
</del><span class="cx"> $(DYLIB): DumpRenderTreeSupport.c $(WRAPPER)
</span><del>-        TOOLCHAINS= xcrun -sdk $(OS_X_SDK) cc -g -dynamiclib -o $(DYLIB) `$(PERL) -MExtUtils::Embed -eperl_inc` `$(PERL) -MExtUtils::Embed -e'my $$opts = ldopts(0); $$opts =~ s/-arch [^ ]*( |$$)//g; print $$opts, &quot; -arch &quot;, join(&quot; -arch &quot;, split(&quot; &quot;,$$ENV{ARCHS}))'` $^
</del><ins>+        xcrun -sdk macosx clang -g -dynamiclib -o $(DYLIB) `$(PERL) -MExtUtils::Embed -eperl_inc` `$(PERL) -MExtUtils::Embed -e'my $$opts = ldopts(0); $$opts =~ s/-arch [^ ]*( |$$)//g; print $$opts, &quot; -arch &quot;, join(&quot; -arch &quot;, split(&quot; &quot;,$$ENV{ARCHS}))'` $^
</ins><span class="cx"> 
</span><span class="cx"> IPHONE_SIMULATOR_NOTIFCATION_BUNDLE=$(OUTPUT_DIR)/lib/perl5/darwin-thread-multi-2level/auto/IPhoneSimulatorNotification/IPhoneSimulatorNotification.bundle
</span><span class="cx"> IPHONE_SIMULATOR_NOTIFCATION_MODULE=$(OUTPUT_DIR)/lib/perl5/darwin-thread-multi-2level/IPhoneSimulatorNotification.pm
</span><span class="lines">@@ -85,12 +59,10 @@
</span><span class="cx"> all: $(IPHONE_SIMULATOR_NOTIFCATION_BUNDLE) $(IPHONE_SIMULATOR_NOTIFCATION_MODULE)
</span><span class="cx"> 
</span><span class="cx"> $(IPHONE_SIMULATOR_NOTIFCATION_BUNDLE) $(IPHONE_SIMULATOR_NOTIFCATION_MODULE): IPhoneSimulatorNotification/IPhoneSimulatorNotification.xs IPhoneSimulatorNotification/Makefile.PL IPhoneSimulatorNotification/lib/IPhoneSimulatorNotification.pm IPhoneSimulatorNotification/ppport.h IPhoneSimulatorNotification/t/IPhoneSimulatorNotification.t
</span><del>-        (cd IPhoneSimulatorNotification &amp;&amp; \
-                SDKROOT=$(OS_X_SDK) TOOLCHAINS= $(PERL) Makefile.PL INSTALL_BASE=$(OUTPUT_DIR) &amp;&amp; \
-                make SDKROOT=$(OS_X_SDK) TOOLCHAINS= &amp;&amp; \
-                make test &amp;&amp; \
-                make install &amp;&amp; \
-                make realclean)
</del><ins>+        cd IPhoneSimulatorNotification &amp;&amp; SDKROOT=iphonesimulator perl Makefile.PL INSTALL_BASE=$(OUTPUT_DIR) 
+        make -C IPhoneSimulatorNotification test
+        make -C IPhoneSimulatorNotification install
+        make -C IPhoneSimulatorNotification realclean
</ins><span class="cx">         # Touch the built perl module and its bundle since IPhoneSimulatorNotification.xs and Makefile.PL always have newer dates after building.
</span><span class="cx">         touch $(IPHONE_SIMULATOR_NOTIFCATION_BUNDLE) $(IPHONE_SIMULATOR_NOTIFCATION_MODULE)
</span><span class="cx"> 
</span><span class="lines">@@ -108,6 +80,10 @@
</span><span class="cx"> 
</span><span class="cx"> else
</span><span class="cx"> 
</span><del>-all clean install installhdrs installsrc:
</del><ins>+install:
</ins><span class="cx"> 
</span><ins>+all:
+
+clean:
+
</ins><span class="cx"> endif
</span></span></pre></div>
<a id="trunkToolsScriptsoldrunwebkittests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/old-run-webkit-tests (163997 => 163998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/old-run-webkit-tests        2014-02-13 00:17:49 UTC (rev 163997)
+++ trunk/Tools/Scripts/old-run-webkit-tests        2014-02-13 00:38:25 UTC (rev 163998)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx"> use File::Temp;
</span><span class="cx"> use FindBin;
</span><span class="cx"> use Getopt::Long;
</span><ins>+use IO::Handle;
</ins><span class="cx"> use IPC::Open2;
</span><span class="cx"> use IPC::Open3;
</span><span class="cx"> use MIME::Base64;
</span><span class="lines">@@ -126,11 +127,17 @@
</span><span class="cx"> sub toWindowsPath($);
</span><span class="cx"> sub validateSkippedArg($$;$);
</span><span class="cx"> sub writeToFile($$);
</span><ins>+sub installAndLaunchDumpRenderTreeAppUsingNotification($$);
+sub openIPhoneSimulator();
+sub quitDumpRenderTreeAppUsingNotification();
+sub quitIPhoneSimulator();
+sub simulatorSessionUUID();
</ins><span class="cx"> 
</span><span class="cx"> # Argument handling
</span><span class="cx"> my $addPlatformExceptions = 0;
</span><span class="cx"> my @additionalPlatformDirectories = ();
</span><span class="cx"> my $complexText = 0;
</span><ins>+my $iOSExpectedResultsDir = '';
</ins><span class="cx"> my $exitAfterNFailures = 0;
</span><span class="cx"> my $exitAfterNCrashesOrTimeouts = 0;
</span><span class="cx"> my $generateNewResults = isAppleMacWebKit() ? 1 : 0;
</span><span class="lines">@@ -217,10 +224,35 @@
</span><span class="cx"> 
</span><span class="cx"> my $realPlatform;
</span><span class="cx"> 
</span><del>-my @macPlatforms = (&quot;mac-leopard&quot;, &quot;mac-snowleopard&quot;, &quot;mac-lion&quot;, &quot;mac&quot;);
</del><ins>+my $haveInstallediOSDumpRenderTreeAppOnce;
+
+my @iPhoneSimulatorPlatforms = qw(iphone-simulator);
+my @macPlatforms = (&quot;mac-mountainlion&quot;, &quot;mac&quot;);
</ins><span class="cx"> my @winPlatforms = (&quot;win-xp&quot;, &quot;win-vista&quot;, &quot;win-7sp0&quot;, &quot;win&quot;);
</span><span class="cx"> 
</span><del>-if (isAppleMacWebKit()) {
</del><ins>+if (isIOSWebKit()) {
+    my $simulatorVersionHash = iPhoneSimulatorVersion();
+    my $simulatorVersion = &quot;v&quot; . $simulatorVersionHash-&gt;{major} . &quot;.&quot; . $simulatorVersionHash-&gt;{minor};
+
+    sub versionFromPlatformSuffix {
+        my $version = shift;
+        $version =~ s/^-//;
+        $version =~ s/-/./g;
+        return &quot;v$version&quot;;
+    }
+
+    foreach my $iphoneSimulatorPlatform (reverse @iPhoneSimulatorPlatforms) {
+        if (!$platform) {
+            $platform = $iphoneSimulatorPlatform;
+            next;
+        }
+        die &quot;Invalid platform: $iphoneSimulatorPlatform&quot; unless $iphoneSimulatorPlatform =~ /^iphone-simulator((-[0-9]+){2})$/;
+        last if eval(versionFromPlatformSuffix($1) . &quot; lt $simulatorVersion&quot;);
+        $platform = $iphoneSimulatorPlatform;
+    }
+
+    $tolerance = 1.0;
+} elsif (isAppleMacWebKit()) {
</ins><span class="cx">     if (isSnowLeopard()) {
</span><span class="cx">         $platform = &quot;mac-snowleopard&quot;;
</span><span class="cx">         $tolerance = 0.1;
</span><span class="lines">@@ -272,11 +304,13 @@
</span><span class="cx"> 
</span><span class="cx"> my $usage = &lt;&lt;EOF;
</span><span class="cx"> Usage: $programName [options] [testdir|testpath ...]
</span><ins>+  --32-bit                        Run tests in 32-bit mode
</ins><span class="cx">   --add-platform-exceptions       Put new results for non-platform-specific failing tests into the platform-specific results directory
</span><span class="cx">   --additional-platform-directory path/to/directory
</span><span class="cx">                                   Look in the specified directory before looking in any of the default platform-specific directories
</span><span class="cx">   --complex-text                  Use the complex text code path for all text (Mac OS X and Windows only)
</span><span class="cx">   -c|--configuration config       Set DumpRenderTree build configuration
</span><ins>+  -e|--expected-results           Specify an alternate directory for expected results (iOS only)
</ins><span class="cx">   --gc-between-tests              Force garbage collection between each test
</span><span class="cx">   -g|--guard-malloc               Enable Guard Malloc
</span><span class="cx">   --exit-after-n-failures N       Exit after the first N failures (includes crashes) instead of running all tests
</span><span class="lines">@@ -327,6 +361,7 @@
</span><span class="cx">     'add-platform-exceptions' =&gt; \$addPlatformExceptions,
</span><span class="cx">     'additional-platform-directory=s' =&gt; \@additionalPlatformDirectories,
</span><span class="cx">     'complex-text' =&gt; \$complexText,
</span><ins>+    'expected-results|e=s' =&gt; \$iOSExpectedResultsDir,  # PLATFORM_IOS 
</ins><span class="cx">     'exit-after-n-failures=i' =&gt; \$exitAfterNFailures,
</span><span class="cx">     'exit-after-n-crashes-or-timeouts=i' =&gt; \$exitAfterNCrashesOrTimeouts,
</span><span class="cx">     'gc-between-tests' =&gt; \$gcBetweenTests,
</span><span class="lines">@@ -416,6 +451,8 @@
</span><span class="cx"> my $productDir = productDir();
</span><span class="cx"> $productDir .= &quot;/Programs&quot; if isGtk();
</span><span class="cx"> 
</span><ins>+quitIPhoneSimulator() if isIOSWebKit();
+
</ins><span class="cx"> # Save the current directory before chaging it via chdirWebKit
</span><span class="cx"> my $currentDir = cwd();
</span><span class="cx"> chdirWebKit();
</span><span class="lines">@@ -428,6 +465,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> my $dumpToolName = $useWebKitTestRunner ? &quot;WebKitTestRunner&quot; : &quot;DumpRenderTree&quot;;
</span><ins>+if (isIOSWebKit()) {
+    $dumpToolName = $useWebKitTestRunner ? &quot;WebKitTestRunnerApp.app/WebKitTestRunnerApp&quot; : &quot;DumpRenderTree.app/DumpRenderTree&quot;;
+}
</ins><span class="cx"> 
</span><span class="cx"> if (isAppleWinWebKit()) {
</span><span class="cx">     $dumpToolName .= &quot;_debug&quot; if configuration() eq &quot;Debug_All&quot;;
</span><span class="lines">@@ -442,8 +482,25 @@
</span><span class="cx"> $imageDiffTool .= &quot;_debug&quot; if isCygwin() &amp;&amp; configuration() eq &quot;Debug_Cairo&quot;;
</span><span class="cx"> die &quot;can't find executable $imageDiffTool (looked in $productDir)\n&quot; if $pixelTests &amp;&amp; !-x $imageDiffTool;
</span><span class="cx"> 
</span><del>-checkFrameworks() unless isCygwin();
</del><ins>+checkFrameworks() unless isCygwin() or isIOSWebKit();
</ins><span class="cx"> 
</span><ins>+if (isIOSWebKit()) {
+    push @INC, $productDir . &quot;/lib/perl5/darwin-thread-multi-2level&quot;;
+    require IPhoneSimulatorNotification;
+}
+
+if (isAppleMacWebKit()) {
+    push @INC, $productDir;
+    eval 'use DumpRenderTreeSupport;';
+}
+
+openIPhoneSimulator() if isIOSWebKit();
+
+if (isAppleMacWebKit()) {
+    push @INC, $productDir;
+    require DumpRenderTreeSupport;
+}
+
</ins><span class="cx"> my $layoutTestsName = &quot;LayoutTests&quot;;
</span><span class="cx"> my $testDirectory = File::Spec-&gt;rel2abs($layoutTestsName);
</span><span class="cx"> my $expectedDirectory = $testDirectory;
</span><span class="lines">@@ -453,13 +510,14 @@
</span><span class="cx"> my @platformTestHierarchy = buildPlatformTestHierarchy(@platformResultHierarchy);
</span><span class="cx"> 
</span><span class="cx"> $expectedDirectory = $ENV{&quot;WebKitExpectedTestResultsDirectory&quot;} if $ENV{&quot;WebKitExpectedTestResultsDirectory&quot;};
</span><ins>+$expectedDirectory = $iOSExpectedResultsDir if $iOSExpectedResultsDir &amp;&amp; isIOSWebKit();
</ins><span class="cx"> 
</span><span class="cx"> $testResultsDirectory = File::Spec-&gt;catfile($currentDir, $testResultsDirectory);
</span><span class="cx"> # $testResultsDirectory must be empty before testing.
</span><span class="cx"> rmtree $testResultsDirectory;
</span><span class="cx"> my $testResults = File::Spec-&gt;catfile($testResultsDirectory, &quot;results.html&quot;);
</span><span class="cx"> 
</span><del>-if (isAppleMacWebKit()) {
</del><ins>+if (isAppleMacWebKit() &amp;&amp; !isIOSWebKit()) {
</ins><span class="cx">     print STDERR &quot;Compiling Java tests\n&quot;;
</span><span class="cx">     my $javaTestsDirectory = catdir($testDirectory, &quot;java&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -1097,6 +1155,8 @@
</span><span class="cx"> 
</span><span class="cx"> !$isDumpToolOpen || die &quot;Failed to close $dumpToolName.\n&quot;;
</span><span class="cx"> 
</span><ins>+quitIPhoneSimulator() if isIOSWebKit();
+
</ins><span class="cx"> $isHttpdOpen = !closeHTTPD();
</span><span class="cx"> closeWebSocketServer();
</span><span class="cx"> 
</span><span class="lines">@@ -1196,6 +1256,9 @@
</span><span class="cx">   system &quot;cygstart&quot;, $testResults if $launchSafari;
</span><span class="cx"> } elsif (isWindows()) {
</span><span class="cx">   system &quot;start&quot;, $testResults if $launchSafari;
</span><ins>+} elsif (isIOSWebKit()) {
+  # Don't use run-safari, since it tries to load iOS frameworks in OS X Safari.
+  system &quot;open&quot;, &quot;-a&quot;, &quot;Safari&quot;, $testResults if $launchSafari;
</ins><span class="cx"> } else {
</span><span class="cx">   system &quot;Tools/Scripts/run-safari&quot;, @configurationArgs, &quot;-NSOpen&quot;, $testResults if $launchSafari;
</span><span class="cx"> }
</span><span class="lines">@@ -1287,6 +1350,118 @@
</span><span class="cx">     close NEWFILE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub installAndLaunchDumpRenderTreeAppUsingNotification($$)
+{
+    my ($args, $cleanEnv) = @_;
+
+    my $iPhoneSimulatorNotification = new IPhoneSimulatorNotification;
+    $iPhoneSimulatorNotification-&gt;startObservingApplicationLaunchedNotification();
+
+    my $makeNSDictionaryFromHash = sub {
+        my ($dict) = @_;
+        my $result = NSMutableDictionary-&gt;alloc()-&gt;initWithCapacity_(scalar(keys %{$dict}));
+        for my $key (keys %{$dict}) {
+            $result-&gt;setObject_forKey_(NSString-&gt;stringWithCString_($dict-&gt;{$key}), NSString-&gt;stringWithCString_($key));
+        }
+        return $result-&gt;autorelease();
+    };
+
+    my $makeNSArrayFromArray = sub {
+        my ($array) = @_;
+        my $result = NSMutableArray-&gt;alloc()-&gt;initWithCapacity_(scalar(@{$array}));
+        for my $item (@{$array}) {
+            $result-&gt;addObject_(NSString-&gt;stringWithCString_($item));
+        }
+        return $result-&gt;autorelease();
+    };
+
+    my $deviceName = architecture() eq 'i386' ? &quot;iPhone Retina (4-inch)&quot; : &quot;iPhone Retina (4-inch 64-bit)&quot;;
+
+    my $sdkRoot = `xcrun --sdk iphonesimulator --show-sdk-path`;
+    chomp $sdkRoot;
+
+    my $dict = {
+        applicationArguments =&gt; &amp;$makeNSArrayFromArray($args),
+        applicationEnvironment =&gt; &amp;$makeNSDictionaryFromHash($cleanEnv),
+        applicationIdentifier =&gt; NSString-&gt;stringWithCString_(&quot;org.webkit.DumpRenderTree&quot;),
+        applicationPath =&gt; NSString-&gt;stringWithCString_(&quot;$productDir/DumpRenderTree.app&quot;),
+        deviceInfo =&gt; NSString-&gt;stringWithCString_($deviceName),
+        sessionOwner =&gt; NSString-&gt;stringWithCString_($programName),
+        sessionUUID =&gt; NSString-&gt;stringWithCString_(simulatorSessionUUID()),
+        sdkRoot =&gt; NSString-&gt;stringWithCString_($sdkRoot),
+    };
+    $iPhoneSimulatorNotification-&gt;postStartSessionNotification($dict);
+
+    while (!$iPhoneSimulatorNotification-&gt;hasReceivedApplicationLaunchedNotification()) {
+        my $date = NSDate-&gt;alloc()-&gt;initWithTimeIntervalSinceNow_(0.1);
+        NSRunLoop-&gt;currentRunLoop-&gt;runUntilDate_($date);
+        $date-&gt;release();
+    }
+
+    print &quot;DumpRenderTree has launched.\n&quot;;
+
+    $iPhoneSimulatorNotification-&gt;stopObservingApplicationLaunchedNotification();
+
+    return $iPhoneSimulatorNotification-&gt;applicationLaunchedApplicationPID();
+}
+
+sub openIPhoneSimulator()
+{
+    my $iPhoneSimulatorNotification = new IPhoneSimulatorNotification;
+    $iPhoneSimulatorNotification-&gt;startObservingReadyNotification();
+
+    my $deviceName = architecture() eq 'i386' ? &quot;iPhone Retina (4-inch)&quot; : &quot;iPhone Retina (4-inch 64-bit)&quot;;
+
+    system &quot;open&quot;, &quot;-a&quot;, &quot;iPhone Simulator&quot;, &quot;--args&quot;, &quot;-SessionOnLaunch&quot;, &quot;NO&quot;, &quot;-SimulateDevice&quot;, $deviceName;
+
+    die $! if exitStatus($?);
+
+    while (!$iPhoneSimulatorNotification-&gt;hasReceivedReadyNotification()) {
+        my $date = NSDate-&gt;alloc()-&gt;initWithTimeIntervalSinceNow_(0.1);
+        NSRunLoop-&gt;currentRunLoop-&gt;runUntilDate_($date);
+        $date-&gt;release();
+    }
+
+    $iPhoneSimulatorNotification-&gt;stopObservingReadyNotification();
+}
+
+sub quitDumpRenderTreeAppUsingNotification()
+{
+    my $iPhoneSimulatorNotification = new IPhoneSimulatorNotification;
+    $iPhoneSimulatorNotification-&gt;startObservingApplicationQuitNotification();
+
+    my $dict = {
+        sessionUUID =&gt; NSString-&gt;stringWithCString_(simulatorSessionUUID()),
+    };
+    $iPhoneSimulatorNotification-&gt;postEndSessionNotification($dict);
+
+    # FIXME: &lt;rdar://problem/7443077&gt; DumpRenderTree should exit without having to use kill -9 from run-webkit-tests
+    kill 9, $dumpToolPID;
+
+    my $timeoutCounter = 0;
+    while (!$iPhoneSimulatorNotification-&gt;hasReceivedApplicationQuitNotification()) {
+        my $date = NSDate-&gt;alloc()-&gt;initWithTimeIntervalSinceNow_(0.1);
+        NSRunLoop-&gt;currentRunLoop-&gt;runUntilDate_($date);
+        $date-&gt;release();
+        if (++$timeoutCounter &gt;= 600) {
+            print STDERR &quot;ERROR: Hang waiting for application quit notification. Did DumpRenderTree.app crash instead?\n&quot;;
+            last;
+        }
+    }
+
+    $iPhoneSimulatorNotification-&gt;stopObservingApplicationQuitNotification();
+}
+
+sub quitIPhoneSimulator()
+{
+    system &quot;osascript&quot;, &quot;-e&quot;, &quot;tell application \&quot;iPhone Simulator\&quot; to quit&quot;;
+}
+
+sub simulatorSessionUUID()
+{
+    return &quot;theAwesomeUniqueSessionIdentifierForDumpRenderTree&quot;;
+}
+
</ins><span class="cx"> # Break up a path into the directory (with slash) and base name.
</span><span class="cx"> sub splitpath($)
</span><span class="cx"> {
</span><span class="lines">@@ -1379,8 +1554,10 @@
</span><span class="cx">     return if !$pixelTests;
</span><span class="cx"> 
</span><span class="cx">     my %CLEAN_ENV;
</span><ins>+    my @command = ($imageDiffTool);;
+    unshift(@command, 'xcrun', '-sdk', xcodeSDK(), 'sim') if willUseIOSSimulatorSDKWhenBuilding();
</ins><span class="cx">     $CLEAN_ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
</span><del>-    $imageDiffToolPID = open2(\*DIFFIN, \*DIFFOUT, $imageDiffTool, launchWithEnv(@diffToolArgs, %CLEAN_ENV)) or die &quot;unable to open $imageDiffTool\n&quot;;
</del><ins>+    $imageDiffToolPID = open2(\*DIFFIN, \*DIFFOUT, @command, launchWithEnv(@diffToolArgs, %CLEAN_ENV)) or die &quot;unable to open $imageDiffTool\n&quot;;
</ins><span class="cx">     $isDiffToolOpen = 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1403,7 +1580,7 @@
</span><span class="cx">         $childErr = &quot;&gt;&amp;STDERR&quot;;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    my @args = argumentsForConfiguration();
</del><ins>+    my @args = ('--sdk', xcodeSDK(), argumentsForConfiguration());
</ins><span class="cx">     my $buildProcess = open3($childIn, $childOut, $childErr, $perlInterpreter, File::Spec-&gt;catfile(qw(Tools Scripts), $dumpToolBuildScript), @args) or die &quot;Failed to run build-dumprendertree&quot;;
</span><span class="cx">     close($childIn);
</span><span class="cx">     waitpid $buildProcess, 0;
</span><span class="lines">@@ -1468,6 +1645,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $CLEAN_ENV{DYLD_FRAMEWORK_PATH} = $productDir;
</span><ins>+        $CLEAN_ENV{DYLD_LIBRARY_PATH} = $productDir;
</ins><span class="cx">         $CLEAN_ENV{DYLD_INSERT_LIBRARIES} = &quot;/usr/lib/libgmalloc.dylib&quot; if $guardMalloc;
</span><span class="cx">     } elsif (isCygwin()) {
</span><span class="cx">         $CLEAN_ENV{HOMEDRIVE} = $ENV{'HOMEDRIVE'};
</span><span class="lines">@@ -1489,7 +1667,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     my @args = ($dumpTool, @toolArgs);
</span><del>-    if (isAppleMacWebKit()) { 
</del><ins>+    if (isAppleMacWebKit() and !isIOSWebKit()) { 
</ins><span class="cx">         unshift @args, &quot;arch&quot;, &quot;-&quot; . architecture();             
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1501,7 +1679,59 @@
</span><span class="cx"> 
</span><span class="cx">     $CLEAN_ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
</span><span class="cx"> 
</span><del>-    $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, launchWithEnv(@args, %CLEAN_ENV)) or die &quot;Failed to start tool: $dumpTool\n&quot;;
</del><ins>+    if (isIOSWebKit()) {
+        # We're either running in the iOS Simulator or through SpringBoard, so FIFO it up!
+
+        # Remove old FIFO files if DRT previously crashed.
+        unlink &lt;/tmp/DumpRenderTree_*&gt;;
+
+        if (!-e '/tmp/DumpRenderTree_IN') {
+            system('mkfifo', '/tmp/DumpRenderTree_IN') == 0 or die &quot;Couldn't mkfifo DRT_IN&quot;;
+        }
+        open(\*OUT, &quot;+&gt; /tmp/DumpRenderTree_IN&quot;) or die &quot;Couldn't open DRT_IN!&quot;;
+        OUT-&gt;autoflush(1);
+
+        if (!-e '/tmp/DumpRenderTree_OUT') {
+            system('mkfifo', '/tmp/DumpRenderTree_OUT') == 0 or die &quot;Couldn't mkfifo DRT_OUT&quot;;
+        }
+        open(\*IN, &quot;+&lt; /tmp/DumpRenderTree_OUT&quot;) or die &quot;Couldn't open DRT_OUT!&quot;;
+
+        if (!-e '/tmp/DumpRenderTree_ERROR') {
+            system('mkfifo', '/tmp/DumpRenderTree_ERROR') == 0 or die &quot;Couldn't mkfifo DRT_ERROR&quot;;
+        }
+        open(\*ERROR, &quot;+&lt; /tmp/DumpRenderTree_ERROR&quot;) or die &quot;Couldn't open DRT_ERROR!&quot;;
+
+        shift @args; # remove the actual binary name
+
+        if ($haveInstallediOSDumpRenderTreeAppOnce) {
+            my $simPath = `xcrun -sdk iphonesimulator -find sim`;
+            chomp $simPath;
+
+            my @env = map {
+                my $key = $_;
+                my $val = $CLEAN_ENV{$key};
+                (&quot;-env&quot;, &quot;$key=$val&quot;);
+            } keys %CLEAN_ENV;
+
+            my $archFlag = architecture() eq 'i386' ? '--arch=32' : '--arch=64';
+
+            local(*LAUNCHIN, *LAUNCHOUT);
+            open2(\*LAUNCHIN, \*LAUNCHOUT, $simPath, $archFlag, &quot;LaunchApp&quot;, @env, &quot;org.webkit.DumpRenderTree&quot;, @args) || die &quot;$!&quot;;
+            my $stdout = &lt;LAUNCHIN&gt;;
+            if ($stdout =~ /Launched org.webkit.DumpRenderTree with process ID ([0-9]+)/) {
+                $dumpToolPID = $1;
+            } else {
+                die &quot;Could not launch DumpRenderTree: $!&quot;;
+            }
+            close(LAUNCHOUT) || die &quot;$!&quot;;
+            close(LAUNCHIN) || die &quot;$!&quot;;
+        } else {
+            $dumpToolPID = installAndLaunchDumpRenderTreeAppUsingNotification(\@args, \%CLEAN_ENV);
+            $haveInstallediOSDumpRenderTreeAppOnce = 1;
+        }
+    } else {
+        $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, launchWithEnv(@args, %CLEAN_ENV)) or die &quot;Failed to start tool: $dumpTool\n&quot;;
+    }
</ins><span class="cx">     $isDumpToolOpen = 1;
</span><span class="cx">     $dumpToolCrashed = 0;
</span><span class="cx"> }
</span><span class="lines">@@ -1516,6 +1746,17 @@
</span><span class="cx"> 
</span><span class="cx">     close IN;
</span><span class="cx">     close OUT;
</span><ins>+    if (isIOSWebKit() &amp;&amp; !dumpToolDidCrash()) {
+        if ($haveInstallediOSDumpRenderTreeAppOnce) {
+            kill 9, $dumpToolPID;
+        } else {
+            quitDumpRenderTreeAppUsingNotification();
+        }
+
+        # Since closing the FIFO doesn't actually terminate the DumpRenderTree process,
+        # do it ourselves.  See above FIXME.
+        unlink &lt;/tmp/DumpRenderTree_*&gt;;
+    }
</ins><span class="cx">     waitpid $dumpToolPID, 0;
</span><span class="cx">     
</span><span class="cx">     # check for WebCore counter leaks.
</span><span class="lines">@@ -1532,10 +1773,18 @@
</span><span class="cx"> {
</span><span class="cx">     return 1 if $dumpToolCrashed;
</span><span class="cx">     return 0 unless $isDumpToolOpen;
</span><del>-    my $pid = waitpid(-1, WNOHANG);
-    return 1 if ($pid == $dumpToolPID);
</del><ins>+    if (isIOSWebKit()) {
+        my $count = kill 0, $dumpToolPID;
+        return 1 if !$count;
+    } else {
+        my $pid = waitpid(-1, WNOHANG);
+        return 1 if ($pid == $dumpToolPID);
+    }
</ins><span class="cx"> 
</span><del>-    return 0;
</del><ins>+    # On Mac OS X, crashing may be significantly delayed by crash reporter.
+    return 0 unless isAppleMacWebKit() or isIOSWebKit();
+
+    return DumpRenderTreeSupport::processIsCrashing($dumpToolPID);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> sub configureAndOpenHTTPDIfNeeded()
</span><span class="lines">@@ -1673,7 +1922,8 @@
</span><span class="cx">         push @extraPlatforms, &quot;mac-wk2&quot; if $platform eq &quot;win-wk2&quot;;
</span><span class="cx">         push @extraPlatforms, qw(mac-lion mac);
</span><span class="cx">     }
</span><del>-  
</del><ins>+    push @extraPlatforms, @macPlatforms if isIOSWebKit();
+
</ins><span class="cx">     push @directories, map { catdir($platformBaseDirectory, $_) } @extraPlatforms;
</span><span class="cx">     push @directories, $expectedDirectory;
</span><span class="cx"> 
</span><span class="lines">@@ -2131,6 +2381,12 @@
</span><span class="cx">         if ($platform eq &quot;wincairo&quot;) {
</span><span class="cx">             @platforms = $platform;
</span><span class="cx">         }
</span><ins>+    } elsif ($platform =~ /^iphone-simulator-/) {
+        my $i;
+        for ($i = 0; $i &lt; @iPhoneSimulatorPlatforms; $i++) {
+            last if $iPhoneSimulatorPlatforms[$i] eq $platform;
+        }
+        push @platforms, @iPhoneSimulatorPlatforms[$i..$#iPhoneSimulatorPlatforms];
</ins><span class="cx">     } elsif ($platform =~ /^gtk-/) {
</span><span class="cx">         push @platforms, $platform;
</span><span class="cx">         push @platforms, &quot;gtk&quot;;
</span></span></pre></div>
<a id="trunkToolsScriptswebkitdirspm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitdirs.pm (163997 => 163998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitdirs.pm        2014-02-13 00:17:49 UTC (rev 163997)
+++ trunk/Tools/Scripts/webkitdirs.pm        2014-02-13 00:38:25 UTC (rev 163998)
</span><span class="lines">@@ -87,6 +87,7 @@
</span><span class="cx"> my $sourceDir;
</span><span class="cx"> my $currentSVNRevision;
</span><span class="cx"> my $debugger;
</span><ins>+my $iPhoneSimulatorVersion;
</ins><span class="cx"> my $nmPath;
</span><span class="cx"> my $osXVersion;
</span><span class="cx"> my $generateDsym;
</span><span class="lines">@@ -1154,6 +1155,31 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub determineIPhoneSimulatorVersion()
+{
+    return if $iPhoneSimulatorVersion;
+
+    if (!isIOSWebKit()) {
+        $iPhoneSimulatorVersion = -1;
+        return;
+    }
+
+    my $version = `/usr/local/bin/psw_vers -productVersion`;
+    my @splitVersion = split(/\./, $version);
+    @splitVersion &gt;= 2 or die &quot;Invalid version $version&quot;;
+    $iPhoneSimulatorVersion = {
+            &quot;major&quot; =&gt; $splitVersion[0],
+            &quot;minor&quot; =&gt; $splitVersion[1],
+            &quot;subminor&quot; =&gt; defined($splitVersion[2] ? $splitVersion[2] : 0),
+    };
+}
+
+sub iPhoneSimulatorVersion()
+{
+    determineIPhoneSimulatorVersion();
+    return $iPhoneSimulatorVersion;
+}
+
</ins><span class="cx"> sub determineNmPath()
</span><span class="cx"> {
</span><span class="cx">     return if $nmPath;
</span></span></pre>
</div>
</div>

</body>
</html>