summaryrefslogtreecommitdiffstats
path: root/logd/tests/logd_test.cpp
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2014-06-13 10:09:55 -0700
committerMark Salyzyn <salyzyn@google.com>2014-06-18 11:12:27 -0700
commit6e9aaae9eda474beea26802c360b45e96402399a (patch)
treec865e8d711a3a53179baa4f85a4efb2f9ffa362d /logd/tests/logd_test.cpp
parent0c57bd864d2353e8f03c8b128bdacb58fc5dce95 (diff)
downloadsystem_core-6e9aaae9eda474beea26802c360b45e96402399a.zip
system_core-6e9aaae9eda474beea26802c360b45e96402399a.tar.gz
system_core-6e9aaae9eda474beea26802c360b45e96402399a.tar.bz2
logd: test: deal with spam filter turned off
Change-Id: I759c65e869d0c7cd81063fa7993ba3d67ef9cd06
Diffstat (limited to 'logd/tests/logd_test.cpp')
-rw-r--r--logd/tests/logd_test.cpp53
1 files changed, 39 insertions, 14 deletions
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;