Add posix_strerror_r and ErrnoNumberAsString to libbase
Calling strerror_r is tricky, as glibc provides the GNU version
if _GNU_SOURCE is set, and musl libc only provides the posix version.
Handle the complexity once in libbase to export a posix_strerror_r
function, and move update_engine's ErrnoNumberAsString into libbase.
Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Test: atest --host libbase_test
Change-Id: Ied24f5bb8cf34fc7948d129c368ee17adb1460e1
diff --git a/strings_test.cpp b/strings_test.cpp
index 7a57489..fb111b8 100644
--- a/strings_test.cpp
+++ b/strings_test.cpp
@@ -400,3 +400,7 @@
ASSERT_EQ("xxyzx", android::base::StringReplace("abcxyzabc", "abc", "x", true));
ASSERT_EQ("<xx>", android::base::StringReplace("<abcabc>", "abc", "x", true));
}
+
+TEST(strings, ErrnoNumberAsString) {
+ EXPECT_EQ("No such file or directory", android::base::ErrnoNumberAsString(ENOENT));
+}