Implement function to determine how many cores are available.
[m6w6/libmemcached] / libtest / unittest.cc
index 95ab7ce1b632fc0391ce20078fad370d4a009cc5..33309a7c1fc216f18a37411901efde3b67d68654 100644 (file)
@@ -534,6 +534,13 @@ static test_return_t fatal_TEST(void *)
   return TEST_SUCCESS;
 }
 
+static test_return_t number_of_cpus_TEST(void *)
+{
+  test_true(number_of_cpus() >= 1);
+
+  return TEST_SUCCESS;
+}
+
 static test_return_t fatal_message_TEST(void *)
 {
   test_compare(fatal_calls++, fatal::disabled_counter());
@@ -648,6 +655,11 @@ test_st fatal_message_TESTS[] ={
   {0, 0, 0}
 };
 
+test_st number_of_cpus_TESTS[] ={
+  {"libtest::number_of_cpus()", 0, number_of_cpus_TEST },
+  {0, 0, 0}
+};
+
 test_st application_tests[] ={
   {"vchar_t", 0, vchar_t_TEST },
   {"true", 0, application_true_BINARY },
@@ -697,6 +709,7 @@ collection_st collection[] ={
   {"http", check_for_curl, 0, http_tests},
   {"get_free_port()", 0, 0, get_free_port_TESTS },
   {"fatal", disable_fatal_exception, enable_fatal_exception, fatal_message_TESTS },
+  {"number_of_cpus()", 0, 0, number_of_cpus_TESTS },
   {0, 0, 0, 0}
 };