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/netdb_test.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tests/netdb_test.cpp') diff --git a/tests/netdb_test.cpp b/tests/netdb_test.cpp index a8056935b..020570762 100644 --- a/tests/netdb_test.cpp +++ b/tests/netdb_test.cpp @@ -265,11 +265,18 @@ TEST(netdb, gethostbyaddr_r) { ASSERT_EQ(0, hp->h_addr[0]); } +#if defined(MUSL) +// musl doesn't define NETDB_INTERNAL. It also never sets *err to -1, but +// since gethostbyname_r is a glibc extension, the difference in behavior +// between musl and glibc should probably be considered a bug in musl. +#define NETDB_INTERNAL -1 +#endif + TEST(netdb, gethostbyname_r_ERANGE) { hostent hent; hostent *hp; char buf[4]; // Use too small buffer. - int err; + int err = 0; int result = gethostbyname_r("localhost", &hent, buf, sizeof(buf), &hp, &err); EXPECT_EQ(NETDB_INTERNAL, err); EXPECT_EQ(ERANGE, result); @@ -280,7 +287,7 @@ TEST(netdb, gethostbyname2_r_ERANGE) { hostent hent; hostent *hp; char buf[4]; // Use too small buffer. - int err; + int err = 0; int result = gethostbyname2_r("localhost", AF_INET, &hent, buf, sizeof(buf), &hp, &err); EXPECT_EQ(NETDB_INTERNAL, err); EXPECT_EQ(ERANGE, result); @@ -292,7 +299,7 @@ TEST(netdb, gethostbyaddr_r_ERANGE) { hostent hent; hostent *hp; char buf[4]; // Use too small buffer. - int err; + int err = 0; int result = gethostbyaddr_r(&addr, sizeof(addr), AF_INET, &hent, buf, sizeof(buf), &hp, &err); EXPECT_EQ(NETDB_INTERNAL, err); EXPECT_EQ(ERANGE, result); -- cgit v1.2.3