Diff
Modified: trunk/Tools/ChangeLog (202742 => 202743)
--- trunk/Tools/ChangeLog 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/ChangeLog 2016-07-01 17:08:38 UTC (rev 202743)
@@ -1,3 +1,53 @@
+2016-07-01 Alexey Proskuryakov <[email protected]>
+
+ Simplify LayoutTestRelay
+ https://bugs.webkit.org/show_bug.cgi?id=159353
+
+ Reviewed by Daniel Bates.
+
+ 1. Use UDID to pass the device from webkitpy to LayoutTestRelay, searching for it
+ by name and runtime makes no sense.
+ 2. Removed code to create devices, webkitpy always does this in advance.
+ 3. Don't create copies of testing apps - we can install the same one into
+ each simulator, now that we don't run multiple tester processes in a single simulator.
+ 4. Pass information on how to find I/O pipes via environment, not via Info.plist.
+ 5. Removed code that kept testing apps alive in the background.
+ 6. Slightly updated coding style in functions that I touched.
+
+ * LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h:
+ Updated for what we acually use at this point.
+
+ * LayoutTestRelay/LayoutTestRelay/LTRelayController.h:
+ * LayoutTestRelay/LayoutTestRelay/LTRelayController.m:
+ (-[LTRelayController initWithDevice:productDir:appPath:deviceUDID:dumpToolArguments:]):
+ (-[LTRelayController ipcIdentifier]):
+ (-[LTRelayController processName]):
+ (-[LTRelayController didReceiveStdoutData:]):
+ (-[LTRelayController didCrashWithMessage:]):
+ (-[LTRelayController installApp]):
+ (-[LTRelayController _environmentVariables]):
+ (-[LTRelayController launchApp]):
+ (-[LTRelayController start]):
+ (-[LTRelayController initWithDevice:productDir:appPath:identifierSuffix:dumpToolArguments:]): Deleted.
+ (-[LTRelayController uniqueAppPath]): Deleted.
+ (-[LTRelayController uniqueAppURL]): Deleted.
+ (-[LTRelayController uniqueAppIdentifier]): Deleted.
+ (-[LTRelayController createUniqueApp]): Deleted.
+ * LayoutTestRelay/LayoutTestRelay/main.m:
+ (usage):
+ (getRequiredStringArgument):
+ (main):
+ (getTestingSimDevice): Deleted.
+ * Scripts/webkitpy/port/driver.py:
+ (IOSSimulatorDriver.cmd_line):
+ * WebKitTestRunner/ios/TestControllerIOS.mm:
+ (WTR::TestController::platformInitialize):
+ * WebKitTestRunner/ios/mainIOS.mm:
+ (-[WebKitTestRunnerApp applicationDidEnterBackground:]):
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (dumpRenderTree):
+ (-[DumpRenderTree applicationDidEnterBackground:]):
+
2016-07-01 Konstantin Tokarev <[email protected]>
[cmake] Build TestNetscapePlugin only if NPAPI is enabled.
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (202742 => 202743)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2016-07-01 17:08:38 UTC (rev 202743)
@@ -1259,10 +1259,10 @@
void dumpRenderTree(int argc, const char *argv[])
{
#if PLATFORM(IOS)
- 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];
+ const char* identifier = getenv("IPC_IDENTIFIER");
+ const char *stdinPath = [[NSString stringWithFormat:@"/tmp/%s_IN", identifier] UTF8String];
+ const char *stdoutPath = [[NSString stringWithFormat:@"/tmp/%s_OUT", identifier] UTF8String];
+ const char *stderrPath = [[NSString stringWithFormat:@"/tmp/%s_ERROR", identifier] UTF8String];
int infd = open(stdinPath, O_RDWR);
dup2(infd, STDIN_FILENO);
@@ -1354,25 +1354,7 @@
- (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);
- }
- });
+ RELEASE_ASSERT_NOT_REACHED();
}
- (void)_webThreadEventLoopHasRun
Modified: trunk/Tools/LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h (202742 => 202743)
--- trunk/Tools/LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h 2016-07-01 17:08:38 UTC (rev 202743)
@@ -35,32 +35,14 @@
#define kSimDeviceLaunchApplicationArguments @"arguments"
#define kSimDeviceLaunchApplicationEnvironment @"environment"
-typedef NS_ENUM(NSUInteger, SimDeviceState) {
- SimDeviceStateCreating = 0,
-};
-
-@interface SimDeviceType : NSObject
-+ (NSDictionary *)supportedDeviceTypesByIdentifier;
-@property (readonly, copy) NSString *identifier;
-@end
-
-@interface SimRuntime : NSObject
-+ (NSDictionary *)supportedRuntimesByIdentifier;
-@end
-
@interface SimDevice : NSObject
- (BOOL)installApplication:(NSURL *)installURL withOptions:(NSDictionary *)options error:(NSError **)error;
- (pid_t)launchApplicationWithID:(NSString *)bundleID options:(NSDictionary *)options error:(NSError **)error;
-@property (readonly, retain) SimDeviceType *deviceType;
-@property (readonly, retain) SimRuntime *runtime;
-@property (readonly, assign) SimDeviceState state;
-@property (readonly, copy) NSString *name;
@end
@interface SimDeviceSet : NSObject
+ (SimDeviceSet *)defaultSet;
-- (SimDevice *)createDeviceWithType:(SimDeviceType *)deviceType runtime:(SimRuntime *)runtime name:(NSString *)name error:(NSError **)error;
-@property (readonly, copy) NSArray *devices;
+@property (readonly, copy) NSDictionary *devicesByUDID;
@end
Modified: trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.h (202742 => 202743)
--- trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.h 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.h 2016-07-01 17:08:38 UTC (rev 202743)
@@ -32,7 +32,7 @@
@class SimDevice;
@interface LTRelayController : NSObject <LTRelayDelegate>
-- (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath identifierSuffix:(NSString *)suffix dumpToolArguments:(NSArray *)arguments;
+- (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments;
- (void)start;
- (void)finish;
@end
Modified: trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m (202742 => 202743)
--- trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m 2016-07-01 17:08:38 UTC (rev 202743)
@@ -33,12 +33,10 @@
@property (readonly, strong) dispatch_source_t standardInputDispatchSource;
@property (readonly, strong) NSFileHandle *standardOutput;
@property (readonly, strong) NSFileHandle *standardError;
-@property (readonly, strong) NSString *uniqueAppPath;
-@property (readonly, strong) NSString *uniqueAppIdentifier;
-@property (readonly, strong) NSURL *uniqueAppURL;
-@property (readonly, strong) NSString *originalAppIdentifier;
-@property (readonly, strong) NSString *originalAppPath;
-@property (readonly, strong) NSString *identifierSuffix;
+@property (readonly, strong) NSString *ipcIdentifier;
+@property (readonly, strong) NSString *appBundleIdentifier;
+@property (readonly, strong) NSString *appPath;
+@property (readonly, strong) NSUUID *deviceUDID;
@property (readonly, strong) NSArray *dumpToolArguments;
@property (readonly, strong) NSString *productDir;
@property (strong) SimDevice *device;
@@ -49,14 +47,14 @@
@implementation LTRelayController
-- (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath identifierSuffix:(NSString *)suffix dumpToolArguments:(NSArray *)arguments
+- (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments
{
if ((self = [super init])) {
_device = device;
_productDir = productDir;
- _originalAppPath = appPath;
- _originalAppIdentifier = [NSDictionary dictionaryWithContentsOfFile:[_originalAppPath stringByAppendingPathComponent:@"Info.plist"]][(NSString *)kCFBundleIdentifierKey];
- _identifierSuffix = suffix;
+ _appPath = appPath;
+ _appBundleIdentifier = [[NSBundle bundleWithPath:appPath] bundleIdentifier];
+ _deviceUDID = udid;
_dumpToolArguments = arguments;
_standardInputDispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, STDIN_FILENO, 0, dispatch_get_main_queue());
_standardOutput = [NSFileHandle fileHandleWithStandardOutput];
@@ -78,29 +76,20 @@
}
});
- _relay = [[LTPipeRelay alloc] initWithPrefix:[@"/tmp" stringByAppendingPathComponent:[self uniqueAppIdentifier]]];
+ _relay = [[LTPipeRelay alloc] initWithPrefix:[@"/tmp" stringByAppendingPathComponent:self.ipcIdentifier]];
[_relay setRelayDelegate:self];
}
return self;
}
-- (NSString *)uniqueAppPath
+- (NSString *)ipcIdentifier
{
- return [[self originalAppPath] stringByReplacingOccurrencesOfString:@".app" withString:[NSString stringWithFormat:@"%@.app", [self identifierSuffix]]];
+ return [NSString stringWithFormat:@"%@-%@", self.appBundleIdentifier, self.deviceUDID.UUIDString];
}
-- (NSURL *)uniqueAppURL
-{
- return [NSURL fileURLWithPath:[self uniqueAppPath]];
-}
-
-- (NSString *)uniqueAppIdentifier
-{
- return [[self originalAppIdentifier] stringByAppendingString:[self identifierSuffix]];
-}
- (NSString *)processName
{
- return [[[self originalAppIdentifier] componentsSeparatedByString:@"."] lastObject];
+ return [self.appBundleIdentifier componentsSeparatedByString:@"."].lastObject;
}
- (void)didReceiveStdoutData:(NSData *)data
@@ -151,35 +140,16 @@
exit(EXIT_FAILURE);
}
-- (void)createUniqueApp
+- (void)installApp
{
- NSError *error;
- NSFileManager *fileManager = [NSFileManager defaultManager];
- [fileManager removeItemAtPath:[self uniqueAppPath] error:&error];
- error = nil;
-
- [fileManager copyItemAtPath:[self originalAppPath] toPath:[self uniqueAppPath] error:&error];
- if (error) {
- NSLog(@"Couldn't copy %@ to %@: %@", [self originalAppPath], [self uniqueAppPath], [error description]);
- exit(EXIT_FAILURE);
- }
-
- NSString *infoPlistPath = [[self uniqueAppPath] stringByAppendingPathComponent:@"Info.plist"];
- NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile:infoPlistPath];
- [plist setValue:[self uniqueAppIdentifier] forKey:(NSString *)kCFBundleIdentifierKey];
- BOOL written = [plist writeToFile:infoPlistPath atomically:YES];
- if (!written) {
- NSLog(@"Couldn't write unique app plist at %@", infoPlistPath);
- exit(EXIT_FAILURE);
- }
-
NSDictionary *installOptions = @{
- (NSString *)kCFBundleIdentifierKey: [self uniqueAppIdentifier],
+ (NSString *)kCFBundleIdentifierKey: self.appBundleIdentifier,
};
- [[self device] installApplication:[self uniqueAppURL] withOptions:installOptions error:&error];
+ NSError *error = nil;
+ [self.device installApplication:[NSURL fileURLWithPath:self.appPath] withOptions:installOptions error:&error];
if (error) {
- NSLog(@"Couldn't install %@: %@", [[self uniqueAppURL] path], [error description]);
+ NSLog(@"Couldn't install %@: %@", self.appPath, error.description);
exit(EXIT_FAILURE);
}
}
@@ -207,6 +177,7 @@
NSString *productDirectory = [self productDir];
NSMutableDictionary *dictionary = [@{
+ @"IPC_IDENTIFIER": self.ipcIdentifier,
@"DYLD_FRAMEWORK_PATH": productDirectory,
@"__XPC_DYLD_FRAMEWORK_PATH": productDirectory,
@"DYLD_LIBRARY_PATH": productDirectory,
@@ -236,10 +207,10 @@
};
NSError *error;
- pid_t pid = [[self device] launchApplicationWithID:[self uniqueAppIdentifier] options:launchOptions error:&error];
+ pid_t pid = [self.device launchApplicationWithID:self.appBundleIdentifier options:launchOptions error:&error];
if (pid < 0) {
- NSLog(@"Couldn't launch unique app instance %@: %@", [self uniqueAppIdentifier], [error description]);
+ NSLog(@"Couldn't launch %@: %@", self.appBundleIdentifier, error.description);
exit(EXIT_FAILURE);
}
@@ -257,7 +228,7 @@
- (void)start
{
- [self createUniqueApp];
+ [self installApp];
[[self relay] setup];
[self launchApp];
[[self relay] connect];
Modified: trunk/Tools/LayoutTestRelay/LayoutTestRelay/main.m (202742 => 202743)
--- trunk/Tools/LayoutTestRelay/LayoutTestRelay/main.m 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/LayoutTestRelay/LayoutTestRelay/main.m 2016-07-01 17:08:38 UTC (rev 202743)
@@ -32,42 +32,15 @@
void usage()
{
NSString *helpText = @"LayoutTestRelay: run a dump tool in the simulator. Not for direct consumption.\n"
- "Usage: LayoutTestRelay [-h] [options] -- [dump tool arguments]\n"
- "Required options:\n"
- " -app <app_path> Path to the built iOS .app bundle directory.\n"
- " -runtime <identifier> iOS Simulator Runtime identifier (see `xcrun -sdk iphonesimulator simctl`)\n"
- " -deviceType <identifier> iOS Simulator device identifier (see simctl).\n"
- " -suffix <text> Used to create multiple unique instances when installing to the simulator.\n"
- " -productDir <dir> /path/to/WebKitBuild/{configuration}-{short platform}.\n";
+ "Usage: LayoutTestRelay [-h] [options] -- [dump tool arguments]\n"
+ "Required options:\n"
+ " -udid <identifier> Simulator device identifier\n"
+ " -app <app_path> Path to the built iOS .app bundle directory.\n"
+ " -productDir <dir> /path/to/WebKitBuild/{configuration}-{short platform}.\n";
fprintf(stderr, "%s\n", [helpText UTF8String]);
}
-SimDevice *getTestingSimDevice(SimDeviceType *deviceType, SimRuntime *runtime, NSString *suffix)
-{
- NSString *deviceName = [[[[deviceType identifier] componentsSeparatedByString:@"."] lastObject] stringByReplacingOccurrencesOfString:@"-" withString:@" "];
- deviceName = [NSString stringWithFormat:@"%@%@%@", deviceName, @" WebKit Tester", suffix];
-
- for (SimDevice *device in [[SimDeviceSet defaultSet] devices]) {
- if ([[device name] isEqualToString:deviceName] && [[device deviceType] isEqualTo:deviceType] && [[device runtime] isEqualTo:runtime])
- return device;
- }
-
- NSError *error;
- SimDevice *device = [[SimDeviceSet defaultSet] createDeviceWithType:deviceType runtime:runtime name:deviceName error:&error];
-
- if (error) {
- NSLog(@"Couldn't create device: %@", [error description]);
- return nil;
- }
-
- while ([device state] == SimDeviceStateCreating)
- sleep(1);
-
- return device;
-}
-
-
NSString *getRequiredStringArgument(NSString *parameter)
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
@@ -117,28 +90,19 @@
exit(EXIT_FAILURE);
}
}
+
+ NSUUID *udid = [[NSUUID alloc] initWithUUIDString:getRequiredStringArgument(@"udid")];
NSString *appPath = getRequiredStringArgument(@"app");
- NSString *runtimeIdentifier = getRequiredStringArgument(@"runtime");
- SimRuntime *runtime = [SimRuntime supportedRuntimesByIdentifier][runtimeIdentifier];
- if (!runtime) {
- NSLog(@"There is no supported runtime \"%@\"", runtimeIdentifier);
- exit(EXIT_FAILURE);
- }
+ NSString *productDirectory = getRequiredStringArgument(@"productDir");
+ NSArray *dumpToolArguments = getDumpToolArguments();
- NSString *deviceTypeIdentifier = getRequiredStringArgument(@"deviceType");
- SimDeviceType *deviceType = [SimDeviceType supportedDeviceTypesByIdentifier][deviceTypeIdentifier];
- if (!deviceType) {
- NSLog(@"There is no supported device type \"%@\"", deviceTypeIdentifier);
+ SimDevice *device = [SimDeviceSet.defaultSet.devicesByUDID objectForKey:udid];
+ if (!device) {
+ NSLog(@"Device %@ couldn't be found", udid);
exit(EXIT_FAILURE);
}
- NSString *suffix = getRequiredStringArgument(@"suffix");
- NSString *productDir = getRequiredStringArgument(@"productDir");
- NSArray *dumpToolArguments = getDumpToolArguments();
-
- SimDevice *device = getTestingSimDevice(deviceType, runtime, suffix);
-
- relayController = [[LTRelayController alloc] initWithDevice:device productDir:productDir appPath:appPath identifierSuffix:suffix dumpToolArguments:dumpToolArguments];
+ relayController = [[LTRelayController alloc] initWithDevice:device productDir:productDirectory appPath:appPath deviceUDID:udid dumpToolArguments:dumpToolArguments];
[relayController start];
atexit(finish);
Modified: trunk/Tools/Scripts/webkitpy/port/driver.py (202742 => 202743)
--- trunk/Tools/Scripts/webkitpy/port/driver.py 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/Scripts/webkitpy/port/driver.py 2016-07-01 17:08:38 UTC (rev 202743)
@@ -594,9 +594,7 @@
dump_tool_args = cmd[1:]
product_dir = self._port._build_path()
relay_args = [
- '-runtime', self._port.simulator_runtime.identifier,
- '-deviceType', self._port.simulator_device_type.identifier,
- '-suffix', str(self._worker_number),
+ '-udid', self._port.testing_device(self._worker_number).udid,
'-productDir', product_dir,
'-app', dump_tool,
]
Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (202742 => 202743)
--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2016-07-01 17:08:38 UTC (rev 202743)
@@ -46,10 +46,10 @@
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];
+ const char* identifier = getenv("IPC_IDENTIFIER");
+ const char *stdinPath = [[NSString stringWithFormat:@"/tmp/%s_IN", identifier] UTF8String];
+ const char *stdoutPath = [[NSString stringWithFormat:@"/tmp/%s_OUT", identifier] UTF8String];
+ const char *stderrPath = [[NSString stringWithFormat:@"/tmp/%s_ERROR", identifier] UTF8String];
int infd = open(stdinPath, O_RDWR);
dup2(infd, STDIN_FILENO);
Modified: trunk/Tools/WebKitTestRunner/ios/mainIOS.mm (202742 => 202743)
--- trunk/Tools/WebKitTestRunner/ios/mainIOS.mm 2016-07-01 17:06:57 UTC (rev 202742)
+++ trunk/Tools/WebKitTestRunner/ios/mainIOS.mm 2016-07-01 17:08:38 UTC (rev 202743)
@@ -52,24 +52,7 @@
- (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);
- }
- });
+ RELEASE_ASSERT_NOT_REACHED();
}
- (void)_handleHIDEvent:(IOHIDEventRef)event