Merge "support _POSIX_REALTIME_SIGNALS"
[android-sdk/platform-bionic.git] / tests / unistd_test.cpp
index 433c1b501694af0fd683519ef2999dcfab616c06..96d66e48d6ff061b54413075f38cc38dc5574852 100644 (file)
@@ -523,12 +523,14 @@ TEST(unistd, _POSIX_macros_smoke) {
   // Verify according to POSIX.1-2008.
   EXPECT_EQ(200809L, _POSIX_VERSION);
 
+  EXPECT_EQ(_POSIX_VERSION, _POSIX_ADVISORY_INFO);
   EXPECT_GT(_POSIX_AIO_LISTIO_MAX, 0);
   EXPECT_GT(_POSIX_AIO_MAX, 0);
   EXPECT_GT(_POSIX_ARG_MAX, 0);
   EXPECT_GT(_POSIX_CHILD_MAX, 0);
   EXPECT_NE(_POSIX_CHOWN_RESTRICTED, -1);
   EXPECT_EQ(_POSIX_VERSION, _POSIX_CLOCK_SELECTION);
+  EXPECT_EQ(0, _POSIX_CPUTIME);             // Use sysconf to detect support at runtime.
   EXPECT_GT(_POSIX_DELAYTIMER_MAX, 0);
   EXPECT_EQ(_POSIX_VERSION, _POSIX_FSYNC);
   EXPECT_GT(_POSIX_HOST_NAME_MAX, 0);
@@ -572,7 +574,7 @@ TEST(unistd, _POSIX_macros_smoke) {
   EXPECT_EQ(_POSIX_VERSION, _POSIX_THREADS);
   EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_ATTR_STACKADDR);
   EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_ATTR_STACKSIZE);
-  EXPECT_TRUE(_POSIX_VERSION ==  _POSIX_THREAD_CPUTIME || 0 == _POSIX_THREAD_CPUTIME);
+  EXPECT_EQ(0, _POSIX_THREAD_CPUTIME);       // Use sysconf to detect support at runtime.
   EXPECT_GT(_POSIX_THREAD_DESTRUCTOR_ITERATIONS, 0);
   EXPECT_GT(_POSIX_THREAD_KEYS_MAX, 0);
   EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_PRIORITY_SCHEDULING);
@@ -611,11 +613,9 @@ TEST(unistd, _POSIX_macros_smoke) {
 
 #if defined(__BIONIC__)
   // These tests only pass on bionic, as bionic and glibc has different support on these macros.
-  // Macros like _POSIX_ADVISORY_INFO are not supported on bionic yet.
-  EXPECT_EQ(-1, _POSIX_ADVISORY_INFO);
+  // Macros like _POSIX_ASYNCHRONOUS_IO are not supported on bionic yet.
   EXPECT_EQ(-1, _POSIX_ASYNCHRONOUS_IO);
   EXPECT_EQ(-1, _POSIX_BARRIERS);
-  EXPECT_EQ(-1, _POSIX_CPUTIME);
   EXPECT_EQ(-1, _POSIX_MESSAGE_PASSING);
   EXPECT_EQ(-1, _POSIX_PRIORITIZED_IO);
   EXPECT_EQ(-1, _POSIX_SHARED_MEMORY_OBJECTS);
@@ -658,6 +658,7 @@ static void VerifySysconf(int option, const char *option_name, bool (*verify)(lo
 }
 
 TEST(unistd, sysconf) {
+  VERIFY_SYSCONF_POSIX_VERSION(_SC_ADVISORY_INFO);
   VERIFY_SYSCONF_POSITIVE(_SC_ARG_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_BC_BASE_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_BC_DIM_MAX);
@@ -665,6 +666,7 @@ TEST(unistd, sysconf) {
   VERIFY_SYSCONF_POSITIVE(_SC_CHILD_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_CLK_TCK);
   VERIFY_SYSCONF_POSITIVE(_SC_COLL_WEIGHTS_MAX);
+  VERIFY_SYSCONF_POSIX_VERSION(_SC_CPUTIME);
   VERIFY_SYSCONF_POSITIVE(_SC_EXPR_NEST_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_LINE_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_NGROUPS_MAX);
@@ -773,10 +775,8 @@ TEST(unistd, sysconf) {
 #if defined(__BIONIC__)
   // Tests can only run on bionic, as bionic and glibc have different support for these options.
   // Below options are not supported on bionic yet.
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_ADVISORY_INFO);
   VERIFY_SYSCONF_NOT_SUPPORT(_SC_ASYNCHRONOUS_IO);
   VERIFY_SYSCONF_NOT_SUPPORT(_SC_BARRIERS);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_CPUTIME);
   VERIFY_SYSCONF_NOT_SUPPORT(_SC_MESSAGE_PASSING);
   VERIFY_SYSCONF_NOT_SUPPORT(_SC_PRIORITIZED_IO);
   VERIFY_SYSCONF_NOT_SUPPORT(_SC_SHARED_MEMORY_OBJECTS);