Merge "Fix select failures when STDIN is ready."
diff --git a/tests/sys_select_test.cpp b/tests/sys_select_test.cpp
index c1732ee..96e7663 100644
--- a/tests/sys_select_test.cpp
+++ b/tests/sys_select_test.cpp
@@ -89,7 +89,13 @@
ASSERT_EQ(-1, select(-1, &r, &w, &e, NULL));
ASSERT_EQ(EINVAL, errno);
- ASSERT_EQ(2, select(max, &r, &w, &e, NULL));
+ int num_fds = select(max, &r, &w, &e, NULL);
+ ASSERT_TRUE(num_fds == 2 || num_fds == 3) << "Num fds returned " << num_fds;
+ ASSERT_TRUE(FD_ISSET(STDOUT_FILENO, &w));
+ ASSERT_TRUE(FD_ISSET(STDERR_FILENO, &w));
+ if (num_fds == 3) {
+ ASSERT_TRUE(FD_ISSET(STDIN_FILENO, &r));
+ }
// Invalid timeout.
timeval tv;
@@ -135,7 +141,13 @@
ASSERT_EQ(-1, pselect(-1, &r, &w, &e, NULL, &ss));
ASSERT_EQ(EINVAL, errno);
- ASSERT_EQ(2, pselect(max, &r, &w, &e, NULL, &ss));
+ int num_fds = pselect(max, &r, &w, &e, NULL, &ss);
+ ASSERT_TRUE(num_fds == 2 || num_fds == 3) << "Num fds returned " << num_fds;
+ ASSERT_TRUE(FD_ISSET(STDOUT_FILENO, &w));
+ ASSERT_TRUE(FD_ISSET(STDERR_FILENO, &w));
+ if (num_fds == 3) {
+ ASSERT_TRUE(FD_ISSET(STDIN_FILENO, &r));
+ }
// Invalid timeout.
timespec tv;