From 7da20341e91a4ece30f628fb91fbc6056c9c8a7c Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 28 Jul 2021 11:18:11 -0700 Subject: 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 --- tests/resolv_test.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/resolv_test.cpp') diff --git a/tests/resolv_test.cpp b/tests/resolv_test.cpp index 5743239d0..7f1f03e0c 100644 --- a/tests/resolv_test.cpp +++ b/tests/resolv_test.cpp @@ -31,6 +31,7 @@ #include TEST(resolv, b64_pton_28035006) { +#if !defined(MUSL) // Test data from https://groups.google.com/forum/#!topic/mailing.openbsd.tech/w3ACIlklJkI. const char* data = "p1v3+nehH3N3n+/OokzXpsyGF2VVpxIxkjSn3Mv/Sq74OE1iFuVU+K4bQImuVj" @@ -41,32 +42,51 @@ TEST(resolv, b64_pton_28035006) { // incorrectly required an extra byte. http://b/28035006. uint8_t buf[128]; ASSERT_EQ(128, b64_pton(data, buf, sizeof(buf))); +#else + GTEST_SKIP() << "musl doesn't have b64_pton"; +#endif } TEST(resolv, b64_ntop) { +#if !defined(MUSL) char buf[128]; memset(buf, 'x', sizeof(buf)); ASSERT_EQ(static_cast(strlen("aGVsbG8=")), b64_ntop(reinterpret_cast("hello"), strlen("hello"), buf, sizeof(buf))); ASSERT_STREQ(buf, "aGVsbG8="); +#else + GTEST_SKIP() << "musl doesn't have b64_ntop"; +#endif } TEST(resolv, b64_pton) { +#if !defined(MUSL) u_char buf[128]; memset(buf, 'x', sizeof(buf)); ASSERT_EQ(static_cast(strlen("hello")), b64_pton("aGVsbG8=", buf, sizeof(buf))); ASSERT_STREQ(reinterpret_cast(buf), "hello"); +#else + GTEST_SKIP() << "musl doesn't have b64_pton"; +#endif } TEST(resolv, p_class) { +#if !defined(MUSL) ASSERT_STREQ("IN", p_class(ns_c_in)); ASSERT_STREQ("BADCLASS", p_class(-1)); +#else + GTEST_SKIP() << "musl doesn't have p_class"; +#endif } TEST(resolv, p_type) { +#if !defined(MUSL) ASSERT_STREQ("AAAA", p_type(ns_t_aaaa)); ASSERT_STREQ("BADTYPE", p_type(-1)); +#else + GTEST_SKIP() << "musl doesn't have p_type"; +#endif } TEST(resolv, res_init) { @@ -74,5 +94,9 @@ TEST(resolv, res_init) { } TEST(resolv, res_randomid) { +#if !defined(MUSL) res_randomid(); +#else + GTEST_SKIP() << "musl doesn't have res_randomid"; +#endif } -- cgit v1.2.3