summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2017-11-17 00:34:00 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-11-17 00:34:00 +0000
commit99a9a1ab483f8ea3a932c450194d26e6e77a903b (patch)
treeb0edff7ceb7ec04cbd37f5983355ea5686e2c727
parent9cdc82735a035d07d39e2ca2f1d680740aa404ee (diff)
parent7b34ff60ba05c5b91766ec719f3077d200c0eb3a (diff)
downloadcore-oreo-vts-release.tar.gz
Merge "Snap for 4455664 from c728d76e09bea3fa6779267d919fdd44703e746e to oreo-vts-release" into oreo-vts-releaseandroid-vts-8.0_r9android-vts-8.0_r8android-vts-8.0_r7android-vts-8.0_r6android-vts-8.0_r13android-vts-8.0_r12android-vts-8.0_r11android-vts-8.0_r10oreo-vts-release
-rw-r--r--liblog/tests/Android.mk9
-rw-r--r--liblog/tests/liblog_test.cpp31
-rw-r--r--libutils/Unicode.cpp23
3 files changed, 34 insertions, 29 deletions
diff --git a/liblog/tests/Android.mk b/liblog/tests/Android.mk
index 0e6432ced..3027fc563 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 := \
liblog_test_default.cpp \
liblog_test_local.cpp \
liblog_test_stderr.cpp \
@@ -65,6 +65,9 @@ test_src_files := \
log_system_test.cpp \
log_time_test.cpp
+test_src_files := \
+ $(cts_src_files) \
+
# to prevent breaking the build if bionic not relatively visible to us
ifneq ($(wildcard $(LOCAL_PATH)/../../../../bionic/libc/bionic/libc_logging.cpp),)
@@ -88,8 +91,8 @@ 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
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index 71f74abb1..11c15ab4a 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -116,6 +116,7 @@ static std::string popenToString(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
@@ -3034,12 +3041,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;
@@ -3090,12 +3100,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);
@@ -3116,10 +3130,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();
@@ -3153,6 +3169,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
diff --git a/libutils/Unicode.cpp b/libutils/Unicode.cpp
index 6cff0f476..5fd915524 100644
--- a/libutils/Unicode.cpp
+++ b/libutils/Unicode.cpp
@@ -180,15 +180,7 @@ ssize_t utf32_to_utf8_length(const char32_t *src, size_t src_len)
size_t ret = 0;
const char32_t *end = src + src_len;
while (src < end) {
- size_t char_len = utf32_codepoint_utf8_length(*src++);
- if (SSIZE_MAX - char_len < ret) {
- // If this happens, we would overflow the ssize_t type when
- // returning from this function, so we cannot express how
- // long this string is in an ssize_t.
- android_errorWriteLog(0x534e4554, "37723026");
- return -1;
- }
- ret += char_len;
+ ret += utf32_codepoint_utf8_length(*src++);
}
return ret;
}
@@ -448,23 +440,14 @@ ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len)
size_t ret = 0;
const char16_t* const end = src + src_len;
while (src < end) {
- size_t char_len;
if ((*src & 0xFC00) == 0xD800 && (src + 1) < end
&& (*(src + 1) & 0xFC00) == 0xDC00) {
// surrogate pairs are always 4 bytes.
- char_len = 4;
+ ret += 4;
src += 2;
} else {
- char_len = utf32_codepoint_utf8_length((char32_t)*src++);
- }
- if (SSIZE_MAX - char_len < ret) {
- // If this happens, we would overflow the ssize_t type when
- // returning from this function, so we cannot express how
- // long this string is in an ssize_t.
- android_errorWriteLog(0x534e4554, "37723026");
- return -1;
+ ret += utf32_codepoint_utf8_length((char32_t) *src++);
}
- ret += char_len;
}
return ret;
}