liblog: remove unused test #defines and transport code
We only ever have the default logger now, so we can remove this code. Test: liblog unit tests Change-Id: Ic3755d1c807c53192c614860a3cbe985748a3fe8
This commit is contained in:
parent
2238ce2d7f
commit
ebb7cdd0ac
1 changed files with 48 additions and 254 deletions
|
@ -38,31 +38,10 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <log/log_event_list.h>
|
||||
#include <log/log_properties.h>
|
||||
#include <log/log_transport.h>
|
||||
#include <log/logprint.h>
|
||||
#include <private/android_filesystem_config.h>
|
||||
#include <private/android_logger.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#define TEST_LOGGER LOGGER_DEFAULT
|
||||
#endif
|
||||
#define USING_LOGGER_DEFAULT
|
||||
|
||||
#ifndef TEST_PREFIX
|
||||
#ifdef TEST_LOGGER
|
||||
#define TEST_PREFIX android_set_log_transport(TEST_LOGGER);
|
||||
// make sure we always run code despite overrides if compiled for android
|
||||
#elif defined(__ANDROID__)
|
||||
#define TEST_PREFIX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USING_LOGGER_STDERR
|
||||
#define SUPPORTS_END_TO_END 0
|
||||
#else
|
||||
#define SUPPORTS_END_TO_END 1
|
||||
#endif
|
||||
|
||||
// enhanced version of LOG_FAILURE_RETRY to add support for EAGAIN and
|
||||
// non-syscall libs. Since we are only using this in the emergency of
|
||||
// a signal to stuff a terminating code into the logs, we will spin rather
|
||||
|
@ -78,9 +57,6 @@
|
|||
})
|
||||
|
||||
TEST(liblog, __android_log_btwrite) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#endif
|
||||
int intBuf = 0xDEADBEEF;
|
||||
EXPECT_LT(0,
|
||||
__android_log_btwrite(0, EVENT_TYPE_INT, &intBuf, sizeof(intBuf)));
|
||||
|
@ -94,7 +70,7 @@ TEST(liblog, __android_log_btwrite) {
|
|||
usleep(1000);
|
||||
}
|
||||
|
||||
#if (defined(__ANDROID__) && defined(USING_LOGGER_DEFAULT))
|
||||
#if defined(__ANDROID__)
|
||||
static std::string popenToString(const std::string& command) {
|
||||
std::string ret;
|
||||
|
||||
|
@ -165,9 +141,6 @@ static bool tested__android_log_close;
|
|||
|
||||
TEST(liblog, __android_log_btwrite__android_logger_list_read) {
|
||||
#ifdef __ANDROID__
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#endif
|
||||
struct logger_list* logger_list;
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
@ -179,7 +152,6 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
|
|||
|
||||
log_time ts(CLOCK_MONOTONIC);
|
||||
EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
|
||||
#ifdef USING_LOGGER_DEFAULT
|
||||
// Check that we can close and reopen the logger
|
||||
bool logdwActiveAfter__android_log_btwrite;
|
||||
if (getuid() == AID_ROOT) {
|
||||
|
@ -202,11 +174,9 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
|
|||
bool logdwActiveAfter__android_log_close = isLogdwActive();
|
||||
EXPECT_FALSE(logdwActiveAfter__android_log_close);
|
||||
}
|
||||
#endif
|
||||
|
||||
log_time ts1(CLOCK_MONOTONIC);
|
||||
EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts1, sizeof(ts1)));
|
||||
#ifdef USING_LOGGER_DEFAULT
|
||||
if (getuid() == AID_ROOT) {
|
||||
#ifndef NO_PSTORE
|
||||
bool pmsgActiveAfter__android_log_btwrite = isPmsgActive();
|
||||
|
@ -215,7 +185,6 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
|
|||
logdwActiveAfter__android_log_btwrite = isLogdwActive();
|
||||
EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
|
||||
}
|
||||
#endif
|
||||
usleep(1000000);
|
||||
|
||||
int count = 0;
|
||||
|
@ -249,8 +218,8 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
|
|||
}
|
||||
}
|
||||
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, second_count);
|
||||
EXPECT_EQ(1, count);
|
||||
EXPECT_EQ(1, second_count);
|
||||
|
||||
android_logger_list_close(logger_list);
|
||||
#else
|
||||
|
@ -259,127 +228,6 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
|
|||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
static void print_transport(const char* prefix, int logger) {
|
||||
static const char orstr[] = " | ";
|
||||
|
||||
if (!prefix) {
|
||||
prefix = "";
|
||||
}
|
||||
if (logger < 0) {
|
||||
fprintf(stderr, "%s%s\n", prefix, strerror(-logger));
|
||||
return;
|
||||
}
|
||||
|
||||
if (logger == LOGGER_DEFAULT) {
|
||||
fprintf(stderr, "%sLOGGER_DEFAULT", prefix);
|
||||
prefix = orstr;
|
||||
}
|
||||
if (logger & LOGGER_LOGD) {
|
||||
fprintf(stderr, "%sLOGGER_LOGD", prefix);
|
||||
prefix = orstr;
|
||||
}
|
||||
if (logger & LOGGER_KERNEL) {
|
||||
fprintf(stderr, "%sLOGGER_KERNEL", prefix);
|
||||
prefix = orstr;
|
||||
}
|
||||
if (logger & LOGGER_NULL) {
|
||||
fprintf(stderr, "%sLOGGER_NULL", prefix);
|
||||
prefix = orstr;
|
||||
}
|
||||
logger &= ~(LOGGER_LOGD | LOGGER_KERNEL | LOGGER_NULL);
|
||||
if (logger) {
|
||||
fprintf(stderr, "%s0x%x", prefix, logger);
|
||||
prefix = orstr;
|
||||
}
|
||||
if (prefix == orstr) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// This test makes little sense standalone, and requires the tests ahead
|
||||
// and behind us, to make us whole. We could incorporate a prefix and
|
||||
// suffix test to make this standalone, but opted to not complicate this.
|
||||
TEST(liblog, android_set_log_transport) {
|
||||
#ifdef __ANDROID__
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#endif
|
||||
|
||||
int logger = android_get_log_transport();
|
||||
print_transport("android_get_log_transport = ", logger);
|
||||
EXPECT_NE(LOGGER_NULL, logger);
|
||||
|
||||
int ret;
|
||||
EXPECT_EQ(LOGGER_NULL, ret = android_set_log_transport(LOGGER_NULL));
|
||||
print_transport("android_set_log_transport = ", ret);
|
||||
EXPECT_EQ(LOGGER_NULL, ret = android_get_log_transport());
|
||||
print_transport("android_get_log_transport = ", ret);
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
||||
struct logger_list* logger_list;
|
||||
ASSERT_TRUE(NULL !=
|
||||
(logger_list = android_logger_list_open(
|
||||
LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
|
||||
1000, pid)));
|
||||
|
||||
log_time ts(CLOCK_MONOTONIC);
|
||||
EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
|
||||
|
||||
usleep(1000000);
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (;;) {
|
||||
log_msg log_msg;
|
||||
if (android_logger_list_read(logger_list, &log_msg) <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
EXPECT_EQ(log_msg.entry.pid, pid);
|
||||
|
||||
if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
|
||||
(log_msg.id() != LOG_ID_EVENTS)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
android_log_event_long_t* eventData;
|
||||
eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
|
||||
|
||||
if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
|
||||
if (ts == tx) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
android_logger_list_close(logger_list);
|
||||
|
||||
EXPECT_EQ(logger, ret = android_set_log_transport(logger));
|
||||
print_transport("android_set_log_transport = ", ret);
|
||||
EXPECT_EQ(logger, ret = android_get_log_transport());
|
||||
print_transport("android_get_log_transport = ", ret);
|
||||
|
||||
// False negative if liblog.__android_log_btwrite__android_logger_list_read
|
||||
// fails above, so we will likely succeed. But we will have so many
|
||||
// failures elsewhere that it is probably not worthwhile for us to
|
||||
// highlight yet another disappointment.
|
||||
//
|
||||
// We also expect failures in the following tests if the set does not
|
||||
// react in an appropriate manner internally, yet passes, so we depend
|
||||
// on this test being in the middle of a series of tests performed in
|
||||
// the same process.
|
||||
EXPECT_EQ(0, count);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TEST_PREFIX
|
||||
static inline uint32_t get4LE(const uint8_t* src) {
|
||||
return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
|
||||
}
|
||||
|
@ -390,8 +238,7 @@ static inline uint32_t get4LE(const char* src) {
|
|||
#endif
|
||||
|
||||
static void bswrite_test(const char* message) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
struct logger_list* logger_list;
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
@ -401,11 +248,7 @@ static void bswrite_test(const char* message) {
|
|||
LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
|
||||
1000, pid)));
|
||||
|
||||
#ifdef __ANDROID__
|
||||
log_time ts(android_log_clockid());
|
||||
#else
|
||||
log_time ts(CLOCK_REALTIME);
|
||||
#endif
|
||||
|
||||
EXPECT_LT(0, __android_log_bswrite(0, message));
|
||||
size_t num_lines = 1, size = 0, length = 0, total = 0;
|
||||
|
@ -487,7 +330,7 @@ static void bswrite_test(const char* message) {
|
|||
}
|
||||
}
|
||||
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(1, count);
|
||||
|
||||
android_logger_list_close(logger_list);
|
||||
#else
|
||||
|
@ -517,8 +360,7 @@ TEST(liblog, __android_log_bswrite_and_print__multiple_newline) {
|
|||
}
|
||||
|
||||
static void buf_write_test(const char* message) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
struct logger_list* logger_list;
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
@ -529,11 +371,7 @@ static void buf_write_test(const char* message) {
|
|||
LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
|
||||
|
||||
static const char tag[] = "TEST__android_log_buf_write";
|
||||
#ifdef __ANDROID__
|
||||
log_time ts(android_log_clockid());
|
||||
#else
|
||||
log_time ts(CLOCK_REALTIME);
|
||||
#endif
|
||||
|
||||
EXPECT_LT(
|
||||
0, __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO, tag, message));
|
||||
|
@ -591,7 +429,7 @@ static void buf_write_test(const char* message) {
|
|||
android_log_format_free(logformat);
|
||||
}
|
||||
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(1, count);
|
||||
|
||||
android_logger_list_close(logger_list);
|
||||
#else
|
||||
|
@ -612,8 +450,7 @@ TEST(liblog, __android_log_buf_write_and_print__newline_space_prefix) {
|
|||
buf_write_test("\n Hello World \n");
|
||||
}
|
||||
|
||||
#ifdef USING_LOGGER_DEFAULT // requires blocking reader functionality
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
static unsigned signaled;
|
||||
static log_time signal_time;
|
||||
|
||||
|
@ -674,8 +511,7 @@ static void get_ticks(unsigned long long* uticks, unsigned long long* sticks) {
|
|||
#endif
|
||||
|
||||
TEST(liblog, android_logger_list_read__cpu_signal) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
struct logger_list* logger_list;
|
||||
unsigned long long v = 0xDEADBEEFA55A0000ULL;
|
||||
|
||||
|
@ -767,7 +603,7 @@ TEST(liblog, android_logger_list_read__cpu_signal) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
/*
|
||||
* Strictly, we are not allowed to log messages in a signal context, the
|
||||
* correct way to handle this is to ensure the messages are constructed in
|
||||
|
@ -831,8 +667,7 @@ static int start_thread() {
|
|||
#endif
|
||||
|
||||
TEST(liblog, android_logger_list_read__cpu_thread) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
struct logger_list* logger_list;
|
||||
unsigned long long v = 0xDEADBEAFA55A0000ULL;
|
||||
|
||||
|
@ -924,9 +759,8 @@ TEST(liblog, android_logger_list_read__cpu_thread) {
|
|||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
#endif // USING_LOGGER_DEFAULT
|
||||
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
static const char max_payload_tag[] = "TEST_max_payload_and_longish_tag_XXXX";
|
||||
#define SIZEOF_MAX_PAYLOAD_BUF \
|
||||
(LOGGER_ENTRY_MAX_PAYLOAD - sizeof(max_payload_tag) - 1)
|
||||
|
@ -1063,10 +897,8 @@ for trouble being gone, comfort should remain, but\n\
|
|||
when you depart from me, sorrow abides and happiness\n\
|
||||
takes his leave.";
|
||||
|
||||
#ifdef USING_LOGGER_DEFAULT
|
||||
TEST(liblog, max_payload) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
pid_t pid = getpid();
|
||||
char tag[sizeof(max_payload_tag)];
|
||||
memcpy(tag, max_payload_tag, sizeof(tag));
|
||||
|
@ -1121,22 +953,16 @@ TEST(liblog, max_payload) {
|
|||
|
||||
android_logger_list_close(logger_list);
|
||||
|
||||
#if SUPPORTS_END_TO_END
|
||||
EXPECT_EQ(true, matches);
|
||||
|
||||
EXPECT_LE(SIZEOF_MAX_PAYLOAD_BUF, static_cast<size_t>(max_len));
|
||||
#else
|
||||
EXPECT_EQ(false, matches);
|
||||
#endif
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(liblog, __android_log_buf_print__maxtag) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
struct logger_list* logger_list;
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
@ -1146,11 +972,7 @@ TEST(liblog, __android_log_buf_print__maxtag) {
|
|||
(logger_list = android_logger_list_open(
|
||||
LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
|
||||
|
||||
#ifdef __ANDROID__
|
||||
log_time ts(android_log_clockid());
|
||||
#else
|
||||
log_time ts(CLOCK_REALTIME);
|
||||
#endif
|
||||
|
||||
EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
|
||||
max_payload_buf, max_payload_buf));
|
||||
|
@ -1193,7 +1015,7 @@ TEST(liblog, __android_log_buf_print__maxtag) {
|
|||
android_log_format_free(logformat);
|
||||
}
|
||||
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(1, count);
|
||||
|
||||
android_logger_list_close(logger_list);
|
||||
#else
|
||||
|
@ -1202,8 +1024,7 @@ TEST(liblog, __android_log_buf_print__maxtag) {
|
|||
}
|
||||
|
||||
TEST(liblog, too_big_payload) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
pid_t pid = getpid();
|
||||
static const char big_payload_tag[] = "TEST_big_payload_XXXX";
|
||||
char tag[sizeof(big_payload_tag)];
|
||||
|
@ -1255,10 +1076,6 @@ TEST(liblog, too_big_payload) {
|
|||
|
||||
android_logger_list_close(logger_list);
|
||||
|
||||
#if !SUPPORTS_END_TO_END
|
||||
max_len =
|
||||
max_len ? max_len : LOGGER_ENTRY_MAX_PAYLOAD - sizeof(big_payload_tag);
|
||||
#endif
|
||||
EXPECT_LE(LOGGER_ENTRY_MAX_PAYLOAD - sizeof(big_payload_tag),
|
||||
static_cast<size_t>(max_len));
|
||||
|
||||
|
@ -1274,10 +1091,8 @@ TEST(liblog, too_big_payload) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef USING_LOGGER_DEFAULT
|
||||
TEST(liblog, dual_reader) {
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
|
||||
static const int num = 25;
|
||||
|
||||
|
@ -1332,15 +1147,13 @@ TEST(liblog, dual_reader) {
|
|||
android_logger_list_close(logger_list1);
|
||||
android_logger_list_close(logger_list2);
|
||||
|
||||
EXPECT_EQ(num * SUPPORTS_END_TO_END, count1);
|
||||
EXPECT_EQ((num - 10) * SUPPORTS_END_TO_END, count2);
|
||||
EXPECT_EQ(num, count1);
|
||||
EXPECT_EQ(num - 10, count2);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USING_LOGGER_DEFAULT // Do not retest logprint
|
||||
static bool checkPriForTag(AndroidLogFormat* p_format, const char* tag,
|
||||
android_LogPriority pri) {
|
||||
return android_log_shouldPrintLine(p_format, tag, pri) &&
|
||||
|
@ -1416,9 +1229,7 @@ TEST(liblog, filterRule) {
|
|||
|
||||
android_log_format_free(p_format);
|
||||
}
|
||||
#endif // USING_LOGGER_DEFAULT
|
||||
|
||||
#ifdef USING_LOGGER_DEFAULT // Do not retest property handling
|
||||
TEST(liblog, is_loggable) {
|
||||
#ifdef __ANDROID__
|
||||
static const char tag[] = "is_loggable";
|
||||
|
@ -1706,14 +1517,11 @@ TEST(liblog, is_loggable) {
|
|||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
#endif // USING_LOGGER_DEFAULT
|
||||
|
||||
// Following tests the specific issues surrounding error handling wrt logd.
|
||||
// Kills logd and toss all collected data, equivalent to logcat -b all -c,
|
||||
// except we also return errors to the logging callers.
|
||||
#ifdef USING_LOGGER_DEFAULT
|
||||
#ifdef __ANDROID__
|
||||
#ifdef TEST_PREFIX
|
||||
// helper to liblog.enoent to count end-to-end matching logging messages.
|
||||
static int count_matching_ts(log_time ts) {
|
||||
usleep(1000000);
|
||||
|
@ -1748,19 +1556,17 @@ static int count_matching_ts(log_time ts) {
|
|||
|
||||
return count;
|
||||
}
|
||||
#endif // TEST_PREFIX
|
||||
|
||||
TEST(liblog, enoent) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
if (getuid() != 0) {
|
||||
GTEST_SKIP() << "Skipping test, must be run as root.";
|
||||
return;
|
||||
}
|
||||
|
||||
TEST_PREFIX
|
||||
log_time ts(CLOCK_MONOTONIC);
|
||||
EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count_matching_ts(ts));
|
||||
EXPECT_EQ(1, count_matching_ts(ts));
|
||||
|
||||
// This call will fail unless we are root, beware of any
|
||||
// test prior to this one playing with setuid and causing interference.
|
||||
|
@ -1801,19 +1607,17 @@ TEST(liblog, enoent) {
|
|||
|
||||
ts = log_time(CLOCK_MONOTONIC);
|
||||
EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count_matching_ts(ts));
|
||||
EXPECT_EQ(1, count_matching_ts(ts));
|
||||
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
#endif // __ANDROID__
|
||||
#endif // USING_LOGGER_DEFAULT
|
||||
|
||||
// Below this point we run risks of setuid(AID_SYSTEM) which may affect others.
|
||||
|
||||
// Do not retest properties, and cannot log into LOG_ID_SECURITY
|
||||
#ifdef USING_LOGGER_DEFAULT
|
||||
TEST(liblog, __security) {
|
||||
#ifdef __ANDROID__
|
||||
static const char persist_key[] = "persist.logd.security";
|
||||
|
@ -2070,13 +1874,11 @@ TEST(liblog, __security_buffer) {
|
|||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
#endif // USING_LOGGER_DEFAULT
|
||||
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
static void android_errorWriteWithInfoLog_helper(int TAG, const char* SUBTAG,
|
||||
int UID, const char* payload,
|
||||
int DATA_LEN, int& count) {
|
||||
TEST_PREFIX
|
||||
struct logger_list* logger_list;
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
@ -2190,11 +1992,11 @@ static void android_errorWriteWithInfoLog_helper(int TAG, const char* SUBTAG,
|
|||
#endif
|
||||
|
||||
TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__typical) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
int count;
|
||||
android_errorWriteWithInfoLog_helper(UNIQUE_TAG(1), "test-subtag", -1,
|
||||
max_payload_buf, 200, count);
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(1, count);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
|
@ -2202,12 +2004,12 @@ TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__typical) {
|
|||
|
||||
TEST(liblog,
|
||||
android_errorWriteWithInfoLog__android_logger_list_read__data_too_large) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
int count;
|
||||
android_errorWriteWithInfoLog_helper(UNIQUE_TAG(2), "test-subtag", -1,
|
||||
max_payload_buf, sizeof(max_payload_buf),
|
||||
count);
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(1, count);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
|
@ -2215,7 +2017,7 @@ TEST(liblog,
|
|||
|
||||
TEST(liblog,
|
||||
android_errorWriteWithInfoLog__android_logger_list_read__null_data) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
int count;
|
||||
android_errorWriteWithInfoLog_helper(UNIQUE_TAG(3), "test-subtag", -1, NULL,
|
||||
200, count);
|
||||
|
@ -2227,12 +2029,12 @@ TEST(liblog,
|
|||
|
||||
TEST(liblog,
|
||||
android_errorWriteWithInfoLog__android_logger_list_read__subtag_too_long) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
int count;
|
||||
android_errorWriteWithInfoLog_helper(
|
||||
UNIQUE_TAG(4), "abcdefghijklmnopqrstuvwxyz now i know my abc", -1,
|
||||
max_payload_buf, 200, count);
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(1, count);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
|
@ -2246,10 +2048,9 @@ TEST(liblog, __android_log_buf_write_and_print__max) {
|
|||
buf_write_test(max_payload_buf);
|
||||
}
|
||||
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
static void android_errorWriteLog_helper(int TAG, const char* SUBTAG,
|
||||
int& count) {
|
||||
TEST_PREFIX
|
||||
struct logger_list* logger_list;
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
@ -2363,17 +2164,17 @@ static void android_errorWriteLog_helper(int TAG, const char* SUBTAG,
|
|||
#endif
|
||||
|
||||
TEST(liblog, android_errorWriteLog__android_logger_list_read__success) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
int count;
|
||||
android_errorWriteLog_helper(UNIQUE_TAG(5), "test-subtag", count);
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(1, count);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(liblog, android_errorWriteLog__android_logger_list_read__null_subtag) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
int count;
|
||||
android_errorWriteLog_helper(UNIQUE_TAG(6), NULL, count);
|
||||
EXPECT_EQ(0, count);
|
||||
|
@ -2383,7 +2184,7 @@ TEST(liblog, android_errorWriteLog__android_logger_list_read__null_subtag) {
|
|||
}
|
||||
|
||||
// Do not retest logger list handling
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
static int is_real_element(int type) {
|
||||
return ((type == EVENT_TYPE_INT) || (type == EVENT_TYPE_LONG) ||
|
||||
(type == EVENT_TYPE_STRING) || (type == EVENT_TYPE_FLOAT));
|
||||
|
@ -2538,9 +2339,9 @@ static int android_log_buffer_to_string(const char* msg, size_t len,
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif // TEST_PREFIX
|
||||
#endif // __ANDROID__
|
||||
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
static const char* event_test_int32(uint32_t tag, size_t& expected_len) {
|
||||
android_log_context ctx;
|
||||
|
||||
|
@ -2794,7 +2595,6 @@ static void print_barrier() {
|
|||
|
||||
static void create_android_logger(const char* (*fn)(uint32_t tag,
|
||||
size_t& expected_len)) {
|
||||
TEST_PREFIX
|
||||
struct logger_list* logger_list;
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
@ -2878,14 +2678,14 @@ static void create_android_logger(const char* (*fn)(uint32_t tag,
|
|||
EXPECT_EQ(0, strcmp(expected_string, msgBuf));
|
||||
}
|
||||
|
||||
EXPECT_EQ(SUPPORTS_END_TO_END, count);
|
||||
EXPECT_EQ(1, count);
|
||||
|
||||
android_logger_list_close(logger_list);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(liblog, create_android_logger_int32) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_int32);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2893,7 +2693,7 @@ TEST(liblog, create_android_logger_int32) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_int64) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_int64);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2901,7 +2701,7 @@ TEST(liblog, create_android_logger_int64) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_list_int64) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_list_int64);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2909,7 +2709,7 @@ TEST(liblog, create_android_logger_list_int64) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_simple_automagic_list) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_simple_automagic_list);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2917,7 +2717,7 @@ TEST(liblog, create_android_logger_simple_automagic_list) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_list_empty) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_list_empty);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2925,7 +2725,7 @@ TEST(liblog, create_android_logger_list_empty) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_complex_nested_list) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_complex_nested_list);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2933,7 +2733,7 @@ TEST(liblog, create_android_logger_complex_nested_list) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_7_level_prefix) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_7_level_prefix);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2941,7 +2741,7 @@ TEST(liblog, create_android_logger_7_level_prefix) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_7_level_suffix) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_7_level_suffix);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2949,7 +2749,7 @@ TEST(liblog, create_android_logger_7_level_suffix) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_android_log_error_write) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_android_log_error_write);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
|
@ -2957,14 +2757,13 @@ TEST(liblog, create_android_logger_android_log_error_write) {
|
|||
}
|
||||
|
||||
TEST(liblog, create_android_logger_android_log_error_write_null) {
|
||||
#ifdef TEST_PREFIX
|
||||
#ifdef __ANDROID__
|
||||
create_android_logger(event_test_android_log_error_write_null);
|
||||
#else
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USING_LOGGER_DEFAULT // Do not retest logger list handling
|
||||
TEST(liblog, create_android_logger_overflow) {
|
||||
android_log_context ctx;
|
||||
|
||||
|
@ -2991,9 +2790,7 @@ TEST(liblog, create_android_logger_overflow) {
|
|||
EXPECT_LE(0, android_log_destroy(&ctx));
|
||||
ASSERT_TRUE(NULL == ctx);
|
||||
}
|
||||
#endif // USING_LOGGER_DEFAULT
|
||||
|
||||
#ifdef USING_LOGGER_DEFAULT // Do not retest pmsg functionality
|
||||
#ifdef __ANDROID__
|
||||
#ifndef NO_PSTORE
|
||||
static const char __pmsg_file[] =
|
||||
|
@ -3130,9 +2927,7 @@ TEST(liblog, __android_log_pmsg_file_read) {
|
|||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
#endif // USING_LOGGER_DEFAULT
|
||||
|
||||
#ifdef USING_LOGGER_DEFAULT // Do not retest event mapping functionality
|
||||
TEST(liblog, android_lookupEventTagNum) {
|
||||
#ifdef __ANDROID__
|
||||
EventTagMap* map = android_openEventTagMap(NULL);
|
||||
|
@ -3149,4 +2944,3 @@ TEST(liblog, android_lookupEventTagNum) {
|
|||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif
|
||||
}
|
||||
#endif // USING_LOGGER_DEFAULT
|
||||
|
|
Loading…
Reference in a new issue