Fix select failures when STDIN is ready.

The select_smoke and pselect_smoke test can fail if STDIN has data ready
to be read. The easiest way to see the failure is to type on the command
line while running the tests.

To avoid this, allow the return value to be 2 or 3 and check which fds
are ready to be read.

Change-Id: Iafba332c5f3ed1943e3d34501f123dd45f06a8c4
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;