1 // Copyright 2016 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include <unistd.h> 6 7 #include <unittest/unittest.h> 8 sysconf_test(void)9static bool sysconf_test(void) { 10 BEGIN_TEST; 11 12 long rv; 13 rv = sysconf(_SC_NPROCESSORS_CONF); 14 EXPECT_GE(rv, 1, "wrong number of cpus configured"); 15 rv = sysconf(_SC_NPROCESSORS_ONLN); 16 EXPECT_GE(rv, 1, "wrong number of cpus currently online"); 17 // test on invalid input 18 rv = sysconf(-1); 19 EXPECT_EQ(rv, -1, "wrong return value on invalid input"); 20 21 END_TEST; 22 } 23 24 BEGIN_TEST_CASE(sysconf_tests) RUN_TEST(sysconf_test)25RUN_TEST(sysconf_test) 26 END_TEST_CASE(sysconf_tests) 27 28 int main(int argc, char** argv) { 29 return unittest_run_all_tests(argc, argv) ? 0 : -1; 30 } 31