From 210095136d9952e84174439389f9c3022ffd7178 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Mon, 13 Mar 2017 16:16:16 -0700 Subject: [PATCH 1/2] logcat: test -v epoch tail time Test: gTest logcat-unit-tests Bug: 35373582 Change-Id: I57d84af2eb5d1fce8753539edf3133bfe0bb7213 --- logcat/tests/logcat_test.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp index 9c777b3a9..dad74ee4b 100644 --- a/logcat/tests/logcat_test.cpp +++ b/logcat/tests/logcat_test.cpp @@ -329,7 +329,7 @@ TEST(logcat, tail_1000) { do_tail(1000); } -TEST(logcat, tail_time) { +static void do_tail_time(const char* cmd) { FILE* fp; int count; char buffer[BIG_BUFFER]; @@ -343,14 +343,9 @@ TEST(logcat, tail_time) { int tries = 4; // in case run too soon after system start or buffer clear do { + snprintf(buffer, sizeof(buffer), "%s -t 10 2>&1", cmd); logcat_define(ctx); - ASSERT_TRUE(NULL != (fp = logcat_popen(ctx, - "logcat" - " -v long" - " -v nsec" - " -b all" - " -t 10" - " 2>&1"))); + ASSERT_TRUE(NULL != (fp = logcat_popen(ctx, buffer))); count = 0; while ((input = fgetLongTime(buffer, sizeof(buffer), fp))) { @@ -372,14 +367,7 @@ TEST(logcat, tail_time) { EXPECT_TRUE(first_timestamp != NULL); EXPECT_TRUE(second_timestamp != NULL); - snprintf(buffer, sizeof(buffer), - "logcat" - " -v long" - " -v nsec" - " -b all" - " -t '%s'" - " 2>&1", - first_timestamp); + snprintf(buffer, sizeof(buffer), "%s -t '%s' 2>&1", cmd, first_timestamp); logcat_define(ctx); ASSERT_TRUE(NULL != (fp = logcat_popen(ctx, buffer))); @@ -446,6 +434,14 @@ TEST(logcat, tail_time) { EXPECT_LE(count, last_timestamp_count); } +TEST(logcat, tail_time) { + do_tail_time("logcat -v long -v nsec -b all"); +} + +TEST(logcat, tail_time_epoch) { + do_tail_time("logcat -v long -v nsec -v epoch -b all"); +} + TEST(logcat, End_to_End) { pid_t pid = getpid(); From c500abb40b612d9cc93150362630112d31b333b5 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Mon, 13 Mar 2017 11:38:24 -0700 Subject: [PATCH 2/2] liblog: test: __android_log_btwrite__android_log_close precharge TEST_PREFIX missing before operations on liblog*.__android_log_btwrite__android_log_close tests Test: gTest liblog-unit-tests Bug: 27405083 Change-Id: Iaddc4e1b1f9afcfd8231c3921605fecefd2b56bf --- liblog/tests/liblog_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp index d68ca46d0..5a52377b2 100644 --- a/liblog/tests/liblog_test.cpp +++ b/liblog/tests/liblog_test.cpp @@ -169,6 +169,9 @@ static bool tested__android_log_close; TEST(liblog, __android_log_btwrite__android_logger_list_read) { #if (defined(__ANDROID__) || defined(USING_LOGGER_LOCAL)) +#ifdef TEST_PREFIX + TEST_PREFIX +#endif struct logger_list* logger_list; pid_t pid = getpid();