Merge changes Iaf0efc0c,Ia4a2ff77
* changes: adb: disable tests that are expected to fail on Win32. adb: increase the FD table size on Win32.
This commit is contained in:
commit
c4f3546e9f
3 changed files with 44 additions and 9 deletions
|
|
@ -37,7 +37,13 @@
|
||||||
// fds far from the range that open() returns. But all of that might defeat the
|
// fds far from the range that open() returns. But all of that might defeat the
|
||||||
// purpose of the tests.
|
// purpose of the tests.
|
||||||
|
|
||||||
TEST(io, ReadFdExactly_whole) {
|
#if defined(_WIN32)
|
||||||
|
#define POSIX_TEST(x,y) TEST(DISABLED_ ## x,y)
|
||||||
|
#else
|
||||||
|
#define POSIX_TEST TEST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
POSIX_TEST(io, ReadFdExactly_whole) {
|
||||||
const char expected[] = "Foobar";
|
const char expected[] = "Foobar";
|
||||||
TemporaryFile tf;
|
TemporaryFile tf;
|
||||||
ASSERT_NE(-1, tf.fd);
|
ASSERT_NE(-1, tf.fd);
|
||||||
|
|
@ -51,7 +57,7 @@ TEST(io, ReadFdExactly_whole) {
|
||||||
EXPECT_STREQ(expected, buf);
|
EXPECT_STREQ(expected, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(io, ReadFdExactly_eof) {
|
POSIX_TEST(io, ReadFdExactly_eof) {
|
||||||
const char expected[] = "Foobar";
|
const char expected[] = "Foobar";
|
||||||
TemporaryFile tf;
|
TemporaryFile tf;
|
||||||
ASSERT_NE(-1, tf.fd);
|
ASSERT_NE(-1, tf.fd);
|
||||||
|
|
@ -65,7 +71,7 @@ TEST(io, ReadFdExactly_eof) {
|
||||||
EXPECT_EQ(0, errno) << strerror(errno);
|
EXPECT_EQ(0, errno) << strerror(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(io, ReadFdExactly_partial) {
|
POSIX_TEST(io, ReadFdExactly_partial) {
|
||||||
const char input[] = "Foobar";
|
const char input[] = "Foobar";
|
||||||
TemporaryFile tf;
|
TemporaryFile tf;
|
||||||
ASSERT_NE(-1, tf.fd);
|
ASSERT_NE(-1, tf.fd);
|
||||||
|
|
@ -82,7 +88,7 @@ TEST(io, ReadFdExactly_partial) {
|
||||||
EXPECT_STREQ(expected.c_str(), buf);
|
EXPECT_STREQ(expected.c_str(), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(io, WriteFdExactly_whole) {
|
POSIX_TEST(io, WriteFdExactly_whole) {
|
||||||
const char expected[] = "Foobar";
|
const char expected[] = "Foobar";
|
||||||
TemporaryFile tf;
|
TemporaryFile tf;
|
||||||
ASSERT_NE(-1, tf.fd);
|
ASSERT_NE(-1, tf.fd);
|
||||||
|
|
@ -97,7 +103,7 @@ TEST(io, WriteFdExactly_whole) {
|
||||||
EXPECT_STREQ(expected, s.c_str());
|
EXPECT_STREQ(expected, s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(io, WriteFdExactly_partial) {
|
POSIX_TEST(io, WriteFdExactly_partial) {
|
||||||
const char buf[] = "Foobar";
|
const char buf[] = "Foobar";
|
||||||
TemporaryFile tf;
|
TemporaryFile tf;
|
||||||
ASSERT_NE(-1, tf.fd);
|
ASSERT_NE(-1, tf.fd);
|
||||||
|
|
@ -114,7 +120,7 @@ TEST(io, WriteFdExactly_partial) {
|
||||||
EXPECT_EQ(expected, s);
|
EXPECT_EQ(expected, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(io, WriteFdExactly_ENOSPC) {
|
POSIX_TEST(io, WriteFdExactly_ENOSPC) {
|
||||||
int fd = open("/dev/full", O_WRONLY);
|
int fd = open("/dev/full", O_WRONLY);
|
||||||
ASSERT_NE(-1, fd);
|
ASSERT_NE(-1, fd);
|
||||||
|
|
||||||
|
|
@ -123,7 +129,7 @@ TEST(io, WriteFdExactly_ENOSPC) {
|
||||||
ASSERT_EQ(ENOSPC, errno);
|
ASSERT_EQ(ENOSPC, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(io, WriteFdExactly_string) {
|
POSIX_TEST(io, WriteFdExactly_string) {
|
||||||
const char str[] = "Foobar";
|
const char str[] = "Foobar";
|
||||||
TemporaryFile tf;
|
TemporaryFile tf;
|
||||||
ASSERT_NE(-1, tf.fd);
|
ASSERT_NE(-1, tf.fd);
|
||||||
|
|
@ -137,7 +143,7 @@ TEST(io, WriteFdExactly_string) {
|
||||||
EXPECT_STREQ(str, s.c_str());
|
EXPECT_STREQ(str, s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(io, WriteFdFmt) {
|
POSIX_TEST(io, WriteFdFmt) {
|
||||||
TemporaryFile tf;
|
TemporaryFile tf;
|
||||||
ASSERT_NE(-1, tf.fd);
|
ASSERT_NE(-1, tf.fd);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,3 +215,32 @@ TEST_F(sysdeps_poll, disconnect) {
|
||||||
// Linux returns POLLIN | POLLHUP, Windows returns just POLLHUP.
|
// Linux returns POLLIN | POLLHUP, Windows returns just POLLHUP.
|
||||||
EXPECT_EQ(POLLHUP, pfd.revents & POLLHUP);
|
EXPECT_EQ(POLLHUP, pfd.revents & POLLHUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(sysdeps_poll, fd_count) {
|
||||||
|
// https://code.google.com/p/android/issues/detail?id=12141
|
||||||
|
static constexpr int num_sockets = 512;
|
||||||
|
std::vector<int> sockets;
|
||||||
|
std::vector<adb_pollfd> pfds;
|
||||||
|
sockets.resize(num_sockets * 2);
|
||||||
|
for (int32_t i = 0; i < num_sockets; ++i) {
|
||||||
|
ASSERT_EQ(0, adb_socketpair(&sockets[i * 2])) << strerror(errno);
|
||||||
|
ASSERT_TRUE(WriteFdExactly(sockets[i * 2], &i, sizeof(i)));
|
||||||
|
adb_pollfd pfd;
|
||||||
|
pfd.events = POLLIN;
|
||||||
|
pfd.fd = sockets[i * 2 + 1];
|
||||||
|
pfds.push_back(pfd);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT_EQ(num_sockets, adb_poll(pfds.data(), pfds.size(), 0));
|
||||||
|
for (int i = 0; i < num_sockets; ++i) {
|
||||||
|
ASSERT_NE(0, pfds[i].revents & POLLIN);
|
||||||
|
|
||||||
|
int32_t buf[2] = { -1, -1 };
|
||||||
|
ASSERT_EQ(adb_read(pfds[i].fd, buf, sizeof(buf)), static_cast<ssize_t>(sizeof(int32_t)));
|
||||||
|
ASSERT_EQ(i, buf[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int fd : sockets) {
|
||||||
|
adb_close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ typedef struct FHRec_
|
||||||
#define fh_socket u.socket
|
#define fh_socket u.socket
|
||||||
|
|
||||||
#define WIN32_FH_BASE 2048
|
#define WIN32_FH_BASE 2048
|
||||||
#define WIN32_MAX_FHS 128
|
#define WIN32_MAX_FHS 2048
|
||||||
|
|
||||||
static adb_mutex_t _win32_lock;
|
static adb_mutex_t _win32_lock;
|
||||||
static FHRec _win32_fhs[ WIN32_MAX_FHS ];
|
static FHRec _win32_fhs[ WIN32_MAX_FHS ];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue