Diff
Modified: trunk/Tools/ChangeLog (171686 => 171687)
--- trunk/Tools/ChangeLog 2014-07-28 19:59:43 UTC (rev 171686)
+++ trunk/Tools/ChangeLog 2014-07-28 20:03:45 UTC (rev 171687)
@@ -1,5 +1,24 @@
2014-07-24 David Farler <dfar...@apple.com>
+ Allow for multiple DumpRenderTree and WebKitTestRunner instances in the iOS Simulator
+ https://bugs.webkit.org/show_bug.cgi?id=135272
+
+ Reviewed by Simon Fraser.
+
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (dumpRenderTree): Remove hard-coding of FIFO paths.
+ (-[DumpRenderTree applicationDidEnterBackground:]): Create background task.
+ (DumpRenderTreeMain): Set DumpRenderTree as UIApplication delegate.
+ * DumpRenderTree/mac/DumpRenderTreeMac.h: bgTask ivar.
+ * Scripts/old-run-webkit-tests: Update FIFO paths for ORWT.
+ * WebKitTestRunner/TestController.cpp: Remove hard-coding of FIFO paths.
+ * WebKitTestRunner/ios/TestControllerIOS.mm: Move dup2 calls to platformInitialize
+ * WebKitTestRunner/ios/mainIOS.mm: bgTask ivar.
+ (-[WebKitTestRunnerApp applicationDidEnterBackground:]): Create background task.
+ (main): Set WebKitTestRunnerApp as UIApplication delegate.
+
+2014-07-24 David Farler <dfar...@apple.com>
+
ImageDiff builds for the simulator when running iOS layout tests
https://bugs.webkit.org/show_bug.cgi?id=135270
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (171686 => 171687)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2014-07-28 19:59:43 UTC (rev 171686)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2014-07-28 20:03:45 UTC (rev 171687)
@@ -1119,11 +1119,16 @@
void dumpRenderTree(int argc, const char *argv[])
{
#if PLATFORM(IOS)
- int infd = open("/tmp/DumpRenderTree_IN", O_RDWR);
+ NSString *identifier = [[NSBundle mainBundle] bundleIdentifier];
+ const char *stdinPath = [[NSString stringWithFormat:@"/tmp/%@_IN", identifier] UTF8String];
+ const char *stdoutPath = [[NSString stringWithFormat:@"/tmp/%@_OUT", identifier] UTF8String];
+ const char *stderrPath = [[NSString stringWithFormat:@"/tmp/%@_ERROR", identifier] UTF8String];
+
+ int infd = open(stdinPath, O_RDWR);
dup2(infd, STDIN_FILENO);
- int outfd = open("/tmp/DumpRenderTree_OUT", O_RDWR);
+ int outfd = open(stdoutPath, O_RDWR);
dup2(outfd, STDOUT_FILENO);
- int errfd = open("/tmp/DumpRenderTree_ERROR", O_RDWR | O_NONBLOCK);
+ int errfd = open(stderrPath, O_RDWR | O_NONBLOCK);
dup2(errfd, STDERR_FILENO);
#endif
@@ -1225,6 +1230,29 @@
});
}
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ /* Apps will get suspended or killed some time after entering the background state but we want to be able to run multiple copies of DumpRenderTree. Periodically check to see if our remaining background time dips below a threshold and create a new background task.
+ */
+ void (^expirationHandler)() = ^ {
+ [application endBackgroundTask:backgroundTaskIdentifier];
+ backgroundTaskIdentifier = UIBackgroundTaskInvalid;
+ };
+
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+
+ NSTimeInterval timeRemaining;
+ while (true) {
+ timeRemaining = [application backgroundTimeRemaining];
+ if (timeRemaining <= 10.0 || backgroundTaskIdentifier == UIBackgroundTaskInvalid) {
+ [application endBackgroundTask:backgroundTaskIdentifier];
+ backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:expirationHandler];
+ }
+ sleep(5);
+ }
+ });
+}
+
// The test can end in response to a delegate callback while there are still methods queued on the Web Thread.
// If we do not ensure the Web Thread has been run, the callback can be done on a WebView that no longer exists.
// To avoid this, _waitForWebThread dispatches a call to the WebThread event loop, actively processing the delegate
@@ -1262,7 +1290,7 @@
#else
_argc = argc;
_argv = argv;
- UIApplicationMain(argc, (char**)argv, @"DumpRenderTree", nil);
+ UIApplicationMain(argc, (char**)argv, @"DumpRenderTree", @"DumpRenderTree");
#endif
[WebCoreStatistics garbageCollectJavaScriptObjects];
[WebCoreStatistics emptyCache]; // Otherwise SVGImages trigger false positives for Frame/Node counts
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTreeMac.h (171686 => 171687)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTreeMac.h 2014-07-28 19:59:43 UTC (rev 171686)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTreeMac.h 2014-07-28 20:03:45 UTC (rev 171687)
@@ -77,6 +77,7 @@
#if PLATFORM(IOS) && defined(__OBJC__)
@interface DumpRenderTree : UIApplication {
BOOL _hasFlushedWebThreadRunQueue;
+ UIBackgroundTaskIdentifier backgroundTaskIdentifier;
}
- (void)_waitForWebThread;
Modified: trunk/Tools/Scripts/old-run-webkit-tests (171686 => 171687)
--- trunk/Tools/Scripts/old-run-webkit-tests 2014-07-28 19:59:43 UTC (rev 171686)
+++ trunk/Tools/Scripts/old-run-webkit-tests 2014-07-28 20:03:45 UTC (rev 171687)
@@ -1506,11 +1506,8 @@
sub unlinkFIFOs()
{
- if ($useWebKitTestRunner) {
- unlink </tmp/WebKitTestRunner_*>;
- } else {
- unlink </tmp/DumpRenderTree_*>;
- }
+ my $identifier = iOSDumpToolAppIdentifier();
+ unlink glob "/tmp/${identifier}_*";
}
sub buildDumpTool($)
@@ -1643,10 +1640,9 @@
my $appIdentifier = iOSDumpToolAppIdentifier();
- my $fifoName = $useWebKitTestRunner ? "WebKitTestRunner" : "DumpRenderTree";
- my $fifoOut = "/tmp/${fifoName}_OUT";
- my $fifoIn = "/tmp/${fifoName}_IN";
- my $fifoError = "/tmp/${fifoName}_ERROR";
+ my $fifoOut = "/tmp/${appIdentifier}_OUT";
+ my $fifoIn = "/tmp/${appIdentifier}_IN";
+ my $fifoError = "/tmp/${appIdentifier}_ERROR";
foreach my $fifo ($fifoOut, $fifoIn, $fifoError) {
if (! -e $fifo) {
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (171686 => 171687)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2014-07-28 19:59:43 UTC (rev 171686)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2014-07-28 20:03:45 UTC (rev 171687)
@@ -124,16 +124,6 @@
, m_shouldUseRemoteLayerTree(false)
, m_shouldLogHistoryClientCallbacks(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/ios/TestControllerIOS.mm (171686 => 171687)
--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2014-07-28 19:59:43 UTC (rev 171686)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2014-07-28 20:03:45 UTC (rev 171687)
@@ -27,6 +27,7 @@
#import "TestController.h"
#import "CrashReporterInfo.h"
+#import <Foundation/Foundation.h>
#import "PlatformWebView.h"
#import "TestInvocation.h"
#import <WebKit/WKStringCF.h>
@@ -40,6 +41,17 @@
void TestController::platformInitialize()
{
+ NSString *identifier = [[NSBundle mainBundle] bundleIdentifier];
+ const char *stdinPath = [[NSString stringWithFormat:@"/tmp/%@_IN", identifier] UTF8String];
+ const char *stdoutPath = [[NSString stringWithFormat:@"/tmp/%@_OUT", identifier] UTF8String];
+ const char *stderrPath = [[NSString stringWithFormat:@"/tmp/%@_ERROR", identifier] UTF8String];
+
+ int infd = open(stdinPath, O_RDWR);
+ dup2(infd, STDIN_FILENO);
+ int outfd = open(stdoutPath, O_RDWR);
+ dup2(outfd, STDOUT_FILENO);
+ int errfd = open(stderrPath, O_RDWR | O_NONBLOCK);
+ dup2(errfd, STDERR_FILENO);
}
void TestController::platformDestroy()
Modified: trunk/Tools/WebKitTestRunner/ios/mainIOS.mm (171686 => 171687)
--- trunk/Tools/WebKitTestRunner/ios/mainIOS.mm 2014-07-28 19:59:43 UTC (rev 171686)
+++ trunk/Tools/WebKitTestRunner/ios/mainIOS.mm 2014-07-28 20:03:45 UTC (rev 171687)
@@ -31,7 +31,9 @@
static int _argc;
static const char **_argv;
-@interface WebKitTestRunnerApp : UIApplication
+@interface WebKitTestRunnerApp : UIApplication {
+ UIBackgroundTaskIdentifier backgroundTaskIdentifier;
+}
@end
@implementation WebKitTestRunnerApp
@@ -46,6 +48,29 @@
[self performSelectorOnMainThread:@selector(_runTestController) withObject:nil waitUntilDone:NO];
}
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ /* Apps will get suspended or killed some time after entering the background state but we want to be able to run multiple copies of DumpRenderTree. Periodically check to see if our remaining background time dips below a threshold and create a new background task.
+ */
+ void (^expirationHandler)() = ^ {
+ [application endBackgroundTask:backgroundTaskIdentifier];
+ backgroundTaskIdentifier = UIBackgroundTaskInvalid;
+ };
+
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+
+ NSTimeInterval timeRemaining;
+ while (true) {
+ timeRemaining = [application backgroundTimeRemaining];
+ if (timeRemaining <= 10.0 || backgroundTaskIdentifier == UIBackgroundTaskInvalid) {
+ [application endBackgroundTask:backgroundTaskIdentifier];
+ backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:expirationHandler];
+ }
+ sleep(5);
+ }
+ });
+}
+
@end
int main(int argc, const char* argv[])
@@ -53,6 +78,6 @@
_argc = argc;
_argv = argv;
- UIApplicationMain(argc, (char**)argv, NSStringFromClass([WebKitTestRunnerApp class]), nil);
+ UIApplicationMain(argc, (char**)argv, @"WebKitTestRunnerApp", @"WebKitTestRunnerApp");
return 0;
}