am 4482091b: Merge "Consistently use #if defined(__BIONIC__) in tests."

* commit '4482091b1d1611aa395931656b94bfd8ffd583bf':
  Consistently use #if defined(__BIONIC__) in tests.
This commit is contained in:
Elliott Hughes 2014-05-13 18:35:49 +00:00 committed by Android Git Automerger
commit 492e8f7250
11 changed files with 22 additions and 22 deletions

View File

@ -53,7 +53,7 @@ TEST(dlfcn, dlsym_in_self) {
TEST(dlfcn, dlopen_failure) { TEST(dlfcn, dlopen_failure) {
void* self = dlopen("/does/not/exist", RTLD_NOW); void* self = dlopen("/does/not/exist", RTLD_NOW);
ASSERT_TRUE(self == NULL); ASSERT_TRUE(self == NULL);
#if __BIONIC__ #if defined(__BIONIC__)
ASSERT_STREQ("dlopen failed: library \"/does/not/exist\" not found", dlerror()); ASSERT_STREQ("dlopen failed: library \"/does/not/exist\" not found", dlerror());
#else #else
ASSERT_STREQ("/does/not/exist: cannot open shared object file: No such file or directory", dlerror()); ASSERT_STREQ("/does/not/exist: cannot open shared object file: No such file or directory", dlerror());
@ -92,14 +92,14 @@ TEST(dlfcn, dlsym_failures) {
// NULL handle. // NULL handle.
sym = dlsym(NULL, "test"); sym = dlsym(NULL, "test");
ASSERT_TRUE(sym == NULL); ASSERT_TRUE(sym == NULL);
#if __BIONIC__ #if defined(__BIONIC__)
ASSERT_SUBSTR("dlsym library handle is null", dlerror()); ASSERT_SUBSTR("dlsym library handle is null", dlerror());
#else #else
ASSERT_SUBSTR("undefined symbol: test", dlerror()); // glibc isn't specific about the failure. ASSERT_SUBSTR("undefined symbol: test", dlerror()); // glibc isn't specific about the failure.
#endif #endif
// NULL symbol name. // NULL symbol name.
#if __BIONIC__ #if defined(__BIONIC__)
// glibc marks this parameter non-null and SEGVs if you cheat. // glibc marks this parameter non-null and SEGVs if you cheat.
sym = dlsym(self, NULL); sym = dlsym(self, NULL);
ASSERT_TRUE(sym == NULL); ASSERT_TRUE(sym == NULL);
@ -206,7 +206,7 @@ TEST(dlfcn, dlopen_bad_flags) {
dlerror(); // Clear any pending errors. dlerror(); // Clear any pending errors.
void* handle; void* handle;
#ifdef __GLIBC__ #if defined(__GLIBC__)
// glibc was smart enough not to define RTLD_NOW as 0, so it can detect missing flags. // glibc was smart enough not to define RTLD_NOW as 0, so it can detect missing flags.
handle = dlopen(NULL, 0); handle = dlopen(NULL, 0);
ASSERT_TRUE(handle == NULL); ASSERT_TRUE(handle == NULL);

View File

@ -73,7 +73,7 @@ TEST(fcntl, creat_creat64) {
TEST(fcntl, fallocate_EINVAL) { TEST(fcntl, fallocate_EINVAL) {
TemporaryFile tf; TemporaryFile tf;
#if !defined(__GLIBC__) #if defined(__BIONIC__)
errno = 0; errno = 0;
ASSERT_EQ(-1, fallocate(tf.fd, 0, 0, -1)); ASSERT_EQ(-1, fallocate(tf.fd, 0, 0, -1));
ASSERT_EQ(EINVAL, errno); ASSERT_EQ(EINVAL, errno);
@ -98,7 +98,7 @@ TEST(fcntl, fallocate) {
ASSERT_EQ(0, fstat(tf.fd, &sb)); ASSERT_EQ(0, fstat(tf.fd, &sb));
ASSERT_EQ(0, sb.st_size); ASSERT_EQ(0, sb.st_size);
#if !defined(__GLIBC__) #if defined(__BIONIC__)
ASSERT_EQ(0, fallocate(tf.fd, 0, 0, 1)); ASSERT_EQ(0, fallocate(tf.fd, 0, 0, 1));
ASSERT_EQ(0, fstat(tf.fd, &sb)); ASSERT_EQ(0, fstat(tf.fd, &sb));
ASSERT_EQ(1, sb.st_size); ASSERT_EQ(1, sb.st_size);

View File

@ -668,7 +668,7 @@ TEST(DEATHTEST, recv_fortified) {
} }
TEST(DEATHTEST, FD_ISSET_fortified) { TEST(DEATHTEST, FD_ISSET_fortified) {
#ifdef __BIONIC__ // glibc catches this at compile-time. #if defined(__BIONIC__) // glibc catches this at compile-time.
::testing::FLAGS_gtest_death_test_style = "threadsafe"; ::testing::FLAGS_gtest_death_test_style = "threadsafe";
fd_set set; fd_set set;
memset(&set, 0, sizeof(set)); memset(&set, 0, sizeof(set));

View File

@ -58,7 +58,7 @@ TEST(locale, setlocale) {
EXPECT_EQ(NULL, setlocale(13, NULL)); EXPECT_EQ(NULL, setlocale(13, NULL));
EXPECT_EQ(EINVAL, errno); EXPECT_EQ(EINVAL, errno);
#if __BIONIC__ #if defined(__BIONIC__)
// The "" locale is implementation-defined. For bionic, it's the C locale. // The "" locale is implementation-defined. For bionic, it's the C locale.
// glibc will give us something like "en_US.UTF-8", depending on the user's configuration. // glibc will give us something like "en_US.UTF-8", depending on the user's configuration.
EXPECT_STREQ("C", setlocale(LC_ALL, "")); EXPECT_STREQ("C", setlocale(LC_ALL, ""));

View File

@ -28,7 +28,7 @@ TEST(regex, smoke) {
char buf[80]; char buf[80];
regerror(REG_NOMATCH, &re, buf, sizeof(buf)); regerror(REG_NOMATCH, &re, buf, sizeof(buf));
#if __BIONIC__ #if defined(__BIONIC__)
ASSERT_STREQ("regexec() failed to match", buf); ASSERT_STREQ("regexec() failed to match", buf);
#else #else
ASSERT_STREQ("No match", buf); ASSERT_STREQ("No match", buf);

View File

@ -21,7 +21,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#ifdef __BIONIC__ #if defined(__BIONIC__)
static int child_fn(void* i_ptr) { static int child_fn(void* i_ptr) {
*reinterpret_cast<int*>(i_ptr) = 42; *reinterpret_cast<int*>(i_ptr) = 42;
return 123; return 123;

View File

@ -219,7 +219,7 @@ TEST(stdio, snprintf_ls) {
} }
TEST(stdio, snprintf_n) { TEST(stdio, snprintf_n) {
#if !defined(__GLIBC__) #if defined(__BIONIC__)
// http://b/14492135 // http://b/14492135
char buf[32]; char buf[32];
int i = 1234; int i = 1234;
@ -460,7 +460,7 @@ TEST(stdio, cantwrite_EBADF) {
errno = 0; errno = 0;
EXPECT_EQ(EOF, fwprintf(fp, L"hello")); EXPECT_EQ(EOF, fwprintf(fp, L"hello"));
#if !defined(__GLIBC__) #if defined(__BIONIC__)
EXPECT_EQ(EBADF, errno); EXPECT_EQ(EBADF, errno);
#endif #endif
@ -478,7 +478,7 @@ TEST(stdio, cantwrite_EBADF) {
errno = 0; errno = 0;
EXPECT_EQ(WEOF, fputwc(L'x', fp)); EXPECT_EQ(WEOF, fputwc(L'x', fp));
#if !defined(__GLIBC__) #if defined(__BIONIC__)
EXPECT_EQ(EBADF, errno); EXPECT_EQ(EBADF, errno);
#endif #endif
} }
@ -521,7 +521,7 @@ TEST(stdio, consistent_fpos_t) {
ASSERT_EQ(mb_four_bytes, static_cast<wchar_t>(fgetwc(fp))); ASSERT_EQ(mb_four_bytes, static_cast<wchar_t>(fgetwc(fp)));
EXPECT_EQ(0, fgetpos(fp, &pos5)); EXPECT_EQ(0, fgetpos(fp, &pos5));
#ifdef __BIONIC__ #if defined(__BIONIC__)
// Bionic's fpos_t is just an alias for off_t. This is inherited from OpenBSD // Bionic's fpos_t is just an alias for off_t. This is inherited from OpenBSD
// upstream. Glibc differs by storing the mbstate_t inside its fpos_t. In // upstream. Glibc differs by storing the mbstate_t inside its fpos_t. In
// Bionic (and upstream OpenBSD) the mbstate_t is stored inside the FILE // Bionic (and upstream OpenBSD) the mbstate_t is stored inside the FILE
@ -586,9 +586,9 @@ TEST(stdio, fpos_t_and_seek) {
// Store the "inside multi byte" position. // Store the "inside multi byte" position.
fpos_t pos_inside_mb; fpos_t pos_inside_mb;
ASSERT_EQ(0, fgetpos(fp, &pos_inside_mb)); ASSERT_EQ(0, fgetpos(fp, &pos_inside_mb));
#ifdef __BIONIC__ #if defined(__BIONIC__)
ASSERT_EQ(offset_inside_mb, static_cast<off_t>(pos_inside_mb)); ASSERT_EQ(offset_inside_mb, static_cast<off_t>(pos_inside_mb));
#endif #endif
// Reading from within a byte should produce an error. // Reading from within a byte should produce an error.
ASSERT_EQ(WEOF, fgetwc(fp)); ASSERT_EQ(WEOF, fgetwc(fp));

View File

@ -42,7 +42,7 @@ TEST(stdlib, lrand48_random_rand) {
EXPECT_EQ(902267124, lrand48()); EXPECT_EQ(902267124, lrand48());
EXPECT_EQ(132366131, lrand48()); EXPECT_EQ(132366131, lrand48());
#if __BIONIC__ #if defined(__BIONIC__)
// On bionic, random(3) is equivalent to lrand48... // On bionic, random(3) is equivalent to lrand48...
srandom(0x01020304); srandom(0x01020304);
EXPECT_EQ(1409163720, random()); EXPECT_EQ(1409163720, random());

View File

@ -18,7 +18,7 @@
#include <sys/resource.h> #include <sys/resource.h>
#if __GLIBC__ #if defined(__GLIBC__)
/* The host glibc we're currently building with doesn't have prlimit64 yet. */ /* 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) { static int prlimit64(pid_t, int resource, const struct rlimit64* new_limit, struct rlimit64* old_limit) {
if (new_limit != NULL) { if (new_limit != NULL) {
@ -30,7 +30,7 @@ static int prlimit64(pid_t, int resource, const struct rlimit64* new_limit, stru
#endif #endif
TEST(sys_resource, smoke) { TEST(sys_resource, smoke) {
#if __LP64__ || __GLIBC__ #if defined(__LP64__) || defined(__GLIBC__)
ASSERT_EQ(sizeof(rlimit), sizeof(rlimit64)); ASSERT_EQ(sizeof(rlimit), sizeof(rlimit64));
ASSERT_EQ(8U, sizeof(rlim_t)); ASSERT_EQ(8U, sizeof(rlim_t));
#else #else

View File

@ -67,7 +67,7 @@ TEST(unistd, sbrk_ENOMEM) {
ASSERT_EQ(reinterpret_cast<void*>(-1), sbrk(-(current_brk + 1))); ASSERT_EQ(reinterpret_cast<void*>(-1), sbrk(-(current_brk + 1)));
ASSERT_EQ(ENOMEM, errno); ASSERT_EQ(ENOMEM, errno);
#if !defined(__GLIBC__) #if defined(__BIONIC__)
// The maximum negative value is an interesting special case that glibc gets wrong. // The maximum negative value is an interesting special case that glibc gets wrong.
ASSERT_EQ(reinterpret_cast<void*>(-1), sbrk(PTRDIFF_MIN)); ASSERT_EQ(reinterpret_cast<void*>(-1), sbrk(PTRDIFF_MIN));
ASSERT_EQ(ENOMEM, errno); ASSERT_EQ(ENOMEM, errno);

View File

@ -288,7 +288,7 @@ TEST(wchar, mbrtowc) {
// 4-byte UTF-8. // 4-byte UTF-8.
ASSERT_EQ(4U, mbrtowc(out, "\xf0\xa4\xad\xa2" "ef", 6, NULL)); ASSERT_EQ(4U, mbrtowc(out, "\xf0\xa4\xad\xa2" "ef", 6, NULL));
ASSERT_EQ(static_cast<wchar_t>(0x24b62), out[0]); ASSERT_EQ(static_cast<wchar_t>(0x24b62), out[0]);
#if __BIONIC__ // glibc allows this. #if defined(__BIONIC__) // glibc allows this.
// Illegal 5-byte UTF-8. // Illegal 5-byte UTF-8.
ASSERT_EQ(static_cast<size_t>(-1), mbrtowc(out, "\xf8\xa1\xa2\xa3\xa4" "f", 6, NULL)); ASSERT_EQ(static_cast<size_t>(-1), mbrtowc(out, "\xf8\xa1\xa2\xa3\xa4" "f", 6, NULL));
ASSERT_EQ(EILSEQ, errno); ASSERT_EQ(EILSEQ, errno);