| OLD | NEW |
| 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 | 4 |
| 5 #import <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 #include <asl.h> | 6 #include <asl.h> |
| 7 #include <libgen.h> | 7 #include <libgen.h> |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 | 10 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 NSFileManager* fileManager = [NSFileManager defaultManager]; | 497 NSFileManager* fileManager = [NSFileManager defaultManager]; |
| 498 if ([fileManager fileExistsAtPath:path]) { | 498 if ([fileManager fileExistsAtPath:path]) { |
| 499 NSString* content = | 499 NSString* content = |
| 500 [NSString stringWithContentsOfFile:path | 500 [NSString stringWithContentsOfFile:path |
| 501 encoding:NSUTF8StringEncoding | 501 encoding:NSUTF8StringEncoding |
| 502 error:NULL]; | 502 error:NULL]; |
| 503 NSArray* lines = [content componentsSeparatedByCharactersInSet: | 503 NSArray* lines = [content componentsSeparatedByCharactersInSet: |
| 504 [NSCharacterSet newlineCharacterSet]]; | 504 [NSCharacterSet newlineCharacterSet]]; |
| 505 NSString* simulatedAppPID = | 505 NSString* simulatedAppPID = |
| 506 [NSString stringWithFormat:@"%d", session.simulatedApplicationPID]; | 506 [NSString stringWithFormat:@"%d", session.simulatedApplicationPID]; |
| 507 NSArray* kErrorStrings = @[ |
| 508 @"Service exited with abnormal code:", |
| 509 @"Service exited due to signal:", |
| 510 ]; |
| 507 for (NSString* line in lines) { | 511 for (NSString* line in lines) { |
| 508 NSString* const kErrorString = @"Service exited with abnormal code:"; | 512 if ([line rangeOfString:simulatedAppPID].location != NSNotFound) { |
| 509 if ([line rangeOfString:kErrorString].location != NSNotFound && | 513 for (NSString* errorString in kErrorStrings) { |
| 510 [line rangeOfString:simulatedAppPID].location != NSNotFound) { | 514 if ([line rangeOfString:errorString].location != NSNotFound) { |
| 511 LogWarning(@"Console message: %@", line); | 515 LogWarning(@"Console message: %@", line); |
| 512 badEntryFound = YES; | 516 badEntryFound = YES; |
| 513 break; | 517 break; |
| 518 } |
| 519 } |
| 520 if (badEntryFound) { |
| 521 break; |
| 522 } |
| 514 } | 523 } |
| 515 } | 524 } |
| 516 // Remove the log file so subsequent invocations of iossim won't be | 525 // Remove the log file so subsequent invocations of iossim won't be |
| 517 // looking at stale logs. | 526 // looking at stale logs. |
| 518 remove([path fileSystemRepresentation]); | 527 remove([path fileSystemRepresentation]); |
| 519 } else { | 528 } else { |
| 520 LogWarning(@"Unable to find system log at '%@'.", path); | 529 LogWarning(@"Unable to find system log at '%@'.", path); |
| 521 } | 530 } |
| 522 } | 531 } |
| 523 | 532 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 [error localizedDescription], | 1021 [error localizedDescription], |
| 1013 [error domain], static_cast<long int>([error code])); | 1022 [error domain], static_cast<long int>([error code])); |
| 1014 } | 1023 } |
| 1015 | 1024 |
| 1016 // Note that this code is only executed if the simulator fails to start | 1025 // Note that this code is only executed if the simulator fails to start |
| 1017 // because once the main run loop is started, only the delegate calling | 1026 // because once the main run loop is started, only the delegate calling |
| 1018 // exit() will end the program. | 1027 // exit() will end the program. |
| 1019 [pool drain]; | 1028 [pool drain]; |
| 1020 return kExitFailure; | 1029 return kExitFailure; |
| 1021 } | 1030 } |
| OLD | NEW |