From bbc489a468aa4355a9eb4ce4ba24c9b269b26a57 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Wed, 25 Sep 2019 14:20:44 -0700 Subject: [PATCH] logd: remove logd.both test This test checks that kernel /dev/log* and logd do not exist and have content in them simultaneously. The kernel logger was removed years ago, so that half of the test is no longer relevant. Once that half is removed, this test is essentially "is logd online and does it have logs", which is already tested for in other tests, so we remove this on entirely. Test: logd unit tests Change-Id: I71dff742f66fc791b7a661a363d4239363140b3f --- logd/tests/logd_test.cpp | 80 ---------------------------------------- 1 file changed, 80 deletions(-) diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp index b6c33d7da..80625a704 100644 --- a/logd/tests/logd_test.cpp +++ b/logd/tests/logd_test.cpp @@ -349,86 +349,6 @@ static void dump_log_msg(const char* prefix, log_msg* msg, unsigned int version, } #endif -TEST(logd, both) { -#ifdef __ANDROID__ - log_msg msg; - - // check if we can read any logs from logd - bool user_logger_available = false; - bool user_logger_content = false; - - int fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED, - SOCK_SEQPACKET); - if (fd >= 0) { - struct sigaction ignore, old_sigaction; - memset(&ignore, 0, sizeof(ignore)); - ignore.sa_handler = caught_signal; - sigemptyset(&ignore.sa_mask); - sigaction(SIGALRM, &ignore, &old_sigaction); - unsigned int old_alarm = alarm(10); - - static const char ask[] = "dumpAndClose lids=0,1,2,3"; - user_logger_available = write(fd, ask, sizeof(ask)) == sizeof(ask); - - user_logger_content = recv(fd, msg.buf, sizeof(msg), 0) > 0; - - if (user_logger_content) { - dump_log_msg("user", &msg, 3, -1); - } - - alarm(old_alarm); - sigaction(SIGALRM, &old_sigaction, nullptr); - - close(fd); - } - - // check if we can read any logs from kernel logger - bool kernel_logger_available = false; - bool kernel_logger_content = false; - - static const char* loggers[] = { - "/dev/log/main", "/dev/log_main", "/dev/log/radio", - "/dev/log_radio", "/dev/log/events", "/dev/log_events", - "/dev/log/system", "/dev/log_system", - }; - - for (unsigned int i = 0; i < arraysize(loggers); ++i) { - fd = open(loggers[i], O_RDONLY); - if (fd < 0) { - continue; - } - kernel_logger_available = true; - fcntl(fd, F_SETFL, O_RDONLY | O_NONBLOCK); - int result = TEMP_FAILURE_RETRY(read(fd, msg.buf, sizeof(msg))); - if (result > 0) { - kernel_logger_content = true; - dump_log_msg("kernel", &msg, 0, i / 2); - } - close(fd); - } - - static const char yes[] = "\xE2\x9C\x93"; - static const char no[] = "\xE2\x9c\x98"; - fprintf(stderr, - "LOGGER Available Content\n" - "user %-13s%s\n" - "kernel %-13s%s\n" - " status %-11s%s\n", - (user_logger_available) ? yes : no, (user_logger_content) ? yes : no, - (kernel_logger_available) ? yes : no, - (kernel_logger_content) ? yes : no, - (user_logger_available && kernel_logger_available) ? "ERROR" : "ok", - (user_logger_content && kernel_logger_content) ? "ERROR" : "ok"); - - EXPECT_EQ(0, user_logger_available && kernel_logger_available); - EXPECT_EQ(0, !user_logger_available && !kernel_logger_available); - EXPECT_EQ(0, user_logger_content && kernel_logger_content); - EXPECT_EQ(0, !user_logger_content && !kernel_logger_content); -#else - GTEST_LOG_(INFO) << "This test does nothing.\n"; -#endif -} - #ifdef __ANDROID__ // BAD ROBOT // Benchmark threshold are generally considered bad form unless there is