summaryrefslogtreecommitdiffstats
path: root/logcat
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2016-11-11 14:41:30 -0800
committerMark Salyzyn <salyzyn@google.com>2016-11-15 14:46:34 -0800
commit1a57ae3a7d2e33531ce26fa2d2fefaae679b6eeb (patch)
tree7cbcacaa7030403c4672f5336e1e4136c95b5f90 /logcat
parent787482ecd9658b3078044aa287680b32795c2375 (diff)
downloadsystem_core-1a57ae3a7d2e33531ce26fa2d2fefaae679b6eeb.tar.gz
system_core-1a57ae3a7d2e33531ce26fa2d2fefaae679b6eeb.tar.bz2
system_core-1a57ae3a7d2e33531ce26fa2d2fefaae679b6eeb.zip
liblog: logprint: report truncated event log contents if error
We need to accept that a log tag can contain no payload. For those that are corrupted, and to aid debugging, report what we did manage to interpret. Report last character as a ! for corruption, and ^ for truncation. Fix a few Android Coding standard issues. Test: gTest logcat-unit-tests Bug: 32903864 Change-Id: Id11bef3a7b6569305c51701dd66c45d2038d6628
Diffstat (limited to 'logcat')
-rw-r--r--logcat/tests/logcat_test.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp
index 18067dc16..8d7c04eb9 100644
--- a/logcat/tests/logcat_test.cpp
+++ b/logcat/tests/logcat_test.cpp
@@ -1255,19 +1255,25 @@ static bool End_to_End(const char* tag, const char* fmt, ...) {
va_end(ap);
char *str = NULL;
- asprintf(&str, "I/%s ( %%d): %s%%c", tag, buffer);
+ asprintf(&str, "I/%s ( %%d):%%c%s%%c", tag, buffer);
std::string expect(str);
free(str);
int count = 0;
pid_t pid = getpid();
std::string lastMatch;
+ int maxMatch = 1;
while (fgets(buffer, sizeof(buffer), fp)) {
+ char space;
char newline;
int p;
- int ret = sscanf(buffer, expect.c_str(), &p, &newline);
- if ((2 == ret) && (p == pid) && (newline == '\n')) ++count;
- else if ((1 == ret) && (p == pid) && (count == 0)) lastMatch = buffer;
+ int ret = sscanf(buffer, expect.c_str(), &p, &space, &newline);
+ if ((ret == 3) && (p == pid) && (space == ' ') && (newline == '\n')) {
+ ++count;
+ } else if ((ret >= maxMatch) && (p == pid) && (count == 0)) {
+ lastMatch = buffer;
+ maxMatch = ret;
+ }
}
pclose(fp);
@@ -1395,4 +1401,10 @@ TEST(logcat, descriptive) {
}
}
+ {
+ static const struct tag sync = { 27501, "notification_panel_hidden" };
+ android_log_event_context ctx(sync.tagNo);
+ ctx.write();
+ EXPECT_TRUE(End_to_End(sync.tagStr, ""));
+ }
}