Commit 30e331c4 authored by thomasvl@chromium.org's avatar thomasvl@chromium.org

Expose the startup timeout as something that can be controlled via commandline.

Review URL: https://chromiumcodereview.appspot.com/10826246

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151058 0039d316-1c4b-4281-b951-d872f2087c98
parent f0834d5e
...@@ -63,7 +63,7 @@ const int kIPadFamily = 2; ...@@ -63,7 +63,7 @@ const int kIPadFamily = 2;
// If this timeout occurs iossim will likely exit with non-zero status; the // If this timeout occurs iossim will likely exit with non-zero status; the
// exception being if the app is invoked and completes execution before the // exception being if the app is invoked and completes execution before the
// session is started (this case is handled in session:didStart:withError). // session is started (this case is handled in session:didStart:withError).
const NSTimeInterval kSessionStartTimeoutSeconds = 30; const NSTimeInterval kDefaultSessionStartTimeoutSeconds = 30;
// While the simulated app is running, its stdout is redirected to a file which // While the simulated app is running, its stdout is redirected to a file which
// is polled by iossim and written to iossim's stdout using the following // is polled by iossim and written to iossim's stdout using the following
...@@ -492,7 +492,7 @@ BOOL InitializeSimulatorUserHome(NSString* userHomePath) { ...@@ -492,7 +492,7 @@ BOOL InitializeSimulatorUserHome(NSString* userHomePath) {
// Prints the usage information to stderr. // Prints the usage information to stderr.
void PrintUsage() { void PrintUsage() {
fprintf(stderr, "Usage: iossim [-d device] [-s sdkVersion] [-u homeDir] " fprintf(stderr, "Usage: iossim [-d device] [-s sdkVersion] [-u homeDir] "
"[-e envKey=value]* <appPath> [<appArgs>]\n" "[-e envKey=value]* [-t startupTimeout] <appPath> [<appArgs>]\n"
" where <appPath> is the path to the .app directory and appArgs are any" " where <appPath> is the path to the .app directory and appArgs are any"
" arguments to send the simulated app.\n" " arguments to send the simulated app.\n"
"\n" "\n"
...@@ -504,7 +504,10 @@ void PrintUsage() { ...@@ -504,7 +504,10 @@ void PrintUsage() {
" -u Specifies a user home directory for the simulator." " -u Specifies a user home directory for the simulator."
" Will create a new directory if not specified.\n" " Will create a new directory if not specified.\n"
" -e Specifies an environment key=value pair that will be" " -e Specifies an environment key=value pair that will be"
" set in the simulated application's environment.\n"); " set in the simulated application's environment.\n"
" -t Specifies the session startup timeout (in seconds)."
" Defaults to %d.\n",
static_cast<int>(kDefaultSessionStartTimeoutSeconds));
} }
} // namespace } // namespace
...@@ -531,10 +534,11 @@ int main(int argc, char* const argv[]) { ...@@ -531,10 +534,11 @@ int main(int argc, char* const argv[]) {
NSString* simHomePath = nil; NSString* simHomePath = nil;
NSMutableArray* appArgs = [NSMutableArray array]; NSMutableArray* appArgs = [NSMutableArray array];
NSMutableDictionary* appEnv = [NSMutableDictionary dictionary]; NSMutableDictionary* appEnv = [NSMutableDictionary dictionary];
NSTimeInterval sessionStartTimeout = kDefaultSessionStartTimeoutSeconds;
// Parse the optional arguments // Parse the optional arguments
int c; int c;
while ((c = getopt(argc, argv, "hs:d:u:e:")) != -1) { while ((c = getopt(argc, argv, "hs:d:u:e:t:")) != -1) {
switch (c) { switch (c) {
case 's': case 's':
sdkVersion = [NSString stringWithUTF8String:optarg]; sdkVersion = [NSString stringWithUTF8String:optarg];
...@@ -559,6 +563,17 @@ int main(int argc, char* const argv[]) { ...@@ -559,6 +563,17 @@ int main(int argc, char* const argv[]) {
[appEnv setObject:value forKey:key]; [appEnv setObject:value forKey:key];
} }
break; break;
case 't': {
int timeout = atoi(optarg);
if (timeout > 0) {
sessionStartTimeout = static_cast<NSTimeInterval>(timeout);
} else {
LogError(@"Invalid startup timeout (%s).", optarg);
PrintUsage();
exit(EXIT_FAILURE);
}
}
break;
case 'h': case 'h':
PrintUsage(); PrintUsage();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
...@@ -660,7 +675,7 @@ int main(int argc, char* const argv[]) { ...@@ -660,7 +675,7 @@ int main(int argc, char* const argv[]) {
// Start the simulator session. // Start the simulator session.
NSError* error; NSError* error;
BOOL started = [session requestStartWithConfig:config BOOL started = [session requestStartWithConfig:config
timeout:kSessionStartTimeoutSeconds timeout:sessionStartTimeout
error:&error]; error:&error];
// Spin the runtime indefinitely. When the delegate gets the message that the // Spin the runtime indefinitely. When the delegate gets the message that the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment