am 4482091b
: Merge "Consistently use #if defined(__BIONIC__) in tests."
* commit '4482091b1d1611aa395931656b94bfd8ffd583bf': Consistently use #if defined(__BIONIC__) in tests.
This commit is contained in:
commit
492e8f7250
@ -53,7 +53,7 @@ TEST(dlfcn, dlsym_in_self) {
|
||||
TEST(dlfcn, dlopen_failure) {
|
||||
void* self = dlopen("/does/not/exist", RTLD_NOW);
|
||||
ASSERT_TRUE(self == NULL);
|
||||
#if __BIONIC__
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_STREQ("dlopen failed: library \"/does/not/exist\" not found", dlerror());
|
||||
#else
|
||||
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.
|
||||
sym = dlsym(NULL, "test");
|
||||
ASSERT_TRUE(sym == NULL);
|
||||
#if __BIONIC__
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_SUBSTR("dlsym library handle is null", dlerror());
|
||||
#else
|
||||
ASSERT_SUBSTR("undefined symbol: test", dlerror()); // glibc isn't specific about the failure.
|
||||
#endif
|
||||
|
||||
// NULL symbol name.
|
||||
#if __BIONIC__
|
||||
#if defined(__BIONIC__)
|
||||
// glibc marks this parameter non-null and SEGVs if you cheat.
|
||||
sym = dlsym(self, NULL);
|
||||
ASSERT_TRUE(sym == NULL);
|
||||
@ -206,7 +206,7 @@ TEST(dlfcn, dlopen_bad_flags) {
|
||||
dlerror(); // Clear any pending errors.
|
||||
void* handle;
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#if defined(__GLIBC__)
|
||||
// glibc was smart enough not to define RTLD_NOW as 0, so it can detect missing flags.
|
||||
handle = dlopen(NULL, 0);
|
||||
ASSERT_TRUE(handle == NULL);
|
||||
|
@ -73,7 +73,7 @@ TEST(fcntl, creat_creat64) {
|
||||
TEST(fcntl, fallocate_EINVAL) {
|
||||
TemporaryFile tf;
|
||||
|
||||
#if !defined(__GLIBC__)
|
||||
#if defined(__BIONIC__)
|
||||
errno = 0;
|
||||
ASSERT_EQ(-1, fallocate(tf.fd, 0, 0, -1));
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
@ -98,7 +98,7 @@ TEST(fcntl, fallocate) {
|
||||
ASSERT_EQ(0, fstat(tf.fd, &sb));
|
||||
ASSERT_EQ(0, sb.st_size);
|
||||
|
||||
#if !defined(__GLIBC__)
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EQ(0, fallocate(tf.fd, 0, 0, 1));
|
||||
ASSERT_EQ(0, fstat(tf.fd, &sb));
|
||||
ASSERT_EQ(1, sb.st_size);
|
||||
|
@ -668,7 +668,7 @@ TEST(DEATHTEST, recv_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";
|
||||
fd_set set;
|
||||
memset(&set, 0, sizeof(set));
|
||||
|
@ -58,7 +58,7 @@ TEST(locale, setlocale) {
|
||||
EXPECT_EQ(NULL, setlocale(13, NULL));
|
||||
EXPECT_EQ(EINVAL, errno);
|
||||
|
||||
#if __BIONIC__
|
||||
#if defined(__BIONIC__)
|
||||
// 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.
|
||||
EXPECT_STREQ("C", setlocale(LC_ALL, ""));
|
||||
|
@ -28,7 +28,7 @@ TEST(regex, smoke) {
|
||||
|
||||
char buf[80];
|
||||
regerror(REG_NOMATCH, &re, buf, sizeof(buf));
|
||||
#if __BIONIC__
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_STREQ("regexec() failed to match", buf);
|
||||
#else
|
||||
ASSERT_STREQ("No match", buf);
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifdef __BIONIC__
|
||||
#if defined(__BIONIC__)
|
||||
static int child_fn(void* i_ptr) {
|
||||
*reinterpret_cast<int*>(i_ptr) = 42;
|
||||
return 123;
|
||||
|
@ -219,7 +219,7 @@ TEST(stdio, snprintf_ls) {
|
||||
}
|
||||
|
||||
TEST(stdio, snprintf_n) {
|
||||
#if !defined(__GLIBC__)
|
||||
#if defined(__BIONIC__)
|
||||
// http://b/14492135
|
||||
char buf[32];
|
||||
int i = 1234;
|
||||
@ -460,7 +460,7 @@ TEST(stdio, cantwrite_EBADF) {
|
||||
|
||||
errno = 0;
|
||||
EXPECT_EQ(EOF, fwprintf(fp, L"hello"));
|
||||
#if !defined(__GLIBC__)
|
||||
#if defined(__BIONIC__)
|
||||
EXPECT_EQ(EBADF, errno);
|
||||
#endif
|
||||
|
||||
@ -478,7 +478,7 @@ TEST(stdio, cantwrite_EBADF) {
|
||||
|
||||
errno = 0;
|
||||
EXPECT_EQ(WEOF, fputwc(L'x', fp));
|
||||
#if !defined(__GLIBC__)
|
||||
#if defined(__BIONIC__)
|
||||
EXPECT_EQ(EBADF, errno);
|
||||
#endif
|
||||
}
|
||||
@ -521,7 +521,7 @@ TEST(stdio, consistent_fpos_t) {
|
||||
ASSERT_EQ(mb_four_bytes, static_cast<wchar_t>(fgetwc(fp)));
|
||||
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
|
||||
// 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
|
||||
@ -586,9 +586,9 @@ TEST(stdio, fpos_t_and_seek) {
|
||||
// Store the "inside multi byte" position.
|
||||
fpos_t pos_inside_mb;
|
||||
ASSERT_EQ(0, fgetpos(fp, &pos_inside_mb));
|
||||
#ifdef __BIONIC__
|
||||
ASSERT_EQ(offset_inside_mb, static_cast<off_t>(pos_inside_mb));
|
||||
#endif
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EQ(offset_inside_mb, static_cast<off_t>(pos_inside_mb));
|
||||
#endif
|
||||
|
||||
// Reading from within a byte should produce an error.
|
||||
ASSERT_EQ(WEOF, fgetwc(fp));
|
||||
|
@ -42,7 +42,7 @@ TEST(stdlib, lrand48_random_rand) {
|
||||
EXPECT_EQ(902267124, lrand48());
|
||||
EXPECT_EQ(132366131, lrand48());
|
||||
|
||||
#if __BIONIC__
|
||||
#if defined(__BIONIC__)
|
||||
// On bionic, random(3) is equivalent to lrand48...
|
||||
srandom(0x01020304);
|
||||
EXPECT_EQ(1409163720, random());
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
#if __GLIBC__
|
||||
#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) {
|
||||
@ -30,7 +30,7 @@ static int prlimit64(pid_t, int resource, const struct rlimit64* new_limit, stru
|
||||
#endif
|
||||
|
||||
TEST(sys_resource, smoke) {
|
||||
#if __LP64__ || __GLIBC__
|
||||
#if defined(__LP64__) || defined(__GLIBC__)
|
||||
ASSERT_EQ(sizeof(rlimit), sizeof(rlimit64));
|
||||
ASSERT_EQ(8U, sizeof(rlim_t));
|
||||
#else
|
||||
|
@ -67,7 +67,7 @@ TEST(unistd, sbrk_ENOMEM) {
|
||||
ASSERT_EQ(reinterpret_cast<void*>(-1), sbrk(-(current_brk + 1)));
|
||||
ASSERT_EQ(ENOMEM, errno);
|
||||
|
||||
#if !defined(__GLIBC__)
|
||||
#if defined(__BIONIC__)
|
||||
// The maximum negative value is an interesting special case that glibc gets wrong.
|
||||
ASSERT_EQ(reinterpret_cast<void*>(-1), sbrk(PTRDIFF_MIN));
|
||||
ASSERT_EQ(ENOMEM, errno);
|
||||
|
@ -288,7 +288,7 @@ TEST(wchar, mbrtowc) {
|
||||
// 4-byte UTF-8.
|
||||
ASSERT_EQ(4U, mbrtowc(out, "\xf0\xa4\xad\xa2" "ef", 6, NULL));
|
||||
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.
|
||||
ASSERT_EQ(static_cast<size_t>(-1), mbrtowc(out, "\xf8\xa1\xa2\xa3\xa4" "f", 6, NULL));
|
||||
ASSERT_EQ(EILSEQ, errno);
|
||||
|
Loading…
Reference in New Issue
Block a user