X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fcycle.cc;h=64d2b860355e217dc53ec59dcccea160c6654e2f;hb=2759aa4142bba88f6dec856178cb5cd628806abb;hp=25ca66cc2d3b9bc1b8bf8ed94df7f5a24ee7b5a2;hpb=12a07e58df95bb8dbe167e4157b29c910177ade8;p=awesomized%2Flibmemcached diff --git a/tests/cycle.cc b/tests/cycle.cc index 25ca66cc..64d2b860 100644 --- a/tests/cycle.cc +++ b/tests/cycle.cc @@ -39,9 +39,10 @@ Test that we are cycling the servers we are creating during testing. */ -#include +#include +#include -#include +#include #include #include @@ -50,7 +51,7 @@ #include -#define SERVERS_TO_CREATE 5 +using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" @@ -90,6 +91,19 @@ static test_return_t valid(memcached_st *memc) return TEST_SUCCESS; } +static test_return_t kill_test(memcached_st *) +{ + static struct timespec global_sleep_value= { 2, 0 }; + +#ifdef WIN32 + sleep(1); +#else + nanosleep(&global_sleep_value, NULL); +#endif + + return TEST_SUCCESS; +} + test_st ping_tests[] ={ {"alive", true, (test_callback_fn*)alive }, {0, 0, 0} @@ -100,34 +114,20 @@ test_st getpid_tests[] ={ {0, 0, 0} }; +test_st kill_tests[] ={ + {"kill", true, (test_callback_fn*)kill_test }, + {0, 0, 0} +}; + collection_st collection[] ={ {"libmemcached_util_ping()", 0, 0, ping_tests}, {"libmemcached_util_getpid()", 0, 0, getpid_tests}, + {"kill", 0, 0, kill_tests}, {0, 0, 0, 0} }; -#if 0 -static server_startup_st *world_create(test_return_t *error) -{ - server_startup_st *servers= new server_startup_st(); - - server_startup(servers); - - *error= TEST_SUCCESS; - - return servers; -} - -static test_return_t world_destroy(server_startup_st *servers) -{ - server_shutdown(servers); - delete servers; - - return TEST_SUCCESS; -} -#endif - +#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10 #include "tests/libmemcached_world.h" void get_world(Framework *world) @@ -135,16 +135,18 @@ void get_world(Framework *world) world->collections= collection; world->_create= (test_callback_create_fn*)world_create; - world->_destroy= (test_callback_fn*)world_destroy; + world->_destroy= (test_callback_destroy_fn*)world_destroy; - world->item._startup= (test_callback_fn*)world_test_startup; + world->item.set_startup((test_callback_fn*)world_test_startup); world->item.set_pre((test_callback_fn*)world_pre_run); world->item.set_post((test_callback_fn*)world_post_run); - world->_on_error= (test_callback_error_fn*)world_on_error; + + world->set_on_error((test_callback_error_fn*)world_on_error); world->collection_startup= (test_callback_fn*)world_container_startup; world->collection_shutdown= (test_callback_fn*)world_container_shutdown; - world->runner= &defualt_libmemcached_runner; + world->set_runner(&defualt_libmemcached_runner); + world->set_socket(); }