Clean up internal libc logging.
We only need one logging API, and I prefer the one that does no
allocation and is thus safe to use in any context.
Also use O_CLOEXEC when opening the /dev/log files.
Move everything logging-related into one header file.
Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
diff --git a/tests/Android.mk b/tests/Android.mk
index 46427ec..491b13c 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -57,11 +57,11 @@
-fno-builtin \
test_src_files = \
- debug_format_test.cpp \
dirent_test.cpp \
fenv_test.cpp \
getauxval_test.cpp \
getcwd_test.cpp \
+ libc_logging_test.cpp \
libgen_test.cpp \
math_test.cpp \
netdb_test.cpp \
diff --git a/tests/debug_format_test.cpp b/tests/libc_logging_test.cpp
similarity index 93%
rename from tests/debug_format_test.cpp
rename to tests/libc_logging_test.cpp
index 8419e4a..d9c615e 100644
--- a/tests/debug_format_test.cpp
+++ b/tests/libc_logging_test.cpp
@@ -18,11 +18,11 @@
#if defined(__BIONIC__)
-#include "../libc/bionic/debug_format.cpp"
+#include "../libc/bionic/libc_logging.cpp"
extern int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...);
-TEST(debug_format, smoke) {
+TEST(libc_logging, smoke) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "a");
@@ -106,37 +106,37 @@
EXPECT_STREQ("a68719476736,6,7,8z", buf);
}
-TEST(debug_format, d_INT_MAX) {
+TEST(libc_logging, d_INT_MAX) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%d", INT_MAX);
EXPECT_STREQ("2147483647", buf);
}
-TEST(debug_format, d_INT_MIN) {
+TEST(libc_logging, d_INT_MIN) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%d", INT_MIN);
EXPECT_STREQ("-2147483648", buf);
}
-TEST(debug_format, ld_LONG_MAX) {
+TEST(libc_logging, ld_LONG_MAX) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX);
EXPECT_STREQ("2147483647", buf);
}
-TEST(debug_format, ld_LONG_MIN) {
+TEST(libc_logging, ld_LONG_MIN) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN);
EXPECT_STREQ("-2147483648", buf);
}
-TEST(debug_format, lld_LLONG_MAX) {
+TEST(libc_logging, lld_LLONG_MAX) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%lld", LLONG_MAX);
EXPECT_STREQ("9223372036854775807", buf);
}
-TEST(debug_format, lld_LLONG_MIN) {
+TEST(libc_logging, lld_LLONG_MIN) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%lld", LLONG_MIN);
EXPECT_STREQ("-9223372036854775808", buf);