Build bionic unit tests for musl
Modify bionic unit tests that are built for glibc so that they also
build against musl. They don't all pass though:
With glibc:
2 SLOW TESTS
4 TIMEOUT TESTS
313 FAILED TESTS
YOU HAVE 2 DISABLED TESTS
With musl:
11 SLOW TESTS
11 TIMEOUT TESTS
363 FAILED TESTS
YOU HAVE 2 DISABLED TESTS
Bug: 190084016
Test: m bionic-unit-tests-glibc with musl
Test: atest bionic-unit-tests-static
Test: atest --host bionic-unit-tests-glibc with glibc
Change-Id: I79b6eab04fed3cc4392450df5eef2579412edfe1
diff --git a/tests/libgen_basename_test.cpp b/tests/libgen_basename_test.cpp
index 91ae960..1202af6 100644
--- a/tests/libgen_basename_test.cpp
+++ b/tests/libgen_basename_test.cpp
@@ -18,6 +18,7 @@
#define _GNU_SOURCE 1
#endif
+#if !defined(MUSL)
#include <string.h>
#if defined(basename)
@@ -28,9 +29,11 @@
return basename(in);
}
+#endif
+
#include <libgen.h>
-#if !defined(basename)
+#if !defined(basename) && !defined(MUSL)
#error basename should be defined at this point
#endif
@@ -41,12 +44,14 @@
#include <errno.h>
#include <gtest/gtest.h>
+#if !defined(MUSL)
static void __TestGnuBasename(const char* in, const char* expected_out, int line) {
errno = 0;
const char* out = gnu_basename(in);
ASSERT_STREQ(expected_out, out) << "(" << line << "): " << in << std::endl;
ASSERT_EQ(0, errno) << "(" << line << "): " << in << std::endl;
}
+#endif
static void __TestPosixBasename(const char* in, const char* expected_out, int line) {
char* writable_in = (in != nullptr) ? strdup(in) : nullptr;
@@ -61,6 +66,7 @@
#define TestPosixBasename(in, expected) __TestPosixBasename(in, expected, __LINE__)
TEST(libgen_basename, gnu_basename) {
+#if !defined(MUSL)
// GNU's basename doesn't accept NULL
// TestGnuBasename(NULL, ".");
TestGnuBasename("", "");
@@ -73,6 +79,9 @@
TestGnuBasename("..", "..");
TestGnuBasename("///", "");
TestGnuBasename("//usr//lib//", "");
+#else
+ GTEST_SKIP() << "musl doesn't have GNU basename";
+ #endif
}
TEST(libgen_basename, posix_basename) {