From 6e9aaae9eda474beea26802c360b45e96402399a Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Fri, 13 Jun 2014 10:09:55 -0700 Subject: logd: test: deal with spam filter turned off Change-Id: I759c65e869d0c7cd81063fa7993ba3d67ef9cd06 --- logd/tests/logd_test.cpp | 53 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'logd/tests/logd_test.cpp') diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp index d30eee2..957fdb5 100644 --- a/logd/tests/logd_test.cpp +++ b/logd/tests/logd_test.cpp @@ -649,27 +649,52 @@ TEST(logd, benchmark) { ASSERT_NE(0UL, nowSpamSize); + // Determine if we have the spam filter enabled int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); + + ASSERT_TRUE(sock >= 0); + + static const char getPruneList[] = "getPruneList"; + if (write(sock, getPruneList, sizeof(getPruneList)) > 0) { + char buffer[80]; + memset(buffer, 0, sizeof(buffer)); + read(sock, buffer, sizeof(buffer)); + char *cp = strchr(buffer, '\n'); + if (!cp || (cp[1] != '~') || (cp[2] != '!')) { + close(sock); + fprintf(stderr, + "WARNING: " + "Logger has SPAM filtration turned off \"%s\"\n", buffer); + return; + } + } else { + int save_errno = errno; + close(sock); + FAIL() << "Can not send " << getPruneList << " to logger -- " << strerror(save_errno); + } + static const unsigned long expected_absolute_minimum_log_size = 65536UL; unsigned long totalSize = expected_absolute_minimum_log_size; - if (sock >= 0) { - static const char getSize[] = { - 'g', 'e', 't', 'L', 'o', 'g', 'S', 'i', 'z', 'e', ' ', - LOG_ID_MAIN + '0', '\0' - }; - if (write(sock, getSize, sizeof(getSize)) > 0) { - char buffer[80]; - memset(buffer, 0, sizeof(buffer)); - read(sock, buffer, sizeof(buffer)); - totalSize = atol(buffer); - if (totalSize < expected_absolute_minimum_log_size) { - totalSize = expected_absolute_minimum_log_size; - } + static const char getSize[] = { + 'g', 'e', 't', 'L', 'o', 'g', 'S', 'i', 'z', 'e', ' ', + LOG_ID_MAIN + '0', '\0' + }; + if (write(sock, getSize, sizeof(getSize)) > 0) { + char buffer[80]; + memset(buffer, 0, sizeof(buffer)); + read(sock, buffer, sizeof(buffer)); + totalSize = atol(buffer); + if (totalSize < expected_absolute_minimum_log_size) { + fprintf(stderr, + "WARNING: " + "Logger had unexpected referenced size \"%s\"\n", buffer); + totalSize = expected_absolute_minimum_log_size; } - close(sock); } + close(sock); + // logd allows excursions to 110% of total size totalSize = (totalSize * 11 ) / 10; -- cgit v1.1