summaryrefslogtreecommitdiffstats
path: root/logcat
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2016-11-16 00:26:00 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-11-16 00:26:00 +0000
commit4a9419f627d8da66fbd3c4695ffe6929dc686359 (patch)
tree37ccffb3324be9afa394924b3aa89e33de150105 /logcat
parentaf2a8858c4633c060e101ce911d4a8e9b39d9071 (diff)
parent925834821944e4f0cb4722be5f0cf08e86853a1c (diff)
downloadsystem_core-4a9419f627d8da66fbd3c4695ffe6929dc686359.tar.gz
system_core-4a9419f627d8da66fbd3c4695ffe6929dc686359.tar.bz2
system_core-4a9419f627d8da66fbd3c4695ffe6929dc686359.zip
Merge "liblog: logprint: report truncated event log contents if error"
am: 9258348219 Change-Id: I8b49452b92a65f5cf1cf92ec1d3b776d954243a6
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, ""));
+ }
}