Make am instrument capture logcat during test run, and return it to the host.
Also makes bit print that logcat, if available, instead of just the
stack trace.
This means that when you run a test you don't also have to run logcat in
some other window, and then scroll around forever looking for the one
test in question.
Test: bit -t GtsIncidentManagerTestCases:com.google.android.incident.gts.IncidentManagerTests\#testFail
Test: bit -t GtsIncidentManagerTestCases:com.google.android.incident.gts.IncidentManagerTests\#testDoesntExist
Bug: 129875642
Change-Id: I8940ff379c919482f4a545cb90d25bdbaa2b4f15
diff --git a/tools/bit/main.cpp b/tools/bit/main.cpp
index 1a91f52..d80c2e7 100644
--- a/tools/bit/main.cpp
+++ b/tools/bit/main.cpp
@@ -290,8 +290,14 @@
m_currentAction->target->name.c_str(), className.c_str(),
testName.c_str(), g_escapeEndColor);
- string stack = get_bundle_string(results, &found, "stack", NULL);
- if (found) {
+ bool stackFound;
+ string stack = get_bundle_string(results, &stackFound, "stack", NULL);
+ if (status.has_logcat()) {
+ const string logcat = status.logcat();
+ if (logcat.length() > 0) {
+ printf("%s\n", logcat.c_str());
+ }
+ } else if (stackFound) {
printf("%s\n", stack.c_str());
}
}