Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: testing/iossim/iossim.mm

Issue 2240373002: [iossim] Work around pipe hang on some macs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #import <Foundation/Foundation.h> 4 #import <Foundation/Foundation.h>
5 #if defined(__MAC_10_12) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12 5 #if defined(__MAC_10_12) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12
6 #include <getopt.h> 6 #include <getopt.h>
7 #include <string> 7 #include <string>
8 8
9 namespace { 9 namespace {
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 - (void)setStandardError:(id)error { 83 - (void)setStandardError:(id)error {
84 [_task setStandardError:error]; 84 [_task setStandardError:error];
85 } 85 }
86 86
87 - (void)run { 87 - (void)run {
88 [_task launch]; 88 [_task launch];
89 [_task waitUntilExit]; 89 [_task waitUntilExit];
90 } 90 }
91 91
92 - (void)launch {
93 [_task launch];
94 }
95
96 - (void)waitUntilExit {
97 [_task waitUntilExit];
98 }
99
92 @end 100 @end
93 101
94 // Return array of available iOS runtime dictionaries. Unavailable (old Xcode 102 // Return array of available iOS runtime dictionaries. Unavailable (old Xcode
95 // versions) or other runtimes (tvOS, watchOS) are removed. 103 // versions) or other runtimes (tvOS, watchOS) are removed.
96 NSArray* Runtimes(NSDictionary* simctl_list) { 104 NSArray* Runtimes(NSDictionary* simctl_list) {
97 NSMutableArray* runtimes = 105 NSMutableArray* runtimes =
98 [[simctl_list[@"runtimes"] mutableCopy] autorelease]; 106 [[simctl_list[@"runtimes"] mutableCopy] autorelease];
99 for (NSDictionary* runtime in simctl_list[@"runtimes"]) { 107 for (NSDictionary* runtime in simctl_list[@"runtimes"]) {
100 if (![runtime[@"identifier"] 108 if (![runtime[@"identifier"]
101 hasPrefix:@"com.apple.CoreSimulator.SimRuntime.iOS"] || 109 hasPrefix:@"com.apple.CoreSimulator.SimRuntime.iOS"] ||
(...skipping 18 matching lines...) Expand all
120 } 128 }
121 return devicetypes; 129 return devicetypes;
122 } 130 }
123 131
124 // Get list of devices, runtimes, etc from sim_ctl. 132 // Get list of devices, runtimes, etc from sim_ctl.
125 NSDictionary* GetSimulatorList() { 133 NSDictionary* GetSimulatorList() {
126 XCRunTask* task = [[[XCRunTask alloc] 134 XCRunTask* task = [[[XCRunTask alloc]
127 initWithArguments:@[ @"simctl", @"list", @"-j" ]] autorelease]; 135 initWithArguments:@[ @"simctl", @"list", @"-j" ]] autorelease];
128 NSPipe* out = [NSPipe pipe]; 136 NSPipe* out = [NSPipe pipe];
129 [task setStandardOutput:out]; 137 [task setStandardOutput:out];
130 [task run];
131 138
139 // In the rest of the this file we read from the pipe after -waitUntilExit
140 // (We normally wrap -launch and -waitUntilExit in one -run method). However,
141 // on some swarming slaves this led to a hang on simctl's pipe. Since the
142 // output of simctl is so instant, reading it before exit seems to work, and
143 // seems to avoid the hang.
144 [task launch];
132 NSData* data = [[out fileHandleForReading] readDataToEndOfFile]; 145 NSData* data = [[out fileHandleForReading] readDataToEndOfFile];
146 [task waitUntilExit];
147
133 NSError* error = nil; 148 NSError* error = nil;
134 return [NSJSONSerialization JSONObjectWithData:data 149 return [NSJSONSerialization JSONObjectWithData:data
135 options:kNilOptions 150 options:kNilOptions
136 error:&error]; 151 error:&error];
137 } 152 }
138 153
139 // List supported runtimes and devices. 154 // List supported runtimes and devices.
140 void PrintSupportedDevices(NSDictionary* simctl_list) { 155 void PrintSupportedDevices(NSDictionary* simctl_list) {
141 printf("\niOS devices:\n"); 156 printf("\niOS devices:\n");
142 for (NSDictionary* type in Devices(simctl_list)) { 157 for (NSDictionary* type in Devices(simctl_list)) {
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 } 1273 }
1259 1274
1260 // Note that this code is only executed if the simulator fails to start 1275 // Note that this code is only executed if the simulator fails to start
1261 // because once the main run loop is started, only the delegate calling 1276 // because once the main run loop is started, only the delegate calling
1262 // exit() will end the program. 1277 // exit() will end the program.
1263 [pool drain]; 1278 [pool drain];
1264 return kExitFailure; 1279 return kExitFailure;
1265 } 1280 }
1266 1281
1267 #endif 1282 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698