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/time_test.cpp b/tests/time_test.cpp
index b16fe16..932af9e 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -282,6 +282,7 @@
}
TEST(time, strptime_l) {
+#if !defined(MUSL)
setenv("TZ", "UTC", 1);
struct tm t;
@@ -296,6 +297,9 @@
strptime_l("09:41:53", "%T", &t, LC_GLOBAL_LOCALE);
strftime_l(buf, sizeof(buf), "%H:%M:%S", &t, LC_GLOBAL_LOCALE);
EXPECT_STREQ("09:41:53", buf);
+#else
+ GTEST_SKIP() << "musl doesn't support strptime_l";
+#endif
}
TEST(time, strptime_F) {
@@ -469,11 +473,11 @@
ASSERT_EQ(0, timer_settime(t, 0, &ts, nullptr));
}
-static void NoOpNotifyFunction(sigval_t) {
+static void NoOpNotifyFunction(sigval) {
}
TEST(time, timer_create) {
- sigevent_t se;
+ sigevent se;
memset(&se, 0, sizeof(se));
se.sigev_notify = SIGEV_THREAD;
se.sigev_notify_function = NoOpNotifyFunction;
@@ -502,7 +506,7 @@
}
TEST(time, timer_create_SIGEV_SIGNAL) {
- sigevent_t se;
+ sigevent se;
memset(&se, 0, sizeof(se));
se.sigev_notify = SIGEV_SIGNAL;
se.sigev_signo = SIGUSR1;
@@ -530,7 +534,7 @@
private:
std::atomic<int> value;
timer_t timer_id;
- sigevent_t se;
+ sigevent se;
bool timer_valid;
void Create() {
@@ -540,7 +544,7 @@
}
public:
- explicit Counter(void (*fn)(sigval_t)) : value(0), timer_valid(false) {
+ explicit Counter(void (*fn)(sigval)) : value(0), timer_valid(false) {
memset(&se, 0, sizeof(se));
se.sigev_notify = SIGEV_THREAD;
se.sigev_notify_function = fn;
@@ -575,12 +579,12 @@
return current_value != value;
}
- static void CountNotifyFunction(sigval_t value) {
+ static void CountNotifyFunction(sigval value) {
Counter* cd = reinterpret_cast<Counter*>(value.sival_ptr);
++cd->value;
}
- static void CountAndDisarmNotifyFunction(sigval_t value) {
+ static void CountAndDisarmNotifyFunction(sigval value) {
Counter* cd = reinterpret_cast<Counter*>(value.sival_ptr);
++cd->value;
@@ -644,7 +648,7 @@
ASSERT_EQ(EINVAL, errno);
// A SIGEV_THREAD timer is more interesting because we have stuff to clean up.
- sigevent_t se;
+ sigevent se;
memset(&se, 0, sizeof(se));
se.sigev_notify = SIGEV_THREAD;
se.sigev_notify_function = NoOpNotifyFunction;
@@ -715,7 +719,7 @@
volatile bool complete;
};
-static void TimerDeleteCallback(sigval_t value) {
+static void TimerDeleteCallback(sigval value) {
TimerDeleteData* tdd = reinterpret_cast<TimerDeleteData*>(value.sival_ptr);
tdd->tid = gettid();
@@ -725,7 +729,7 @@
TEST(time, timer_delete_from_timer_thread) {
TimerDeleteData tdd;
- sigevent_t se;
+ sigevent se;
memset(&se, 0, sizeof(se));
se.sigev_notify = SIGEV_THREAD;