summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2017-11-14 12:12:57 -0800
committerXin Li <delphij@google.com>2017-11-14 13:19:45 -0800
commit23e27db576d06761363365494327baf062468a66 (patch)
treecc76a40025c2189fc70dd6edd4a0eba251fd7b44 /liblog
parentea41bcf7a3a9095feb39cc6bd37d865c2eec3c36 (diff)
parenta63ccea6abc7ea02e2d98e41c80793ca97237bd3 (diff)
downloadcore-23e27db576d06761363365494327baf062468a66.tar.gz
core-23e27db576d06761363365494327baf062468a66.tar.bz2
core-23e27db576d06761363365494327baf062468a66.zip
Merge commit 'a63ccea6abc7ea02e2d98e41c80793ca97237bd3' from
oc-mr1-dev-plus-aosp into stage-aosp-master Change-Id: Ia33311cd1fd26dfaea59a69317b306fb91203c40 Merged-In: I03d06b10807e8a313c9654c2e1db36bfb59e3f99
Diffstat (limited to 'liblog')
-rw-r--r--liblog/tests/Android.mk11
-rw-r--r--liblog/tests/liblog_test.cpp31
2 files changed, 32 insertions, 10 deletions
diff --git a/liblog/tests/Android.mk b/liblog/tests/Android.mk
index 275a2d681..39b52ac35 100644
--- a/liblog/tests/Android.mk
+++ b/liblog/tests/Android.mk
@@ -54,7 +54,7 @@ test_c_flags := \
-Werror \
-fno-builtin \
-test_src_files := \
+cts_src_files := \
libc_test.cpp \
liblog_test_default.cpp \
liblog_test_local.cpp \
@@ -67,6 +67,9 @@ test_src_files := \
log_time_test.cpp \
log_wrap_test.cpp
+test_src_files := \
+ $(cts_src_files) \
+
# Build tests for the device (with .so). Run with:
# adb shell /data/nativetest/liblog-unit-tests/liblog-unit-tests
include $(CLEAR_VARS)
@@ -82,15 +85,15 @@ cts_executable := CtsLiblogTestCases
include $(CLEAR_VARS)
LOCAL_MODULE := $(cts_executable)
LOCAL_MODULE_TAGS := tests
-LOCAL_CFLAGS += $(test_c_flags)
-LOCAL_SRC_FILES := $(test_src_files)
+LOCAL_CFLAGS += $(test_c_flags) -DNO_PSTORE
+LOCAL_SRC_FILES := $(cts_src_files)
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
LOCAL_MULTILIB := both
LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
LOCAL_SHARED_LIBRARIES := liblog libcutils libbase
LOCAL_STATIC_LIBRARIES := libgtest libgtest_main
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.core.liblog
include $(BUILD_CTS_EXECUTABLE)
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index e2d5aeb46..597a6bb90 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -116,6 +116,7 @@ static std::string popenToString(const std::string& command) {
return ret;
}
+#ifndef NO_PSTORE
static bool isPmsgActive() {
pid_t pid = getpid();
@@ -125,6 +126,7 @@ static bool isPmsgActive() {
return std::string::npos != myPidFds.find(" -> /dev/pmsg0");
}
+#endif /* NO_PSTORE */
static bool isLogdwActive() {
std::string logdwSignature =
@@ -189,22 +191,25 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
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 pmsgActiveAfter__android_log_btwrite;
bool logdwActiveAfter__android_log_btwrite;
if (getuid() == AID_ROOT) {
tested__android_log_close = true;
- pmsgActiveAfter__android_log_btwrite = isPmsgActive();
- logdwActiveAfter__android_log_btwrite = isLogdwActive();
+#ifndef NO_PSTORE
+ bool pmsgActiveAfter__android_log_btwrite = isPmsgActive();
EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
+#endif /* NO_PSTORE */
+ logdwActiveAfter__android_log_btwrite = isLogdwActive();
EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
} else if (!tested__android_log_close) {
fprintf(stderr, "WARNING: can not test __android_log_close()\n");
}
__android_log_close();
if (getuid() == AID_ROOT) {
+#ifndef NO_PSTORE
bool pmsgActiveAfter__android_log_close = isPmsgActive();
- bool logdwActiveAfter__android_log_close = isLogdwActive();
EXPECT_FALSE(pmsgActiveAfter__android_log_close);
+#endif /* NO_PSTORE */
+ bool logdwActiveAfter__android_log_close = isLogdwActive();
EXPECT_FALSE(logdwActiveAfter__android_log_close);
}
#endif
@@ -213,9 +218,11 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts1, sizeof(ts1)));
#ifdef USING_LOGGER_DEFAULT
if (getuid() == AID_ROOT) {
- pmsgActiveAfter__android_log_btwrite = isPmsgActive();
- logdwActiveAfter__android_log_btwrite = isLogdwActive();
+#ifndef NO_PSTORE
+ bool pmsgActiveAfter__android_log_btwrite = isPmsgActive();
EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
+#endif /* NO_PSTORE */
+ logdwActiveAfter__android_log_btwrite = isLogdwActive();
EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
}
#endif
@@ -3036,12 +3043,15 @@ TEST(liblog, android_log_write_list_buffer) {
#ifdef USING_LOGGER_DEFAULT // Do not retest pmsg functionality
#ifdef __ANDROID__
+#ifndef NO_PSTORE
static const char __pmsg_file[] =
"/data/william-shakespeare/MuchAdoAboutNothing.txt";
+#endif /* NO_PSTORE */
#endif
TEST(liblog, __android_log_pmsg_file_write) {
#ifdef __ANDROID__
+#ifndef NO_PSTORE
__android_log_close();
if (getuid() == AID_ROOT) {
tested__android_log_close = true;
@@ -3092,12 +3102,16 @@ TEST(liblog, __android_log_pmsg_file_write) {
EXPECT_TRUE(pmsgActiveAfter__android_pmsg_file_write);
EXPECT_TRUE(logdwActiveAfter__android_pmsg_file_write);
}
+#else /* NO_PSTORE */
+ GTEST_LOG_(INFO) << "This test does nothing because of NO_PSTORE.\n";
+#endif /* NO_PSTORE */
#else
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif
}
#ifdef __ANDROID__
+#ifndef NO_PSTORE
static ssize_t __pmsg_fn(log_id_t logId, char prio, const char* filename,
const char* buf, size_t len, void* arg) {
EXPECT_TRUE(NULL == arg);
@@ -3118,10 +3132,12 @@ static ssize_t __pmsg_fn(log_id_t logId, char prio, const char* filename,
? -ENOEXEC
: 1;
}
+#endif /* NO_PSTORE */
#endif
TEST(liblog, __android_log_pmsg_file_read) {
#ifdef __ANDROID__
+#ifndef NO_PSTORE
signaled = 0;
__android_log_close();
@@ -3155,6 +3171,9 @@ TEST(liblog, __android_log_pmsg_file_read) {
EXPECT_LT(0, ret);
EXPECT_EQ(1U, signaled);
+#else /* NO_PSTORE */
+ GTEST_LOG_(INFO) << "This test does nothing because of NO_PSTORE.\n";
+#endif /* NO_PSTORE */
#else
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif