Changeset 202743 in webkit
- Timestamp:
- Jul 1, 2016 10:08:38 AM (8 years ago)
- Location:
- trunk/Tools
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r202739 r202743 1 2016-07-01 Alexey Proskuryakov <ap@apple.com> 2 3 Simplify LayoutTestRelay 4 https://bugs.webkit.org/show_bug.cgi?id=159353 5 6 Reviewed by Daniel Bates. 7 8 1. Use UDID to pass the device from webkitpy to LayoutTestRelay, searching for it 9 by name and runtime makes no sense. 10 2. Removed code to create devices, webkitpy always does this in advance. 11 3. Don't create copies of testing apps - we can install the same one into 12 each simulator, now that we don't run multiple tester processes in a single simulator. 13 4. Pass information on how to find I/O pipes via environment, not via Info.plist. 14 5. Removed code that kept testing apps alive in the background. 15 6. Slightly updated coding style in functions that I touched. 16 17 * LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h: 18 Updated for what we acually use at this point. 19 20 * LayoutTestRelay/LayoutTestRelay/LTRelayController.h: 21 * LayoutTestRelay/LayoutTestRelay/LTRelayController.m: 22 (-[LTRelayController initWithDevice:productDir:appPath:deviceUDID:dumpToolArguments:]): 23 (-[LTRelayController ipcIdentifier]): 24 (-[LTRelayController processName]): 25 (-[LTRelayController didReceiveStdoutData:]): 26 (-[LTRelayController didCrashWithMessage:]): 27 (-[LTRelayController installApp]): 28 (-[LTRelayController _environmentVariables]): 29 (-[LTRelayController launchApp]): 30 (-[LTRelayController start]): 31 (-[LTRelayController initWithDevice:productDir:appPath:identifierSuffix:dumpToolArguments:]): Deleted. 32 (-[LTRelayController uniqueAppPath]): Deleted. 33 (-[LTRelayController uniqueAppURL]): Deleted. 34 (-[LTRelayController uniqueAppIdentifier]): Deleted. 35 (-[LTRelayController createUniqueApp]): Deleted. 36 * LayoutTestRelay/LayoutTestRelay/main.m: 37 (usage): 38 (getRequiredStringArgument): 39 (main): 40 (getTestingSimDevice): Deleted. 41 * Scripts/webkitpy/port/driver.py: 42 (IOSSimulatorDriver.cmd_line): 43 * WebKitTestRunner/ios/TestControllerIOS.mm: 44 (WTR::TestController::platformInitialize): 45 * WebKitTestRunner/ios/mainIOS.mm: 46 (-[WebKitTestRunnerApp applicationDidEnterBackground:]): 47 * DumpRenderTree/mac/DumpRenderTree.mm: 48 (dumpRenderTree): 49 (-[DumpRenderTree applicationDidEnterBackground:]): 50 1 51 2016-07-01 Konstantin Tokarev <annulen@yandex.ru> 2 52 -
trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm
r202728 r202743 1260 1260 { 1261 1261 #if PLATFORM(IOS) 1262 NSString *identifier = [[NSBundle mainBundle] bundleIdentifier];1263 const char *stdinPath = [[NSString stringWithFormat:@"/tmp/% @_IN", identifier] UTF8String];1264 const char *stdoutPath = [[NSString stringWithFormat:@"/tmp/% @_OUT", identifier] UTF8String];1265 const char *stderrPath = [[NSString stringWithFormat:@"/tmp/% @_ERROR", identifier] UTF8String];1262 const char* identifier = getenv("IPC_IDENTIFIER"); 1263 const char *stdinPath = [[NSString stringWithFormat:@"/tmp/%s_IN", identifier] UTF8String]; 1264 const char *stdoutPath = [[NSString stringWithFormat:@"/tmp/%s_OUT", identifier] UTF8String]; 1265 const char *stderrPath = [[NSString stringWithFormat:@"/tmp/%s_ERROR", identifier] UTF8String]; 1266 1266 1267 1267 int infd = open(stdinPath, O_RDWR); … … 1355 1355 - (void)applicationDidEnterBackground:(UIApplication *)application 1356 1356 { 1357 /* 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. 1358 */ 1359 void (^expirationHandler)() = ^ { 1360 [application endBackgroundTask:backgroundTaskIdentifier]; 1361 backgroundTaskIdentifier = UIBackgroundTaskInvalid; 1362 }; 1363 1364 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 1365 1366 NSTimeInterval timeRemaining; 1367 while (true) { 1368 timeRemaining = [application backgroundTimeRemaining]; 1369 if (timeRemaining <= 10.0 || backgroundTaskIdentifier == UIBackgroundTaskInvalid) { 1370 [application endBackgroundTask:backgroundTaskIdentifier]; 1371 backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:expirationHandler]; 1372 } 1373 sleep(5); 1374 } 1375 }); 1357 RELEASE_ASSERT_NOT_REACHED(); 1376 1358 } 1377 1359 -
trunk/Tools/LayoutTestRelay/LayoutTestRelay/CoreSimulatorSPI.h
r199627 r202743 36 36 #define kSimDeviceLaunchApplicationEnvironment @"environment" 37 37 38 typedef NS_ENUM(NSUInteger, SimDeviceState) {39 SimDeviceStateCreating = 0,40 };41 42 @interface SimDeviceType : NSObject43 + (NSDictionary *)supportedDeviceTypesByIdentifier;44 @property (readonly, copy) NSString *identifier;45 @end46 47 @interface SimRuntime : NSObject48 + (NSDictionary *)supportedRuntimesByIdentifier;49 @end50 51 38 @interface SimDevice : NSObject 52 39 - (BOOL)installApplication:(NSURL *)installURL withOptions:(NSDictionary *)options error:(NSError **)error; 53 40 - (pid_t)launchApplicationWithID:(NSString *)bundleID options:(NSDictionary *)options error:(NSError **)error; 54 @property (readonly, retain) SimDeviceType *deviceType;55 @property (readonly, retain) SimRuntime *runtime;56 @property (readonly, assign) SimDeviceState state;57 @property (readonly, copy) NSString *name;58 41 @end 59 42 60 43 @interface SimDeviceSet : NSObject 61 44 + (SimDeviceSet *)defaultSet; 62 - (SimDevice *)createDeviceWithType:(SimDeviceType *)deviceType runtime:(SimRuntime *)runtime name:(NSString *)name error:(NSError **)error; 63 @property (readonly, copy) NSArray *devices; 45 @property (readonly, copy) NSDictionary *devicesByUDID; 64 46 65 47 @end -
trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.h
r174628 r202743 33 33 34 34 @interface LTRelayController : NSObject <LTRelayDelegate> 35 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath identifierSuffix:(NSString *)suffixdumpToolArguments:(NSArray *)arguments;35 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments; 36 36 - (void)start; 37 37 - (void)finish; -
trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m
r185478 r202743 34 34 @property (readonly, strong) NSFileHandle *standardOutput; 35 35 @property (readonly, strong) NSFileHandle *standardError; 36 @property (readonly, strong) NSString *uniqueAppPath; 37 @property (readonly, strong) NSString *uniqueAppIdentifier; 38 @property (readonly, strong) NSURL *uniqueAppURL; 39 @property (readonly, strong) NSString *originalAppIdentifier; 40 @property (readonly, strong) NSString *originalAppPath; 41 @property (readonly, strong) NSString *identifierSuffix; 36 @property (readonly, strong) NSString *ipcIdentifier; 37 @property (readonly, strong) NSString *appBundleIdentifier; 38 @property (readonly, strong) NSString *appPath; 39 @property (readonly, strong) NSUUID *deviceUDID; 42 40 @property (readonly, strong) NSArray *dumpToolArguments; 43 41 @property (readonly, strong) NSString *productDir; … … 50 48 @implementation LTRelayController 51 49 52 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath identifierSuffix:(NSString *)suffixdumpToolArguments:(NSArray *)arguments50 - (id)initWithDevice:(SimDevice *)device productDir:(NSString *)productDir appPath:(NSString *)appPath deviceUDID:(NSUUID *)udid dumpToolArguments:(NSArray *)arguments 53 51 { 54 52 if ((self = [super init])) { 55 53 _device = device; 56 54 _productDir = productDir; 57 _ originalAppPath = appPath;58 _ originalAppIdentifier = [NSDictionary dictionaryWithContentsOfFile:[_originalAppPath stringByAppendingPathComponent:@"Info.plist"]][(NSString *)kCFBundleIdentifierKey];59 _ identifierSuffix = suffix;55 _appPath = appPath; 56 _appBundleIdentifier = [[NSBundle bundleWithPath:appPath] bundleIdentifier]; 57 _deviceUDID = udid; 60 58 _dumpToolArguments = arguments; 61 59 _standardInputDispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, STDIN_FILENO, 0, dispatch_get_main_queue()); … … 79 77 }); 80 78 81 _relay = [[LTPipeRelay alloc] initWithPrefix:[@"/tmp" stringByAppendingPathComponent: [self uniqueAppIdentifier]]];79 _relay = [[LTPipeRelay alloc] initWithPrefix:[@"/tmp" stringByAppendingPathComponent:self.ipcIdentifier]]; 82 80 [_relay setRelayDelegate:self]; 83 81 } … … 85 83 } 86 84 87 - (NSString *)uniqueAppPath 88 { 89 return [[self originalAppPath] stringByReplacingOccurrencesOfString:@".app" withString:[NSString stringWithFormat:@"%@.app", [self identifierSuffix]]]; 90 } 91 92 - (NSURL *)uniqueAppURL 93 { 94 return [NSURL fileURLWithPath:[self uniqueAppPath]]; 95 } 96 97 - (NSString *)uniqueAppIdentifier 98 { 99 return [[self originalAppIdentifier] stringByAppendingString:[self identifierSuffix]]; 100 } 85 - (NSString *)ipcIdentifier 86 { 87 return [NSString stringWithFormat:@"%@-%@", self.appBundleIdentifier, self.deviceUDID.UUIDString]; 88 } 89 101 90 - (NSString *)processName 102 91 { 103 return [ [[self originalAppIdentifier] componentsSeparatedByString:@"."] lastObject];92 return [self.appBundleIdentifier componentsSeparatedByString:@"."].lastObject; 104 93 } 105 94 … … 152 141 } 153 142 154 - (void) createUniqueApp155 { 156 NS Error *error;157 NSFileManager *fileManager = [NSFileManager defaultManager];158 [fileManager removeItemAtPath:[self uniqueAppPath] error:&error];159 error = nil; 160 161 [ fileManager copyItemAtPath:[self originalAppPath] toPath:[self uniqueAppPath]error:&error];143 - (void)installApp 144 { 145 NSDictionary *installOptions = @{ 146 (NSString *)kCFBundleIdentifierKey: self.appBundleIdentifier, 147 }; 148 149 NSError *error = nil; 150 [self.device installApplication:[NSURL fileURLWithPath:self.appPath] withOptions:installOptions error:&error]; 162 151 if (error) { 163 NSLog(@"Couldn't copy %@ to %@: %@", [self originalAppPath], [self uniqueAppPath], [error description]); 164 exit(EXIT_FAILURE); 165 } 166 167 NSString *infoPlistPath = [[self uniqueAppPath] stringByAppendingPathComponent:@"Info.plist"]; 168 NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile:infoPlistPath]; 169 [plist setValue:[self uniqueAppIdentifier] forKey:(NSString *)kCFBundleIdentifierKey]; 170 BOOL written = [plist writeToFile:infoPlistPath atomically:YES]; 171 if (!written) { 172 NSLog(@"Couldn't write unique app plist at %@", infoPlistPath); 173 exit(EXIT_FAILURE); 174 } 175 176 NSDictionary *installOptions = @{ 177 (NSString *)kCFBundleIdentifierKey: [self uniqueAppIdentifier], 178 }; 179 180 [[self device] installApplication:[self uniqueAppURL] withOptions:installOptions error:&error]; 181 if (error) { 182 NSLog(@"Couldn't install %@: %@", [[self uniqueAppURL] path], [error description]); 152 NSLog(@"Couldn't install %@: %@", self.appPath, error.description); 183 153 exit(EXIT_FAILURE); 184 154 } … … 208 178 209 179 NSMutableDictionary *dictionary = [@{ 180 @"IPC_IDENTIFIER": self.ipcIdentifier, 210 181 @"DYLD_FRAMEWORK_PATH": productDirectory, 211 182 @"__XPC_DYLD_FRAMEWORK_PATH": productDirectory, … … 237 208 238 209 NSError *error; 239 pid_t pid = [ [self device] launchApplicationWithID:[self uniqueAppIdentifier]options:launchOptions error:&error];210 pid_t pid = [self.device launchApplicationWithID:self.appBundleIdentifier options:launchOptions error:&error]; 240 211 241 212 if (pid < 0) { 242 NSLog(@"Couldn't launch unique app instance %@: %@", [self uniqueAppIdentifier], [error description]);213 NSLog(@"Couldn't launch %@: %@", self.appBundleIdentifier, error.description); 243 214 exit(EXIT_FAILURE); 244 215 } … … 258 229 - (void)start 259 230 { 260 [self createUniqueApp];231 [self installApp]; 261 232 [[self relay] setup]; 262 233 [self launchApp]; -
trunk/Tools/LayoutTestRelay/LayoutTestRelay/main.m
r199610 r202743 33 33 { 34 34 NSString *helpText = @"LayoutTestRelay: run a dump tool in the simulator. Not for direct consumption.\n" 35 "Usage: LayoutTestRelay [-h] [options] -- [dump tool arguments]\n" 36 "Required options:\n" 37 " -app <app_path> Path to the built iOS .app bundle directory.\n" 38 " -runtime <identifier> iOS Simulator Runtime identifier (see `xcrun -sdk iphonesimulator simctl`)\n" 39 " -deviceType <identifier> iOS Simulator device identifier (see simctl).\n" 40 " -suffix <text> Used to create multiple unique instances when installing to the simulator.\n" 41 " -productDir <dir> /path/to/WebKitBuild/{configuration}-{short platform}.\n"; 35 "Usage: LayoutTestRelay [-h] [options] -- [dump tool arguments]\n" 36 "Required options:\n" 37 " -udid <identifier> Simulator device identifier\n" 38 " -app <app_path> Path to the built iOS .app bundle directory.\n" 39 " -productDir <dir> /path/to/WebKitBuild/{configuration}-{short platform}.\n"; 42 40 43 41 fprintf(stderr, "%s\n", [helpText UTF8String]); 44 42 } 45 46 SimDevice *getTestingSimDevice(SimDeviceType *deviceType, SimRuntime *runtime, NSString *suffix)47 {48 NSString *deviceName = [[[[deviceType identifier] componentsSeparatedByString:@"."] lastObject] stringByReplacingOccurrencesOfString:@"-" withString:@" "];49 deviceName = [NSString stringWithFormat:@"%@%@%@", deviceName, @" WebKit Tester", suffix];50 51 for (SimDevice *device in [[SimDeviceSet defaultSet] devices]) {52 if ([[device name] isEqualToString:deviceName] && [[device deviceType] isEqualTo:deviceType] && [[device runtime] isEqualTo:runtime])53 return device;54 }55 56 NSError *error;57 SimDevice *device = [[SimDeviceSet defaultSet] createDeviceWithType:deviceType runtime:runtime name:deviceName error:&error];58 59 if (error) {60 NSLog(@"Couldn't create device: %@", [error description]);61 return nil;62 }63 64 while ([device state] == SimDeviceStateCreating)65 sleep(1);66 67 return device;68 }69 70 43 71 44 NSString *getRequiredStringArgument(NSString *parameter) … … 118 91 } 119 92 } 93 94 NSUUID *udid = [[NSUUID alloc] initWithUUIDString:getRequiredStringArgument(@"udid")]; 120 95 NSString *appPath = getRequiredStringArgument(@"app"); 121 NSString *runtimeIdentifier = getRequiredStringArgument(@"runtime"); 122 SimRuntime *runtime = [SimRuntime supportedRuntimesByIdentifier][runtimeIdentifier]; 123 if (!runtime) { 124 NSLog(@"There is no supported runtime \"%@\"", runtimeIdentifier); 96 NSString *productDirectory = getRequiredStringArgument(@"productDir"); 97 NSArray *dumpToolArguments = getDumpToolArguments(); 98 99 SimDevice *device = [SimDeviceSet.defaultSet.devicesByUDID objectForKey:udid]; 100 if (!device) { 101 NSLog(@"Device %@ couldn't be found", udid); 125 102 exit(EXIT_FAILURE); 126 103 } 127 104 128 NSString *deviceTypeIdentifier = getRequiredStringArgument(@"deviceType"); 129 SimDeviceType *deviceType = [SimDeviceType supportedDeviceTypesByIdentifier][deviceTypeIdentifier]; 130 if (!deviceType) { 131 NSLog(@"There is no supported device type \"%@\"", deviceTypeIdentifier); 132 exit(EXIT_FAILURE); 133 } 134 135 NSString *suffix = getRequiredStringArgument(@"suffix"); 136 NSString *productDir = getRequiredStringArgument(@"productDir"); 137 NSArray *dumpToolArguments = getDumpToolArguments(); 138 139 SimDevice *device = getTestingSimDevice(deviceType, runtime, suffix); 140 141 relayController = [[LTRelayController alloc] initWithDevice:device productDir:productDir appPath:appPath identifierSuffix:suffix dumpToolArguments:dumpToolArguments]; 105 relayController = [[LTRelayController alloc] initWithDevice:device productDir:productDirectory appPath:appPath deviceUDID:udid dumpToolArguments:dumpToolArguments]; 142 106 [relayController start]; 143 107 -
trunk/Tools/Scripts/webkitpy/port/driver.py
r202362 r202743 595 595 product_dir = self._port._build_path() 596 596 relay_args = [ 597 '-runtime', self._port.simulator_runtime.identifier, 598 '-deviceType', self._port.simulator_device_type.identifier, 599 '-suffix', str(self._worker_number), 597 '-udid', self._port.testing_device(self._worker_number).udid, 600 598 '-productDir', product_dir, 601 599 '-app', dump_tool, -
trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm
r202132 r202743 47 47 void TestController::platformInitialize() 48 48 { 49 NSString *identifier = [[NSBundle mainBundle] bundleIdentifier];50 const char *stdinPath = [[NSString stringWithFormat:@"/tmp/% @_IN", identifier] UTF8String];51 const char *stdoutPath = [[NSString stringWithFormat:@"/tmp/% @_OUT", identifier] UTF8String];52 const char *stderrPath = [[NSString stringWithFormat:@"/tmp/% @_ERROR", identifier] UTF8String];49 const char* identifier = getenv("IPC_IDENTIFIER"); 50 const char *stdinPath = [[NSString stringWithFormat:@"/tmp/%s_IN", identifier] UTF8String]; 51 const char *stdoutPath = [[NSString stringWithFormat:@"/tmp/%s_OUT", identifier] UTF8String]; 52 const char *stderrPath = [[NSString stringWithFormat:@"/tmp/%s_ERROR", identifier] UTF8String]; 53 53 54 54 int infd = open(stdinPath, O_RDWR); -
trunk/Tools/WebKitTestRunner/ios/mainIOS.mm
r190368 r202743 53 53 - (void)applicationDidEnterBackground:(UIApplication *)application 54 54 { 55 /* 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. 56 */ 57 void (^expirationHandler)() = ^ { 58 [application endBackgroundTask:backgroundTaskIdentifier]; 59 backgroundTaskIdentifier = UIBackgroundTaskInvalid; 60 }; 61 62 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 63 NSTimeInterval timeRemaining; 64 while (true) { 65 timeRemaining = [application backgroundTimeRemaining]; 66 if (timeRemaining <= 10.0 || backgroundTaskIdentifier == UIBackgroundTaskInvalid) { 67 [application endBackgroundTask:backgroundTaskIdentifier]; 68 backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:expirationHandler]; 69 } 70 sleep(5); 71 } 72 }); 55 RELEASE_ASSERT_NOT_REACHED(); 73 56 } 74 57
Note: See TracChangeset
for help on using the changeset viewer.