Title: [164506] trunk/Tools
Revision
164506
Author
dfar...@apple.com
Date
2014-02-21 15:30:25 -0800 (Fri, 21 Feb 2014)

Log Message

Make old-run-webkit-tests work with iOS Simulator WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=128622

Reviewed by Simon Fraser.

With this change, we now have layout tests running in both DumpRenderTree
and WebKitTestRunner, with WebKit and WebKit2 used respectively in the iOS
simulator.

* Scripts/old-run-webkit-tests:
In general, make any specific reference to DumpRenderTree
able to refer to WebKitTestRunner wherever possible:
- Rename functions to remove DRT-specific naming.
- Name FIFOs after the tool that is being used.
-- Clean up FIFO creation code
Other necessary changes:
- Allow use of an ios-sim-wk2 platform.
- Clean up platform hierarchy creation where the simulator platform behavior differed.
* WebKitTestRunner/TestController.cpp:
Open FIFOs to get dumps out of the simulator as we do in DumpRenderTree.
(WTR::TestController::TestController):
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
Copy the injected bundle into the app bundle.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (164505 => 164506)


--- trunk/Tools/ChangeLog	2014-02-21 22:47:37 UTC (rev 164505)
+++ trunk/Tools/ChangeLog	2014-02-21 23:30:25 UTC (rev 164506)
@@ -1,3 +1,29 @@
+2014-02-20  David Farler  <dfar...@apple.com>
+
+        Make old-run-webkit-tests work with iOS Simulator WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=128622
+
+        Reviewed by Simon Fraser.
+
+        With this change, we now have layout tests running in both DumpRenderTree
+        and WebKitTestRunner, with WebKit and WebKit2 used respectively in the iOS
+        simulator.
+
+        * Scripts/old-run-webkit-tests:
+        In general, make any specific reference to DumpRenderTree
+        able to refer to WebKitTestRunner wherever possible:
+        - Rename functions to remove DRT-specific naming.
+        - Name FIFOs after the tool that is being used.
+        -- Clean up FIFO creation code
+        Other necessary changes:
+        - Allow use of an ios-sim-wk2 platform.
+        - Clean up platform hierarchy creation where the simulator platform behavior differed.
+        * WebKitTestRunner/TestController.cpp:
+        Open FIFOs to get dumps out of the simulator as we do in DumpRenderTree.
+        (WTR::TestController::TestController):
+        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+        Copy the injected bundle into the app bundle.
+
 2014-02-21  Joseph Pecoraro  <pecor...@apple.com>
 
         run-webkit-httpd fails to find httpd configuation file.

Modified: trunk/Tools/Scripts/old-run-webkit-tests (164505 => 164506)


--- trunk/Tools/Scripts/old-run-webkit-tests	2014-02-21 22:47:37 UTC (rev 164505)
+++ trunk/Tools/Scripts/old-run-webkit-tests	2014-02-21 23:30:25 UTC (rev 164506)
@@ -127,9 +127,9 @@
 sub toWindowsPath($);
 sub validateSkippedArg($$;$);
 sub writeToFile($$);
-sub installAndLaunchDumpRenderTreeAppUsingNotification($$);
+sub installAndLaunchDumpToolAppUsingNotification($$);
 sub openIPhoneSimulator();
-sub quitDumpRenderTreeAppUsingNotification();
+sub quitDumpToolUsingNotification();
 sub quitIPhoneSimulator();
 sub simulatorSessionUUID();
 
@@ -224,9 +224,9 @@
 
 my $realPlatform;
 
-my $haveInstallediOSDumpRenderTreeAppOnce;
+my $haveInstallediOSDumpToolAppOnce;
 
-my @iPhoneSimulatorPlatforms = qw(iphone-simulator);
+my @iPhoneSimulatorPlatforms = qw(ios-sim);
 my @macPlatforms = ("mac-mountainlion", "mac");
 my @winPlatforms = ("win-xp", "win-vista", "win-7sp0", "win");
 
@@ -309,7 +309,7 @@
   --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
+  -c|--configuration config       Set DumpRenderTree/WebKitTestRunner 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
@@ -325,7 +325,7 @@
   --[no-]show-results             Same as --[no-]launch-safari
   -l|--leaks                      Enable leaks checking
   --[no-]new-test-results         Generate results for new tests
-  --nthly n                       Restart DumpRenderTree every n tests (default: $testsPerDumpTool)
+  --nthly n                       Restart DumpRenderTree/WebKitTestRunner every n tests (default: $testsPerDumpTool)
   -p|--pixel-tests                Enable pixel tests
   --tolerance t                   Ignore image differences less than this percentage (default: $tolerance)
   --platform                      Override the detected platform to use for tests and results (default: $platform)
@@ -414,8 +414,11 @@
 }
 
 if ($useWebKitTestRunner) {
-    if (isAppleMacWebKit()) {
+    if (isIOSWebKit()) {
         $realPlatform = $platform;
+        $platform = "ios-sim-wk2";
+    } elsif (isAppleMacWebKit()) {
+        $realPlatform = $platform;
         $platform = "mac-wk2";
     } elsif (isAppleWinWebKit()) {
         $stripEditingCallbacks = 0 unless defined $stripEditingCallbacks;
@@ -1350,7 +1353,7 @@
     close NEWFILE;
 }
 
-sub installAndLaunchDumpRenderTreeAppUsingNotification($$)
+sub installAndLaunchDumpToolAppUsingNotification($$)
 {
     my ($args, $cleanEnv) = @_;
 
@@ -1380,11 +1383,20 @@
     my $sdkRoot = `xcrun --sdk iphonesimulator --show-sdk-path`;
     chomp $sdkRoot;
 
+    my $identifier = iOSDumpToolAppIdentifier();
+    my $applicationPath;
+
+    if ($useWebKitTestRunner) {
+        $applicationPath = "$productDir/WebKitTestRunnerApp.app";
+    } else {
+        $applicationPath = "$productDir/DumpRenderTree.app";
+    }
+
     my $dict = {
         applicationArguments => &$makeNSArrayFromArray($args),
         applicationEnvironment => &$makeNSDictionaryFromHash($cleanEnv),
-        applicationIdentifier => NSString->stringWithCString_("org.webkit.DumpRenderTree"),
-        applicationPath => NSString->stringWithCString_("$productDir/DumpRenderTree.app"),
+        applicationIdentifier => NSString->stringWithCString_($identifier),
+        applicationPath => NSString->stringWithCString_($applicationPath),
         deviceInfo => NSString->stringWithCString_($deviceName),
         sessionOwner => NSString->stringWithCString_($programName),
         sessionUUID => NSString->stringWithCString_(simulatorSessionUUID()),
@@ -1398,7 +1410,7 @@
         $date->release();
     }
 
-    print "DumpRenderTree has launched.\n";
+    print "$identifier has launched.\n";
 
     $iPhoneSimulatorNotification->stopObservingApplicationLaunchedNotification();
 
@@ -1412,7 +1424,7 @@
 
     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;
+    system "open", "-a", "iOS Simulator", "--args", "-SessionOnLaunch", "NO", "-SimulateDevice", $deviceName;
 
     die $! if exitStatus($?);
 
@@ -1425,7 +1437,7 @@
     $iPhoneSimulatorNotification->stopObservingReadyNotification();
 }
 
-sub quitDumpRenderTreeAppUsingNotification()
+sub quitDumpToolUsingNotification()
 {
     my $iPhoneSimulatorNotification = new IPhoneSimulatorNotification;
     $iPhoneSimulatorNotification->startObservingApplicationQuitNotification();
@@ -1444,7 +1456,7 @@
         NSRunLoop->currentRunLoop->runUntilDate_($date);
         $date->release();
         if (++$timeoutCounter >= 600) {
-            print STDERR "ERROR: Hang waiting for application quit notification. Did DumpRenderTree.app crash instead?\n";
+            print STDERR "ERROR: Hang waiting for application quit notification. Did $dumpToolName crash instead?\n";
             last;
         }
     }
@@ -1561,6 +1573,15 @@
     $isDiffToolOpen = 1;
 }
 
+sub unlinkFIFOs()
+{
+    if ($useWebKitTestRunner) {
+        unlink </tmp/WebKitTestRunner_*>;
+    } else {
+        unlink </tmp/DumpRenderTree_*>;
+    }
+}
+
 sub buildDumpTool($)
 {
     my ($dumpToolName) = @_;
@@ -1581,7 +1602,9 @@
     }
 
     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";
+    push @args, ('-target', 'WebKitTestRunnerApp') if $useWebKitTestRunner and $dumpToolName eq 'WebKitTestRunner';
+
+    my $buildProcess = open3($childIn, $childOut, $childErr, $perlInterpreter, File::Spec->catfile(qw(Tools Scripts), $dumpToolBuildScript), @args) or die "Failed to run build-$dumpToolName";
     close($childIn);
     waitpid $buildProcess, 0;
     my $buildResult = $?;
@@ -1596,6 +1619,11 @@
     }
 }
 
+sub iOSDumpToolAppIdentifier()
+{
+    return $useWebKitTestRunner ? "org.webkit.WebKitTestRunnerApp" : "org.webkit.DumpRenderTree";
+}
+
 sub openDumpTool()
 {
     return if $isDumpToolOpen;
@@ -1667,8 +1695,8 @@
     }
 
     my @args = ($dumpTool, @toolArgs);
-    if (isAppleMacWebKit() and !isIOSWebKit()) { 
-        unshift @args, "arch", "-" . architecture();             
+    if (isAppleMacWebKit() and !isIOSWebKit()) {
+        unshift @args, "arch", "-" . architecture();
     }
 
     if ($useWebKitTestRunner) {
@@ -1680,30 +1708,29 @@
     $CLEAN_ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
 
     if (isIOSWebKit()) {
-        # We're either running in the iOS Simulator or through SpringBoard, so FIFO it up!
+        unlinkFIFOs();
 
-        # Remove old FIFO files if DRT previously crashed.
-        unlink </tmp/DumpRenderTree_*>;
+        my $appIdentifier = iOSDumpToolAppIdentifier();
 
-        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);
+        my $fifoName = $useWebKitTestRunner ? "WebKitTestRunner" : "DumpRenderTree";
+        my $fifoOut = "/tmp/${fifoName}_OUT";
+        my $fifoIn = "/tmp/${fifoName}_IN";
+        my $fifoError = "/tmp/${fifoName}_ERROR";
 
-        if (!-e '/tmp/DumpRenderTree_OUT') {
-            system('mkfifo', '/tmp/DumpRenderTree_OUT') == 0 or die "Couldn't mkfifo DRT_OUT";
+        foreach my $fifo ($fifoOut, $fifoIn, $fifoError) {
+            if (! -e $fifo) {
+                system('mkfifo', $fifo) == 0 or die "Couldn't mkfifo $fifo";
+            }
         }
-        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!";
+        open(\*OUT, "+> $fifoIn") or die "Couldn't open $fifoIn!";
+        open(\*IN, "+< $fifoOut") or die "Couldn't open $fifoOut!";
+        open(\*ERROR, "+< $fifoError") or die "Couldn't open $fifoError!";
+        OUT->autoflush(1);
 
         shift @args; # remove the actual binary name
 
-        if ($haveInstallediOSDumpRenderTreeAppOnce) {
+        if ($haveInstallediOSDumpToolAppOnce) {
             my $simPath = `xcrun -sdk iphonesimulator -find sim`;
             chomp $simPath;
 
@@ -1716,18 +1743,18 @@
             my $archFlag = architecture() eq 'i386' ? '--arch=32' : '--arch=64';
 
             local(*LAUNCHIN, *LAUNCHOUT);
-            open2(\*LAUNCHIN, \*LAUNCHOUT, $simPath, $archFlag, "LaunchApp", @env, "org.webkit.DumpRenderTree", @args) || die "$!";
+            open2(\*LAUNCHIN, \*LAUNCHOUT, $simPath, $archFlag, "LaunchApp", @env, $appIdentifier, @args) || die "$!";
             my $stdout = <LAUNCHIN>;
-            if ($stdout =~ /Launched org.webkit.DumpRenderTree with process ID ([0-9]+)/) {
+            if ($stdout =~ /Launched $appIdentifier with process ID ([0-9]+)/) {
                 $dumpToolPID = $1;
             } else {
-                die "Could not launch DumpRenderTree: $!";
+                die "Could not launch $appIdentifier: $!";
             }
             close(LAUNCHOUT) || die "$!";
             close(LAUNCHIN) || die "$!";
         } else {
-            $dumpToolPID = installAndLaunchDumpRenderTreeAppUsingNotification(\@args, \%CLEAN_ENV);
-            $haveInstallediOSDumpRenderTreeAppOnce = 1;
+            $dumpToolPID = installAndLaunchDumpToolAppUsingNotification(\@args, \%CLEAN_ENV);
+            $haveInstallediOSDumpToolAppOnce = 1;
         }
     } else {
         $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, launchWithEnv(@args, %CLEAN_ENV)) or die "Failed to start tool: $dumpTool\n";
@@ -1747,18 +1774,16 @@
     close IN;
     close OUT;
     if (isIOSWebKit() && !dumpToolDidCrash()) {
-        if ($haveInstallediOSDumpRenderTreeAppOnce) {
+        if ($haveInstallediOSDumpToolAppOnce) {
             kill 9, $dumpToolPID;
         } else {
-            quitDumpRenderTreeAppUsingNotification();
+            quitDumpToolUsingNotification();
         }
 
-        # Since closing the FIFO doesn't actually terminate the DumpRenderTree process,
-        # do it ourselves.  See above FIXME.
-        unlink </tmp/DumpRenderTree_*>;
+        unlinkFIFOs();
     }
     waitpid $dumpToolPID, 0;
-    
+ 
     # check for WebCore counter leaks.
     if ($shouldCheckLeaks) {
         while (<ERROR>) {
@@ -2359,17 +2384,19 @@
     mkpath($platformTestDirectory) if ($platform eq "undefined" && !-d "$platformTestDirectory");
 
     my @platforms;
-    
+
     my $isMac = $platform =~ /^mac/;
     my $isWin = $platform =~ /^win/;
-    if ($isMac || $isWin) {
+    my $isIOS = $platform =~ /^ios/;
+    if ($isMac || $isWin || $isIOS) {
         my $effectivePlatform = $platform;
-        if ($platform eq "mac-wk2" || $platform eq "win-wk2") {
+        if ($platform eq "mac-wk2" || $platform eq "win-wk2" || $platform eq "ios-sim-wk2") {
             push @platforms, $platform;
             $effectivePlatform = $realPlatform;
         }
 
         my @platformList = $isMac ? @macPlatforms : @winPlatforms;
+        @platformList = @iPhoneSimulatorPlatforms if $isIOS;
         my $i;
         for ($i = 0; $i < @platformList; $i++) {
             last if $platformList[$i] eq $effectivePlatform;
@@ -2381,12 +2408,6 @@
         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";
@@ -2399,7 +2420,7 @@
         my $scoped = catdir($platformBaseDirectory, $platforms[$i]);
         push(@hierarchy, $scoped) if (-d $scoped);
     }
-    
+ 
     unshift @hierarchy, grep { -d $_ } @additionalPlatformDirectories;
 
     return @hierarchy;

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (164505 => 164506)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2014-02-21 22:47:37 UTC (rev 164505)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2014-02-21 23:30:25 UTC (rev 164506)
@@ -122,6 +122,16 @@
     , m_shouldUseAcceleratedDrawing(false)
     , m_shouldUseRemoteLayerTree(false)
 {
+
+#if PLATFORM(IOS)
+    int infd = open("/tmp/WebKitTestRunner_IN", O_RDWR);
+    dup2(infd, STDIN_FILENO);
+    int outfd = open("/tmp/WebKitTestRunner_OUT", O_RDWR);
+    dup2(outfd, STDOUT_FILENO);
+    int errfd = open("/tmp/WebKitTestRunner_ERROR", O_RDWR | O_NONBLOCK);
+    dup2(errfd, STDERR_FILENO);
+#endif
+
     initialize(argc, argv);
     controller = this;
     run();

Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (164505 => 164506)


--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2014-02-21 22:47:37 UTC (rev 164505)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2014-02-21 23:30:25 UTC (rev 164506)
@@ -37,6 +37,7 @@
 		29A8FCDD145F0337009045A6 /* JSAccessibilityTextMarkerRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29A8FCE1345E7021006AA5A6 /* JSAccessibilityTextMarkerRange.cpp */; };
 		29A8FCE2145F037B009045A6 /* AccessibilityTextMarkerRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29A8FCE1145F037B009045A6 /* AccessibilityTextMarkerRange.cpp */; };
 		29A8FCE5145F0464009045A6 /* AccessibilityTextMarkerRangeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29A8FCE4145F0464009045A6 /* AccessibilityTextMarkerRangeMac.mm */; };
+		2E34C90018B68808000067BB /* WebKitTestRunnerInjectedBundle.bundle in Resources */ = {isa = PBXBuildFile; fileRef = BC25186211D15D54002EBC01 /* WebKitTestRunnerInjectedBundle.bundle */; };
 		2E63ED8A1891AD7E002A7AFC /* AccessibilityControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E63ED751891ACE9002A7AFC /* AccessibilityControllerIOS.mm */; };
 		2E63ED8B1891AD7E002A7AFC /* AccessibilityTextMarkerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E63ED771891ACE9002A7AFC /* AccessibilityTextMarkerIOS.mm */; };
 		2E63ED8D1891AD7E002A7AFC /* ActivateFontsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E63ED791891ACE9002A7AFC /* ActivateFontsIOS.mm */; };
@@ -792,6 +793,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				2E34C90018B68808000067BB /* WebKitTestRunnerInjectedBundle.bundle in Resources */,
 				2EE52CED1890A9A80010ED21 /* InfoPlist.strings in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to