Title: [163998] trunk/Tools
Revision
163998
Author
[email protected]
Date
2014-02-12 16:38:25 -0800 (Wed, 12 Feb 2014)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (163997 => 163998)


--- trunk/Tools/ChangeLog	2014-02-13 00:17:49 UTC (rev 163997)
+++ trunk/Tools/ChangeLog	2014-02-13 00:38:25 UTC (rev 163998)
@@ -1,3 +1,35 @@
+2014-02-12  David Farler  <[email protected]>
+
+        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):
+
 2014-02-12  Mark Hahnenberg  <[email protected]>
 
         Basic framework for a modern jsc CLI

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (163997 => 163998)


--- 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)
@@ -800,7 +800,7 @@
 /* Begin PBXLegacyTarget section */
 		A1158D6218927AF00088C17B /* Perl Support */ = {
 			isa = PBXLegacyTarget;
-			buildArgumentsString = "$(ACTION)";
+			buildArgumentsString = "$(ACTION) PLATFORM_NAME=$(PLATFORM_NAME)";
 			buildConfigurationList = A1158D6318927AF00088C17B /* Build configuration list for PBXLegacyTarget "Perl Support" */;
 			buildPhases = (
 			);

Modified: trunk/Tools/DumpRenderTree/ios/PerlSupport/Makefile (163997 => 163998)


--- 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)
@@ -21,10 +21,10 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
-ifneq ($(filter iphoneos iphonesimulator, $(PLATFORM_NAME)), )
+ifneq (,$(filter iphonesimulator, $(PLATFORM_NAME)))
 
-CONFIGURATION_BUILD_DIR ?= .
-OUTPUT_DIR=$(CONFIGURATION_BUILD_DIR)
+TARGET_BUILD_DIR ?= .
+OUTPUT_DIR=$(TARGET_BUILD_DIR)
 
 WRAPPER_DIR=$(OUTPUT_DIR)/DerivedSources/DumpRenderTree
 ifneq ($(PLATFORM_NAME),iphoneos)
@@ -40,30 +40,9 @@
 # FIXME: We shouldn't hard code these architectures. See <rdar://problem/9047171> for more discussion on why we have to.
 ARCHS=i386 x86_64
 
-OSX_VERSION = $(shell sw_vers -productVersion | cut -d. -f 2)
-ifeq "$(OSX_VERSION)" "5"
-GENERATE_WRAPPER = YES
-endif
-ifeq "$(OSX_VERSION)" "6"
-GENERATE_WRAPPER = NO
-endif
 
-ifeq "$(GENERATE_WRAPPER)" "YES"
-
-SWIG=/usr/bin/swig
-
 all: $(DYLIB) $(PERL_MODULE)
 
-$(WRAPPER) $(PERL_MODULE): DumpRenderTreeSupport.c $(DUMPRENDERTREE)
-	mkdir -p $(WRAPPER_DIR)
-	$(SWIG) -o $(WRAPPER) -outdir $(OUTPUT_DIR) -perl -module DumpRenderTreeSupport $<
-
-
-else
-
-
-all: $(DYLIB) $(PERL_MODULE)
-
 $(WRAPPER): DumpRenderTreeSupport_wrapPregenerated.c $(DUMPRENDERTREE)
 	mkdir -p $(WRAPPER_DIR)
 	cp DumpRenderTreeSupport_wrapPregenerated.c $(WRAPPER)
@@ -71,13 +50,8 @@
 $(PERL_MODULE): DumpRenderTreeSupportPregenerated.pm $(DUMPRENDERTREE)
 	cp DumpRenderTreeSupportPregenerated.pm $(PERL_MODULE)
 
-
-endif
-
-OS_X_SDK = $(if $(shell xcrun --show-sdk-path -sdk "macosx" 2> /dev/null),macosx, /)
-
 $(DYLIB): DumpRenderTreeSupport.c $(WRAPPER)
-	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, " -arch ", join(" -arch ", split(" ",$$ENV{ARCHS}))'` $^
+	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, " -arch ", join(" -arch ", split(" ",$$ENV{ARCHS}))'` $^
 
 IPHONE_SIMULATOR_NOTIFCATION_BUNDLE=$(OUTPUT_DIR)/lib/perl5/darwin-thread-multi-2level/auto/IPhoneSimulatorNotification/IPhoneSimulatorNotification.bundle
 IPHONE_SIMULATOR_NOTIFCATION_MODULE=$(OUTPUT_DIR)/lib/perl5/darwin-thread-multi-2level/IPhoneSimulatorNotification.pm
@@ -85,12 +59,10 @@
 all: $(IPHONE_SIMULATOR_NOTIFCATION_BUNDLE) $(IPHONE_SIMULATOR_NOTIFCATION_MODULE)
 
 $(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
-	(cd IPhoneSimulatorNotification && \
-		SDKROOT=$(OS_X_SDK) TOOLCHAINS= $(PERL) Makefile.PL INSTALL_BASE=$(OUTPUT_DIR) && \
-		make SDKROOT=$(OS_X_SDK) TOOLCHAINS= && \
-		make test && \
-		make install && \
-		make realclean)
+	cd IPhoneSimulatorNotification && SDKROOT=iphonesimulator perl Makefile.PL INSTALL_BASE=$(OUTPUT_DIR) 
+	make -C IPhoneSimulatorNotification test
+	make -C IPhoneSimulatorNotification install
+	make -C IPhoneSimulatorNotification realclean
 	# Touch the built perl module and its bundle since IPhoneSimulatorNotification.xs and Makefile.PL always have newer dates after building.
 	touch $(IPHONE_SIMULATOR_NOTIFCATION_BUNDLE) $(IPHONE_SIMULATOR_NOTIFCATION_MODULE)
 
@@ -108,6 +80,10 @@
 
 else
 
-all clean install installhdrs installsrc:
+install:
 
+all:
+
+clean:
+
 endif

Modified: trunk/Tools/Scripts/old-run-webkit-tests (163997 => 163998)


--- 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)
@@ -63,6 +63,7 @@
 use File::Temp;
 use FindBin;
 use Getopt::Long;
+use IO::Handle;
 use IPC::Open2;
 use IPC::Open3;
 use MIME::Base64;
@@ -126,11 +127,17 @@
 sub toWindowsPath($);
 sub validateSkippedArg($$;$);
 sub writeToFile($$);
+sub installAndLaunchDumpRenderTreeAppUsingNotification($$);
+sub openIPhoneSimulator();
+sub quitDumpRenderTreeAppUsingNotification();
+sub quitIPhoneSimulator();
+sub simulatorSessionUUID();
 
 # Argument handling
 my $addPlatformExceptions = 0;
 my @additionalPlatformDirectories = ();
 my $complexText = 0;
+my $iOSExpectedResultsDir = '';
 my $exitAfterNFailures = 0;
 my $exitAfterNCrashesOrTimeouts = 0;
 my $generateNewResults = isAppleMacWebKit() ? 1 : 0;
@@ -217,10 +224,35 @@
 
 my $realPlatform;
 
-my @macPlatforms = ("mac-leopard", "mac-snowleopard", "mac-lion", "mac");
+my $haveInstallediOSDumpRenderTreeAppOnce;
+
+my @iPhoneSimulatorPlatforms = qw(iphone-simulator);
+my @macPlatforms = ("mac-mountainlion", "mac");
 my @winPlatforms = ("win-xp", "win-vista", "win-7sp0", "win");
 
-if (isAppleMacWebKit()) {
+if (isIOSWebKit()) {
+    my $simulatorVersionHash = iPhoneSimulatorVersion();
+    my $simulatorVersion = "v" . $simulatorVersionHash->{major} . "." . $simulatorVersionHash->{minor};
+
+    sub versionFromPlatformSuffix {
+        my $version = shift;
+        $version =~ s/^-//;
+        $version =~ s/-/./g;
+        return "v$version";
+    }
+
+    foreach my $iphoneSimulatorPlatform (reverse @iPhoneSimulatorPlatforms) {
+        if (!$platform) {
+            $platform = $iphoneSimulatorPlatform;
+            next;
+        }
+        die "Invalid platform: $iphoneSimulatorPlatform" unless $iphoneSimulatorPlatform =~ /^iphone-simulator((-[0-9]+){2})$/;
+        last if eval(versionFromPlatformSuffix($1) . " lt $simulatorVersion");
+        $platform = $iphoneSimulatorPlatform;
+    }
+
+    $tolerance = 1.0;
+} elsif (isAppleMacWebKit()) {
     if (isSnowLeopard()) {
         $platform = "mac-snowleopard";
         $tolerance = 0.1;
@@ -272,11 +304,13 @@
 
 my $usage = <<EOF;
 Usage: $programName [options] [testdir|testpath ...]
+  --32-bit                        Run tests in 32-bit mode
   --add-platform-exceptions       Put new results for non-platform-specific failing tests into the platform-specific results directory
   --additional-platform-directory path/to/directory
                                   Look in the specified directory before looking in any of the default platform-specific directories
   --complex-text                  Use the complex text code path for all text (Mac OS X and Windows only)
   -c|--configuration config       Set DumpRenderTree build configuration
+  -e|--expected-results           Specify an alternate directory for expected results (iOS only)
   --gc-between-tests              Force garbage collection between each test
   -g|--guard-malloc               Enable Guard Malloc
   --exit-after-n-failures N       Exit after the first N failures (includes crashes) instead of running all tests
@@ -327,6 +361,7 @@
     'add-platform-exceptions' => \$addPlatformExceptions,
     'additional-platform-directory=s' => \@additionalPlatformDirectories,
     'complex-text' => \$complexText,
+    'expected-results|e=s' => \$iOSExpectedResultsDir,  # PLATFORM_IOS 
     'exit-after-n-failures=i' => \$exitAfterNFailures,
     'exit-after-n-crashes-or-timeouts=i' => \$exitAfterNCrashesOrTimeouts,
     'gc-between-tests' => \$gcBetweenTests,
@@ -416,6 +451,8 @@
 my $productDir = productDir();
 $productDir .= "/Programs" if isGtk();
 
+quitIPhoneSimulator() if isIOSWebKit();
+
 # Save the current directory before chaging it via chdirWebKit
 my $currentDir = cwd();
 chdirWebKit();
@@ -428,6 +465,9 @@
 }
 
 my $dumpToolName = $useWebKitTestRunner ? "WebKitTestRunner" : "DumpRenderTree";
+if (isIOSWebKit()) {
+    $dumpToolName = $useWebKitTestRunner ? "WebKitTestRunnerApp.app/WebKitTestRunnerApp" : "DumpRenderTree.app/DumpRenderTree";
+}
 
 if (isAppleWinWebKit()) {
     $dumpToolName .= "_debug" if configuration() eq "Debug_All";
@@ -442,8 +482,25 @@
 $imageDiffTool .= "_debug" if isCygwin() && configuration() eq "Debug_Cairo";
 die "can't find executable $imageDiffTool (looked in $productDir)\n" if $pixelTests && !-x $imageDiffTool;
 
-checkFrameworks() unless isCygwin();
+checkFrameworks() unless isCygwin() or isIOSWebKit();
 
+if (isIOSWebKit()) {
+    push @INC, $productDir . "/lib/perl5/darwin-thread-multi-2level";
+    require IPhoneSimulatorNotification;
+}
+
+if (isAppleMacWebKit()) {
+    push @INC, $productDir;
+    eval 'use DumpRenderTreeSupport;';
+}
+
+openIPhoneSimulator() if isIOSWebKit();
+
+if (isAppleMacWebKit()) {
+    push @INC, $productDir;
+    require DumpRenderTreeSupport;
+}
+
 my $layoutTestsName = "LayoutTests";
 my $testDirectory = File::Spec->rel2abs($layoutTestsName);
 my $expectedDirectory = $testDirectory;
@@ -453,13 +510,14 @@
 my @platformTestHierarchy = buildPlatformTestHierarchy(@platformResultHierarchy);
 
 $expectedDirectory = $ENV{"WebKitExpectedTestResultsDirectory"} if $ENV{"WebKitExpectedTestResultsDirectory"};
+$expectedDirectory = $iOSExpectedResultsDir if $iOSExpectedResultsDir && isIOSWebKit();
 
 $testResultsDirectory = File::Spec->catfile($currentDir, $testResultsDirectory);
 # $testResultsDirectory must be empty before testing.
 rmtree $testResultsDirectory;
 my $testResults = File::Spec->catfile($testResultsDirectory, "results.html");
 
-if (isAppleMacWebKit()) {
+if (isAppleMacWebKit() && !isIOSWebKit()) {
     print STDERR "Compiling Java tests\n";
     my $javaTestsDirectory = catdir($testDirectory, "java");
 
@@ -1097,6 +1155,8 @@
 
 !$isDumpToolOpen || die "Failed to close $dumpToolName.\n";
 
+quitIPhoneSimulator() if isIOSWebKit();
+
 $isHttpdOpen = !closeHTTPD();
 closeWebSocketServer();
 
@@ -1196,6 +1256,9 @@
   system "cygstart", $testResults if $launchSafari;
 } elsif (isWindows()) {
   system "start", $testResults if $launchSafari;
+} elsif (isIOSWebKit()) {
+  # Don't use run-safari, since it tries to load iOS frameworks in OS X Safari.
+  system "open", "-a", "Safari", $testResults if $launchSafari;
 } else {
   system "Tools/Scripts/run-safari", @configurationArgs, "-NSOpen", $testResults if $launchSafari;
 }
@@ -1287,6 +1350,118 @@
     close NEWFILE;
 }
 
+sub installAndLaunchDumpRenderTreeAppUsingNotification($$)
+{
+    my ($args, $cleanEnv) = @_;
+
+    my $iPhoneSimulatorNotification = new IPhoneSimulatorNotification;
+    $iPhoneSimulatorNotification->startObservingApplicationLaunchedNotification();
+
+    my $makeNSDictionaryFromHash = sub {
+        my ($dict) = @_;
+        my $result = NSMutableDictionary->alloc()->initWithCapacity_(scalar(keys %{$dict}));
+        for my $key (keys %{$dict}) {
+            $result->setObject_forKey_(NSString->stringWithCString_($dict->{$key}), NSString->stringWithCString_($key));
+        }
+        return $result->autorelease();
+    };
+
+    my $makeNSArrayFromArray = sub {
+        my ($array) = @_;
+        my $result = NSMutableArray->alloc()->initWithCapacity_(scalar(@{$array}));
+        for my $item (@{$array}) {
+            $result->addObject_(NSString->stringWithCString_($item));
+        }
+        return $result->autorelease();
+    };
+
+    my $deviceName = architecture() eq 'i386' ? "iPhone Retina (4-inch)" : "iPhone Retina (4-inch 64-bit)";
+
+    my $sdkRoot = `xcrun --sdk iphonesimulator --show-sdk-path`;
+    chomp $sdkRoot;
+
+    my $dict = {
+        applicationArguments => &$makeNSArrayFromArray($args),
+        applicationEnvironment => &$makeNSDictionaryFromHash($cleanEnv),
+        applicationIdentifier => NSString->stringWithCString_("org.webkit.DumpRenderTree"),
+        applicationPath => NSString->stringWithCString_("$productDir/DumpRenderTree.app"),
+        deviceInfo => NSString->stringWithCString_($deviceName),
+        sessionOwner => NSString->stringWithCString_($programName),
+        sessionUUID => NSString->stringWithCString_(simulatorSessionUUID()),
+        sdkRoot => NSString->stringWithCString_($sdkRoot),
+    };
+    $iPhoneSimulatorNotification->postStartSessionNotification($dict);
+
+    while (!$iPhoneSimulatorNotification->hasReceivedApplicationLaunchedNotification()) {
+        my $date = NSDate->alloc()->initWithTimeIntervalSinceNow_(0.1);
+        NSRunLoop->currentRunLoop->runUntilDate_($date);
+        $date->release();
+    }
+
+    print "DumpRenderTree has launched.\n";
+
+    $iPhoneSimulatorNotification->stopObservingApplicationLaunchedNotification();
+
+    return $iPhoneSimulatorNotification->applicationLaunchedApplicationPID();
+}
+
+sub openIPhoneSimulator()
+{
+    my $iPhoneSimulatorNotification = new IPhoneSimulatorNotification;
+    $iPhoneSimulatorNotification->startObservingReadyNotification();
+
+    my $deviceName = architecture() eq 'i386' ? "iPhone Retina (4-inch)" : "iPhone Retina (4-inch 64-bit)";
+
+    system "open", "-a", "iPhone Simulator", "--args", "-SessionOnLaunch", "NO", "-SimulateDevice", $deviceName;
+
+    die $! if exitStatus($?);
+
+    while (!$iPhoneSimulatorNotification->hasReceivedReadyNotification()) {
+        my $date = NSDate->alloc()->initWithTimeIntervalSinceNow_(0.1);
+        NSRunLoop->currentRunLoop->runUntilDate_($date);
+        $date->release();
+    }
+
+    $iPhoneSimulatorNotification->stopObservingReadyNotification();
+}
+
+sub quitDumpRenderTreeAppUsingNotification()
+{
+    my $iPhoneSimulatorNotification = new IPhoneSimulatorNotification;
+    $iPhoneSimulatorNotification->startObservingApplicationQuitNotification();
+
+    my $dict = {
+        sessionUUID => NSString->stringWithCString_(simulatorSessionUUID()),
+    };
+    $iPhoneSimulatorNotification->postEndSessionNotification($dict);
+
+    # FIXME: <rdar://problem/7443077> DumpRenderTree should exit without having to use kill -9 from run-webkit-tests
+    kill 9, $dumpToolPID;
+
+    my $timeoutCounter = 0;
+    while (!$iPhoneSimulatorNotification->hasReceivedApplicationQuitNotification()) {
+        my $date = NSDate->alloc()->initWithTimeIntervalSinceNow_(0.1);
+        NSRunLoop->currentRunLoop->runUntilDate_($date);
+        $date->release();
+        if (++$timeoutCounter >= 600) {
+            print STDERR "ERROR: Hang waiting for application quit notification. Did DumpRenderTree.app crash instead?\n";
+            last;
+        }
+    }
+
+    $iPhoneSimulatorNotification->stopObservingApplicationQuitNotification();
+}
+
+sub quitIPhoneSimulator()
+{
+    system "osascript", "-e", "tell application \"iPhone Simulator\" to quit";
+}
+
+sub simulatorSessionUUID()
+{
+    return "theAwesomeUniqueSessionIdentifierForDumpRenderTree";
+}
+
 # Break up a path into the directory (with slash) and base name.
 sub splitpath($)
 {
@@ -1379,8 +1554,10 @@
     return if !$pixelTests;
 
     my %CLEAN_ENV;
+    my @command = ($imageDiffTool);;
+    unshift(@command, 'xcrun', '-sdk', xcodeSDK(), 'sim') if willUseIOSSimulatorSDKWhenBuilding();
     $CLEAN_ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
-    $imageDiffToolPID = open2(\*DIFFIN, \*DIFFOUT, $imageDiffTool, launchWithEnv(@diffToolArgs, %CLEAN_ENV)) or die "unable to open $imageDiffTool\n";
+    $imageDiffToolPID = open2(\*DIFFIN, \*DIFFOUT, @command, launchWithEnv(@diffToolArgs, %CLEAN_ENV)) or die "unable to open $imageDiffTool\n";
     $isDiffToolOpen = 1;
 }
 
@@ -1403,7 +1580,7 @@
         $childErr = ">&STDERR";
     }
 
-    my @args = argumentsForConfiguration();
+    my @args = ('--sdk', xcodeSDK(), argumentsForConfiguration());
     my $buildProcess = open3($childIn, $childOut, $childErr, $perlInterpreter, File::Spec->catfile(qw(Tools Scripts), $dumpToolBuildScript), @args) or die "Failed to run build-dumprendertree";
     close($childIn);
     waitpid $buildProcess, 0;
@@ -1468,6 +1645,7 @@
         }
 
         $CLEAN_ENV{DYLD_FRAMEWORK_PATH} = $productDir;
+        $CLEAN_ENV{DYLD_LIBRARY_PATH} = $productDir;
         $CLEAN_ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc;
     } elsif (isCygwin()) {
         $CLEAN_ENV{HOMEDRIVE} = $ENV{'HOMEDRIVE'};
@@ -1489,7 +1667,7 @@
     }
 
     my @args = ($dumpTool, @toolArgs);
-    if (isAppleMacWebKit()) { 
+    if (isAppleMacWebKit() and !isIOSWebKit()) { 
         unshift @args, "arch", "-" . architecture();             
     }
 
@@ -1501,7 +1679,59 @@
 
     $CLEAN_ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
 
-    $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, launchWithEnv(@args, %CLEAN_ENV)) or die "Failed to start tool: $dumpTool\n";
+    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 </tmp/DumpRenderTree_*>;
+
+        if (!-e '/tmp/DumpRenderTree_IN') {
+            system('mkfifo', '/tmp/DumpRenderTree_IN') == 0 or die "Couldn't mkfifo DRT_IN";
+        }
+        open(\*OUT, "+> /tmp/DumpRenderTree_IN") or die "Couldn't open DRT_IN!";
+        OUT->autoflush(1);
+
+        if (!-e '/tmp/DumpRenderTree_OUT') {
+            system('mkfifo', '/tmp/DumpRenderTree_OUT') == 0 or die "Couldn't mkfifo DRT_OUT";
+        }
+        open(\*IN, "+< /tmp/DumpRenderTree_OUT") or die "Couldn't open DRT_OUT!";
+
+        if (!-e '/tmp/DumpRenderTree_ERROR') {
+            system('mkfifo', '/tmp/DumpRenderTree_ERROR') == 0 or die "Couldn't mkfifo DRT_ERROR";
+        }
+        open(\*ERROR, "+< /tmp/DumpRenderTree_ERROR") or die "Couldn't open DRT_ERROR!";
+
+        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};
+                ("-env", "$key=$val");
+            } keys %CLEAN_ENV;
+
+            my $archFlag = architecture() eq 'i386' ? '--arch=32' : '--arch=64';
+
+            local(*LAUNCHIN, *LAUNCHOUT);
+            open2(\*LAUNCHIN, \*LAUNCHOUT, $simPath, $archFlag, "LaunchApp", @env, "org.webkit.DumpRenderTree", @args) || die "$!";
+            my $stdout = <LAUNCHIN>;
+            if ($stdout =~ /Launched org.webkit.DumpRenderTree with process ID ([0-9]+)/) {
+                $dumpToolPID = $1;
+            } else {
+                die "Could not launch DumpRenderTree: $!";
+            }
+            close(LAUNCHOUT) || die "$!";
+            close(LAUNCHIN) || die "$!";
+        } else {
+            $dumpToolPID = installAndLaunchDumpRenderTreeAppUsingNotification(\@args, \%CLEAN_ENV);
+            $haveInstallediOSDumpRenderTreeAppOnce = 1;
+        }
+    } else {
+        $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, launchWithEnv(@args, %CLEAN_ENV)) or die "Failed to start tool: $dumpTool\n";
+    }
     $isDumpToolOpen = 1;
     $dumpToolCrashed = 0;
 }
@@ -1516,6 +1746,17 @@
 
     close IN;
     close OUT;
+    if (isIOSWebKit() && !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 </tmp/DumpRenderTree_*>;
+    }
     waitpid $dumpToolPID, 0;
     
     # check for WebCore counter leaks.
@@ -1532,10 +1773,18 @@
 {
     return 1 if $dumpToolCrashed;
     return 0 unless $isDumpToolOpen;
-    my $pid = waitpid(-1, WNOHANG);
-    return 1 if ($pid == $dumpToolPID);
+    if (isIOSWebKit()) {
+        my $count = kill 0, $dumpToolPID;
+        return 1 if !$count;
+    } else {
+        my $pid = waitpid(-1, WNOHANG);
+        return 1 if ($pid == $dumpToolPID);
+    }
 
-    return 0;
+    # On Mac OS X, crashing may be significantly delayed by crash reporter.
+    return 0 unless isAppleMacWebKit() or isIOSWebKit();
+
+    return DumpRenderTreeSupport::processIsCrashing($dumpToolPID);
 }
 
 sub configureAndOpenHTTPDIfNeeded()
@@ -1673,7 +1922,8 @@
         push @extraPlatforms, "mac-wk2" if $platform eq "win-wk2";
         push @extraPlatforms, qw(mac-lion mac);
     }
-  
+    push @extraPlatforms, @macPlatforms if isIOSWebKit();
+
     push @directories, map { catdir($platformBaseDirectory, $_) } @extraPlatforms;
     push @directories, $expectedDirectory;
 
@@ -2131,6 +2381,12 @@
         if ($platform eq "wincairo") {
             @platforms = $platform;
         }
+    } elsif ($platform =~ /^iphone-simulator-/) {
+        my $i;
+        for ($i = 0; $i < @iPhoneSimulatorPlatforms; $i++) {
+            last if $iPhoneSimulatorPlatforms[$i] eq $platform;
+        }
+        push @platforms, @iPhoneSimulatorPlatforms[$i..$#iPhoneSimulatorPlatforms];
     } elsif ($platform =~ /^gtk-/) {
         push @platforms, $platform;
         push @platforms, "gtk";

Modified: trunk/Tools/Scripts/webkitdirs.pm (163997 => 163998)


--- 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)
@@ -87,6 +87,7 @@
 my $sourceDir;
 my $currentSVNRevision;
 my $debugger;
+my $iPhoneSimulatorVersion;
 my $nmPath;
 my $osXVersion;
 my $generateDsym;
@@ -1154,6 +1155,31 @@
     return 0;
 }
 
+sub determineIPhoneSimulatorVersion()
+{
+    return if $iPhoneSimulatorVersion;
+
+    if (!isIOSWebKit()) {
+        $iPhoneSimulatorVersion = -1;
+        return;
+    }
+
+    my $version = `/usr/local/bin/psw_vers -productVersion`;
+    my @splitVersion = split(/\./, $version);
+    @splitVersion >= 2 or die "Invalid version $version";
+    $iPhoneSimulatorVersion = {
+            "major" => $splitVersion[0],
+            "minor" => $splitVersion[1],
+            "subminor" => defined($splitVersion[2] ? $splitVersion[2] : 0),
+    };
+}
+
+sub iPhoneSimulatorVersion()
+{
+    determineIPhoneSimulatorVersion();
+    return $iPhoneSimulatorVersion;
+}
+
 sub determineNmPath()
 {
     return if $nmPath;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to