First pass on a generic zero key that can be used for test cases.
[m6w6/libmemcached] / tests / libmemcached_world.h
index 9f38c02498b54220f40db8330c99f82cfdd62a68..824aabe751adfa503384f780d83233d404f81db1 100644 (file)
@@ -29,7 +29,13 @@ struct libmemcached_test_container_st
 
 static void *world_create(server_startup_st& servers, test_return_t& error)
 {
-  if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+  if (HAVE_MEMCACHED_BINARY == 0)
+  {
+    error= TEST_SKIPPED;
+    return NULL;
+  }
+
+  if (servers.sasl() and (LIBMEMCACHED_WITH_SASL_SUPPORT == 0 or MEMCACHED_SASL_BINARY == 0))
   {
     error= TEST_SKIPPED;
     return NULL;
@@ -42,7 +48,6 @@ static void *world_create(server_startup_st& servers, test_return_t& error)
     return NULL;
   }
 
-
   in_port_t max_port= TEST_PORT_BASE;
   for (uint32_t x= 0; x < servers.count(); x++)
   {
@@ -67,7 +72,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error)
     {
       if (not server_startup(servers, "memcached-sasl", port, 1, argv))
       {
-        error= TEST_FAILURE;
+        error= TEST_FATAL;
         return NULL;
       }
     }
@@ -75,7 +80,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error)
     {
       if (not server_startup(servers, "memcached", port, 1, argv))
       {
-        error= TEST_FAILURE;
+        error= TEST_FATAL;
         return NULL;
       }
     }
@@ -88,7 +93,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error)
       const char *argv[1]= { "memcached" };
       if (not servers.start_socket_server("memcached-sasl", max_port +1, 1, argv))
       {
-        error= TEST_FAILURE;
+        error= TEST_FATAL;
         return NULL;
       }
     }
@@ -97,7 +102,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error)
       const char *argv[1]= { "memcached" };
       if (not servers.start_socket_server("memcached", max_port +1, 1, argv))
       {
-        error= TEST_FAILURE;
+        error= TEST_FATAL;
         return NULL;
       }
     }
@@ -125,9 +130,10 @@ static test_return_t world_container_startup(libmemcached_test_container_st *con
                                                     buffer, sizeof(buffer)),
                    container->construct.option_string().c_str());
 
-  test_true(not container->parent);
+  test_null(container->parent);
   container->parent= memcached(container->construct.option_string().c_str(), container->construct.option_string().size());
   test_true(container->parent);
+  test_compare(MEMCACHED_SUCCESS, memcached_version(container->parent));
 
   if (container->construct.sasl())
   {
@@ -169,7 +175,7 @@ static test_return_t world_container_shutdown(libmemcached_test_container_st *co
 static test_return_t world_test_startup(libmemcached_test_container_st *container)
 {
   test_true(container);
-  test_true(not container->memc);
+  test_null(container->memc);
   test_true(container->parent);
   container->memc= memcached_clone(NULL, container->parent);
   test_true(container->memc);
@@ -210,9 +216,8 @@ static test_return_t world_post_run(libmemcached_test_container_st *container)
   return TEST_SUCCESS;
 }
 
-static test_return_t world_on_error(test_return_t test_state, libmemcached_test_container_st *container)
+static test_return_t world_on_error(test_return_t , libmemcached_test_container_st *container)
 {
-  (void)test_state;
   test_true(container->memc);
   memcached_free(container->memc);
   container->memc= NULL;
@@ -243,7 +248,17 @@ static test_return_t _runner_default(libmemcached_test_callback_fn func, libmemc
   {
     test_true(container);
     test_true(container->memc);
-    return func(container->memc);
+    test_return_t ret;
+    try {
+      ret= func(container->memc);
+    }
+    catch (std::exception& e)
+    {
+      Error << e.what();
+      return TEST_FAILURE;
+    }
+
+    return ret;
   }
 
   return TEST_SUCCESS;