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

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

Issue 11699005: In iossim, ignore harmless messages from launchd. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: addressed review comment Created 7 years, 11 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 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // messages from launchd that refer to the simulated app's PID. Limit query 284 // messages from launchd that refer to the simulated app's PID. Limit query
285 // to messages in the last minute since PIDs are cyclical. 285 // to messages in the last minute since PIDs are cyclical.
286 aslmsg query = asl_new(ASL_TYPE_QUERY); 286 aslmsg query = asl_new(ASL_TYPE_QUERY);
287 asl_set_query(query, ASL_KEY_SENDER, "launchd", 287 asl_set_query(query, ASL_KEY_SENDER, "launchd",
288 ASL_QUERY_OP_EQUAL | ASL_QUERY_OP_SUBSTRING); 288 ASL_QUERY_OP_EQUAL | ASL_QUERY_OP_SUBSTRING);
289 asl_set_query(query, ASL_KEY_REF_PID, 289 asl_set_query(query, ASL_KEY_REF_PID,
290 [[[session simulatedApplicationPID] stringValue] UTF8String], 290 [[[session simulatedApplicationPID] stringValue] UTF8String],
291 ASL_QUERY_OP_EQUAL); 291 ASL_QUERY_OP_EQUAL);
292 asl_set_query(query, ASL_KEY_TIME, "-1m", ASL_QUERY_OP_GREATER_EQUAL); 292 asl_set_query(query, ASL_KEY_TIME, "-1m", ASL_QUERY_OP_GREATER_EQUAL);
293 293
294 // Log any messages found. 294 // Log any messages found, and take note of any messages that may indicate the
295 // app crashed or did not exit cleanly.
295 aslresponse response = asl_search(NULL, query); 296 aslresponse response = asl_search(NULL, query);
296 BOOL entryFound = NO; 297 BOOL badEntryFound = NO;
297 aslmsg entry; 298 aslmsg entry;
298 while ((entry = aslresponse_next(response)) != NULL) { 299 while ((entry = aslresponse_next(response)) != NULL) {
299 entryFound = YES; 300 const char* message = asl_get(entry, ASL_KEY_MSG);
300 LogWarning(@"Console message: %s", asl_get(entry, ASL_KEY_MSG)); 301 LogWarning(@"Console message: %s", message);
302 // Some messages are harmless, so don't trigger a failure for them.
303 if (strstr(message, "The following job tried to hijack the service"))
304 continue;
305 badEntryFound = YES;
301 } 306 }
302 307
303 // launchd only sends messages if the process crashed or exits with a 308 // If the query returned any nasty-looking results, iossim should exit with
304 // non-zero status, so if the query returned any results iossim should exit 309 // non-zero status.
305 // with non-zero status. 310 if (badEntryFound) {
306 if (entryFound) {
307 LogError(@"Simulated app crashed or exited with non-zero status"); 311 LogError(@"Simulated app crashed or exited with non-zero status");
308 exit(kExitAppCrashed); 312 exit(kExitAppCrashed);
309 } 313 }
310 exit(kExitSuccess); 314 exit(kExitSuccess);
311 } 315 }
312 @end 316 @end
313 317
314 namespace { 318 namespace {
315 319
316 // Finds the developer dir via xcode-select or the DEVELOPER_DIR environment 320 // Finds the developer dir via xcode-select or the DEVELOPER_DIR environment
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 [error localizedDescription], 719 [error localizedDescription],
716 [error domain], static_cast<long int>([error code])); 720 [error domain], static_cast<long int>([error code]));
717 } 721 }
718 722
719 // Note that this code is only executed if the simulator fails to start 723 // Note that this code is only executed if the simulator fails to start
720 // because once the main run loop is started, only the delegate calling 724 // because once the main run loop is started, only the delegate calling
721 // exit() will end the program. 725 // exit() will end the program.
722 [pool drain]; 726 [pool drain];
723 return kExitFailure; 727 return kExitFailure;
724 } 728 }
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