Use FUTEX_WAIT_BITSET to avoid converting timeouts.
Add unittests for pthread APIs with timeout parameter.
Bug: 17569991
Change-Id: I6b3b9b2feae03680654cd64c3112ce7644632c87
diff --git a/tests/semaphore_test.cpp b/tests/semaphore_test.cpp
index e517f81..b65bfb8 100644
--- a/tests/semaphore_test.cpp
+++ b/tests/semaphore_test.cpp
@@ -117,6 +117,16 @@
ts.tv_nsec = -1;
ASSERT_EQ(-1, sem_timedwait(&s, &ts));
ASSERT_EQ(EINVAL, errno);
+ errno = 0;
+ ts.tv_nsec = NS_PER_S;
+ ASSERT_EQ(-1, sem_timedwait(&s, &ts));
+ ASSERT_EQ(EINVAL, errno);
+
+ errno = 0;
+ ts.tv_nsec = NS_PER_S - 1;
+ ts.tv_sec = -1;
+ ASSERT_EQ(-1, sem_timedwait(&s, &ts));
+ ASSERT_EQ(ETIMEDOUT, errno);
ASSERT_EQ(0, sem_destroy(&s));
}