Merge trunk
[awesomized/libmemcached] / tests / libmemcached_world.h
index e2f0c27d2e4b9de3df69d6ce482c8c8b8bfc5d18..7936a524826818b009cbbe5e6ac67b7506071203 100644 (file)
@@ -27,11 +27,15 @@ struct libmemcached_test_container_st
   { }
 };
 
-#define SERVERS_TO_CREATE 5
-
 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_FATAL;
+    return NULL;
+  }
+
+  if (servers.sasl() and (LIBMEMCACHED_WITH_SASL_SUPPORT == 0 or MEMCACHED_SASL_BINARY == 0))
   {
     error= TEST_SKIPPED;
     return NULL;
@@ -45,8 +49,8 @@ static void *world_create(server_startup_st& servers, test_return_t& error)
   }
 
 
-  in_port_t max_port;
-  for (uint32_t x= 0; x < SERVERS_TO_CREATE; x++)
+  in_port_t max_port= TEST_PORT_BASE;
+  for (uint32_t x= 0; x < servers.count(); x++)
   {
     in_port_t port;
 
@@ -69,7 +73,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;
       }
     }
@@ -77,7 +81,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;
       }
     }
@@ -90,7 +94,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;
       }
     }
@@ -99,7 +103,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;
       }
     }
@@ -127,9 +131,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())
   {
@@ -171,7 +176,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);
@@ -212,9 +217,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;