Skip to content

Commit

Permalink
Merge "logd: remove logd.both test"
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Sep 25, 2019
2 parents ab09a17 + bbc489a commit fb897dc
Showing 1 changed file with 0 additions and 80 deletions.
80 changes: 0 additions & 80 deletions logd/tests/logd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fb897dc

Please sign in to comment.