From fb50057138ef37232dc67c8559fd26719ee26021 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 12 Nov 2014 19:22:48 -0800 Subject: [PATCH] Fix glibc 2.15 build. glibc 2.15 has prlimit64, has an unsetenv that's declared nonnull, and hasn't fixed the problems we were having trying to use the POSIX strerror_r in C++ code. Change-Id: I834356a385e5ae55500bd86781691b6c1c9c8300 --- tests/string_posix_strerror_r_test.cpp | 25 ++++++++++++++++--------- tests/sys_resource_test.cpp | 11 ----------- tests/unistd_test.cpp | 3 --- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/tests/string_posix_strerror_r_test.cpp b/tests/string_posix_strerror_r_test.cpp index 09cebfecc..ae3b41abd 100644 --- a/tests/string_posix_strerror_r_test.cpp +++ b/tests/string_posix_strerror_r_test.cpp @@ -15,13 +15,23 @@ */ #undef _GNU_SOURCE +#include // Get __BIONIC__ or __GLIBC__ so we can tell what we're using. -// Old versions of glibc (like our current host prebuilt sysroot one) have -// headers that don't work if you #undef _GNU_SOURCE, which makes it -// impossible to build this test. -#include +#if defined(__GLIBC__) + +// At the time of writing, libcxx -- which is dragged in by gtest -- assumes +// declarations from glibc of things that aren't available without __USE_GNU. +// This means we can't even build this test (which is a problem because that +// means it doesn't get included in CTS). +// For glibc 2.15, the symbols in question are: +// at_quick_exit, quick_exit, vasprintf, strtoll_l, strtoull_l, and strtold_l. + +# if __GLIBC_PREREQ(2, 19) +# error check whether we can build this now... +# endif + +#else -#if !defined(__GLIBC__) #include #include @@ -50,8 +60,5 @@ TEST(string, posix_strerror_r) { // The POSIX strerror_r sets errno to ERANGE (the GNU one doesn't). ASSERT_EQ(ERANGE, errno); } -#else -# if __GLIBC_PREREQ(2, 15) -# error this test should work now -# endif + #endif diff --git a/tests/sys_resource_test.cpp b/tests/sys_resource_test.cpp index d6d99a095..91d07abea 100644 --- a/tests/sys_resource_test.cpp +++ b/tests/sys_resource_test.cpp @@ -18,17 +18,6 @@ #include -#if defined(__GLIBC__) -/* The host glibc we're currently building with doesn't have prlimit64 yet. */ -static int prlimit64(pid_t, int resource, const struct rlimit64* new_limit, struct rlimit64* old_limit) { - if (new_limit != NULL) { - return setrlimit64(resource, new_limit); - } else { - return getrlimit64(resource, old_limit); - } -} -#endif - TEST(sys_resource, smoke) { #if defined(__LP64__) || defined(__GLIBC__) ASSERT_EQ(sizeof(rlimit), sizeof(rlimit64)); diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp index 19d401773..c9d994363 100644 --- a/tests/unistd_test.cpp +++ b/tests/unistd_test.cpp @@ -29,7 +29,6 @@ #include #include - TEST(unistd, sysconf_SC_MONOTONIC_CLOCK) { ASSERT_GT(sysconf(_SC_MONOTONIC_CLOCK), 0); } @@ -250,8 +249,6 @@ TEST(unistd, getenv_unsetenv) { } TEST(unistd, unsetenv_EINVAL) { - EXPECT_EQ(-1, unsetenv(NULL)); - EXPECT_EQ(EINVAL, errno); EXPECT_EQ(-1, unsetenv("")); EXPECT_EQ(EINVAL, errno); EXPECT_EQ(-1, unsetenv("a=b"));