From 7bb855498e47207ee741d2705e6c58aceec7470d Mon Sep 17 00:00:00 2001 From: "fischman@chromium.org" Date: Sat, 4 Jan 2014 12:28:40 +0000 Subject: Emit test name in FATAL logs. Today failing android tests make it difficult/impossible to correlate logcat output with test failures. This CL adds the test name to the logcat output between the 'F chromium: [FATAL' backtrace and the system-generated tombstone (which previously appeared consecutively, with no mention of which test failed). Contrived example (gotten by throwing a LOG(FATAL) into webrtc_browsertest.cc:572): 12-19 11:12:46.126 20361 20361 F chromium: [FATAL:webrtc_browsertest.cc(572)] AMI: yo! 12-19 11:12:46.126 20361 20361 F chromium: #00 0x757b9475 /data/app-lib/org.chromium.content_browsertests_apk-1/libbase.cr.so+0x0006a475 [...] 12-19 11:12:46.126 20361 20361 F chromium: #40 0x4010634b /system/lib/libc.so+0x0000e34b 12-19 11:12:46.126 20361 20361 F chromium: NEW--> 12-19 11:12:46.126 20361 20361 E chromium: [ERROR:test_suite.cc(231)] Currently running: WebrtcBrowserTest.EstablishAudioVideoCallAndMeasureOutputLevel 12-19 11:12:46.126 20361 20361 F libc : Fatal signal 6 (SIGABRT) at 0x00004f89 (code=-6), thread 20361 (rowsertests_apk) 12-19 11:12:46.236 30166 30166 I DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 12-19 11:12:46.236 30166 30166 I DEBUG : Build fingerprint: 'google/hammerhead/hammerhead:4.4.2/KK/eng.fischman.20131206.175945:userdebug/dev-keys' 12-19 11:12:46.236 30166 30166 I DEBUG : Revision: '11' [...] Review URL: https://codereview.chromium.org/119383002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243028 0039d316-1c4b-4281-b951-d872f2087c98 --- base/test/test_suite.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'base/test') diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index 6579525..5154c05 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -226,6 +226,19 @@ int TestSuite::Run() { // static void TestSuite::UnitTestAssertHandler(const std::string& str) { +#if defined(OS_ANDROID) + // Correlating test stdio with logcat can be difficult, so we emit this + // helpful little hint about what was running. Only do this for Android + // because other platforms don't separate out the relevant logs in the same + // way. + const ::testing::TestInfo* const test_info = + ::testing::UnitTest::GetInstance()->current_test_info(); + if (test_info) { + LOG(ERROR) << "Currently running: " << test_info->test_case_name() << "." + << test_info->name(); + fflush(stderr); + } +#endif // defined(OS_ANDROID) RAW_LOG(FATAL, str.c_str()); } -- cgit v1.1