summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2014-11-17 18:43:31 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-11-17 18:43:32 +0000
commitee4c8febb7bd1f5492486cc11980f925425b02ec (patch)
treea25de9b47c806485750186097108196a529fd0b5 /tests
parentf2c882095b5747cd7f3158428208580a7ff72ed6 (diff)
parentbc6447673fba0b38d948dcd627ab6744395c771a (diff)
downloadbionic-ee4c8febb7bd1f5492486cc11980f925425b02ec.zip
bionic-ee4c8febb7bd1f5492486cc11980f925425b02ec.tar.gz
bionic-ee4c8febb7bd1f5492486cc11980f925425b02ec.tar.bz2
Merge "bionic/test: migrate sysconf tests from system/extras to bionic/tests"
Diffstat (limited to 'tests')
-rw-r--r--tests/unistd_test.cpp139
1 files changed, 135 insertions, 4 deletions
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index b5fcf26..50afd05 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -30,10 +30,6 @@
#include <sys/wait.h>
#include <unistd.h>
-TEST(unistd, sysconf_SC_MONOTONIC_CLOCK) {
- ASSERT_GT(sysconf(_SC_MONOTONIC_CLOCK), 0);
-}
-
static void* get_brk() {
return sbrk(0);
}
@@ -520,3 +516,138 @@ TEST(unistd, pathconf_fpathconf) {
rc = fpathconf(tf.fd, _PC_REC_XFER_ALIGN);
ASSERT_TRUE(rc > 0 && powerof2(rc));
}
+
+#define verifySysconf(name, ret) \
+{\
+ errno = 0;\
+ ret = sysconf(name);\
+ ASSERT_TRUE((0 == errno) && (-1 != ret)) << "name=" << #name << ", ret=" << ret << ", Error Message: " << strerror(errno);\
+}\
+
+TEST(unistd, sysconf) {
+ long ret;
+
+ verifySysconf(_SC_MONOTONIC_CLOCK, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_ARG_MAX, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_CHILD_MAX, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_CLK_TCK, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_LINE_MAX, ret);
+ ASSERT_GT(ret, 1);
+ verifySysconf(_SC_NGROUPS_MAX, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_OPEN_MAX, ret);
+ ASSERT_GT(ret, 1);
+ verifySysconf(_SC_2_C_BIND, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_2_C_VERSION, ret);
+ verifySysconf(_SC_JOB_CONTROL, ret);
+ ASSERT_EQ(1, ret);
+ verifySysconf(_SC_SAVED_IDS, ret);
+ ASSERT_EQ(1, ret);
+ verifySysconf(_SC_VERSION, ret);
+ verifySysconf(_SC_RE_DUP_MAX, ret);
+ verifySysconf(_SC_STREAM_MAX, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_TZNAME_MAX, ret);
+ verifySysconf(_SC_XOPEN_VERSION, ret);
+ verifySysconf(_SC_ATEXIT_MAX, ret);
+ ASSERT_GT(ret, 1);
+ verifySysconf(_SC_IOV_MAX, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_PAGESIZE, ret);
+ ASSERT_GE(ret, 1);
+ verifySysconf(_SC_PAGE_SIZE, ret);
+ ASSERT_GE(ret, 1);
+ verifySysconf(_SC_XOPEN_UNIX, ret);
+ verifySysconf(_SC_DELAYTIMER_MAX, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_MQ_OPEN_MAX, ret);
+ verifySysconf(_SC_MQ_PRIO_MAX, ret);
+ ASSERT_GT(ret ,0);
+ verifySysconf(_SC_RTSIG_MAX, ret);
+ verifySysconf(_SC_SEM_NSEMS_MAX, ret);
+ verifySysconf(_SC_SEM_VALUE_MAX, ret);
+ verifySysconf(_SC_SIGQUEUE_MAX, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_TIMER_MAX, ret);
+ verifySysconf(_SC_FSYNC, ret);
+ verifySysconf(_SC_MAPPED_FILES, ret);
+ verifySysconf(_SC_PRIORITY_SCHEDULING, ret);
+ verifySysconf(_SC_SEMAPHORES, ret);
+ verifySysconf(_SC_SYNCHRONIZED_IO, ret);
+ verifySysconf(_SC_TIMERS, ret);
+ verifySysconf(_SC_GETGR_R_SIZE_MAX, ret);
+ verifySysconf(_SC_GETPW_R_SIZE_MAX, ret);
+ verifySysconf(_SC_LOGIN_NAME_MAX, ret);
+ verifySysconf(_SC_THREAD_DESTRUCTOR_ITERATIONS, ret);
+ verifySysconf(_SC_THREAD_KEYS_MAX, ret);
+ verifySysconf(_SC_THREAD_STACK_MIN, ret);
+ verifySysconf(_SC_THREAD_THREADS_MAX, ret);
+ verifySysconf(_SC_TTY_NAME_MAX, ret);
+ ASSERT_GT(ret, 0);
+ verifySysconf(_SC_THREADS, ret);
+ verifySysconf(_SC_THREAD_PRIO_INHERIT, ret);
+ verifySysconf(_SC_THREAD_PRIO_PROTECT, ret);
+ verifySysconf(_SC_NPROCESSORS_CONF, ret);
+ verifySysconf(_SC_NPROCESSORS_ONLN, ret);
+ verifySysconf(_SC_PHYS_PAGES, ret);
+ verifySysconf(_SC_AVPHYS_PAGES, ret);
+
+ // TODO: keep following names check here
+ // so that we can enable them when the error fixed
+
+ /* when call sysconf with following name,
+ the system call will report error "Function not implemented"
+
+ verifySysconf(_SC_BC_BASE_MAX, ret);
+ verifySysconf(_SC_BC_DIM_MAX, ret);
+ verifySysconf(_SC_BC_SCALE_MAX, ret);
+ verifySysconf(_SC_BC_STRING_MAX, ret);
+ verifySysconf(_SC_COLL_WEIGHTS_MAX, ret);
+ verifySysconf(_SC_EXPR_NEST_MAX, ret);
+ verifySysconf(_SC_XOPEN_SHM, ret);
+ verifySysconf(_SC_XBS5_ILP32_OFF32, ret);
+ verifySysconf(_SC_XBS5_ILP32_OFFBIG, ret);
+ verifySysconf(_SC_XBS5_LP64_OFF64, ret);
+ verifySysconf(_SC_XBS5_LPBIG_OFFBIG, ret);
+ verifySysconf(_SC_AIO_LISTIO_MAX, ret);
+ verifySysconf(_SC_AIO_MAX, ret);
+ verifySysconf(_SC_AIO_PRIO_DELTA_MAX, ret);
+ verifySysconf(_SC_ASYNCHRONOUS_IO, ret);
+ verifySysconf(_SC_MEMLOCK, ret);
+ verifySysconf(_SC_MEMLOCK_RANGE, ret);
+ verifySysconf(_SC_MEMORY_PROTECTION, ret);
+ verifySysconf(_SC_MESSAGE_PASSING, ret);
+ verifySysconf(_SC_PRIORITIZED_IO, ret);
+ verifySysconf(_SC_SHARED_MEMORY_OBJECTS, ret);
+ verifySysconf(_SC_THREAD_SAFE_FUNCTIONS, ret);
+
+ */
+
+ /* when following names are checked,
+ the return value of sysconf is -1,
+ which means following name are invalid.
+
+ verifySysconf(_SC_2_C_DEV, ret);
+ verifySysconf(_SC_2_FORT_DEV, ret);
+ verifySysconf(_SC_2_FORT_RUN, ret);
+ verifySysconf(_SC_2_LOCALEDEF, ret);
+ verifySysconf(_SC_2_SW_DEV, ret);
+ verifySysconf(_SC_2_UPE, ret);
+ verifySysconf(_SC_2_VERSION, ret);
+ verifySysconf(_SC_XOPEN_CRYPT, ret);
+ verifySysconf(_SC_XOPEN_ENH_I18N, ret);
+ verifySysconf(_SC_XOPEN_XCU_VERSION, ret);
+ verifySysconf(_SC_XOPEN_REALTIME, ret);
+ verifySysconf(_SC_XOPEN_REALTIME_THREADS, ret);
+ verifySysconf(_SC_XOPEN_LEGACY, ret);
+ verifySysconf(_SC_THREAD_ATTR_STACKADDR, ret);
+ verifySysconf(_SC_THREAD_ATTR_STACKSIZE, ret);
+ verifySysconf(_SC_REALTIME_SIGNALS, ret);
+
+ */
+}