X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Flibmemcached-1.0%2Fatomsmasher.cc;h=9b246b176d7ec8860c7e2e9fb8a90721d65b86c0;hb=2569efffe16042f47dc5d2c34528a9ec22fc18b0;hp=ad4483ed4df87e2f887fb9bb6834c801caadd9f1;hpb=a18c65b0ee1a4721a4f1298f52f8b3446cf7c600;p=awesomized%2Flibmemcached diff --git a/tests/libmemcached-1.0/atomsmasher.cc b/tests/libmemcached-1.0/atomsmasher.cc index ad4483ed..9b246b17 100644 --- a/tests/libmemcached-1.0/atomsmasher.cc +++ b/tests/libmemcached-1.0/atomsmasher.cc @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -34,6 +34,8 @@ #include +#include "tests/libmemcached-1.0/generate.h" + using namespace libtest; /* Number of items generated for tests */ @@ -46,14 +48,14 @@ static pairs_st *global_pairs; static char *global_keys[GLOBAL_COUNT]; static size_t global_keys_length[GLOBAL_COUNT]; -static test_return_t cleanup_pairs(memcached_st *) +static test_return_t cleanup_pairs_TEST(memcached_st *) { pairs_free(global_pairs); return TEST_SUCCESS; } -static test_return_t generate_pairs(memcached_st *) +static test_return_t generate_pairs_TEST(memcached_st *) { global_pairs= pairs_generate(GLOBAL_COUNT, 400); @@ -66,26 +68,22 @@ static test_return_t generate_pairs(memcached_st *) return TEST_SUCCESS; } -static test_return_t drizzle(memcached_st *memc) +static test_return_t drizzle_TEST(memcached_st *memc) { infinite: for (ptrdiff_t x= 0; x < TEST_COUNTER; x++) { memcached_return_t rc; - char *return_value; - size_t return_value_length; - uint32_t flags; - - uint32_t test_bit; - uint8_t which; - test_bit= (uint32_t)(random() % GLOBAL_COUNT); - which= (uint8_t)(random() % 2); + uint32_t test_bit= (uint32_t)(random() % GLOBAL_COUNT); + uint8_t which= (uint8_t)(random() % 2); if (which == 0) { - return_value= memcached_get(memc, global_keys[test_bit], global_keys_length[test_bit], - &return_value_length, &flags, &rc); + size_t return_value_length; + uint32_t flags; + char* return_value= memcached_get(memc, global_keys[test_bit], global_keys_length[test_bit], + &return_value_length, &flags, &rc); if (rc == MEMCACHED_SUCCESS && return_value) { free(return_value); @@ -123,7 +121,7 @@ infinite: static test_return_t pre_nonblock(memcached_st *memc) { - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); + test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0)); return TEST_SUCCESS; } @@ -137,10 +135,9 @@ static test_return_t add_test(memcached_st *memc) const char *key= "foo"; const char *value= "when we sanitize"; - memcached_return_t rc; - rc= memcached_set(memc, key, strlen(key), - value, strlen(value), - (time_t)0, (uint32_t)0); + memcached_return_t rc= memcached_set(memc, key, strlen(key), + value, strlen(value), + time_t(0), uint32_t(0)); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); memcached_quit(memc); rc= memcached_add(memc, key, strlen(key), @@ -180,9 +177,9 @@ static test_return_t many_adds(memcached_st *memc) } test_st smash_tests[] ={ - {"generate_pairs", true, (test_callback_fn*)generate_pairs }, - {"drizzle", true, (test_callback_fn*)drizzle }, - {"cleanup", true, (test_callback_fn*)cleanup_pairs }, + {"generate_pairs", true, (test_callback_fn*)generate_pairs_TEST }, + {"drizzle", true, (test_callback_fn*)drizzle_TEST }, + {"cleanup", true, (test_callback_fn*)cleanup_pairs_TEST }, {"many_adds", true, (test_callback_fn*)many_adds }, {0, 0, 0} }; @@ -203,8 +200,7 @@ static test_return_t memcached_create_benchmark(memcached_st *) for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { - memcached_st *ptr; - ptr= memcached_create(&benchmark_state.create[x]); + memcached_st *ptr= memcached_create(&benchmark_state.create[x]); test_true(ptr); } @@ -277,21 +273,12 @@ collection_st collection[] ={ #include "tests/libmemcached_world.h" -void get_world(Framework *world) +void get_world(libtest::Framework* world) { - world->collections= collection; - - world->_create= (test_callback_create_fn*)world_create; - world->_destroy= (test_callback_destroy_fn*)world_destroy; - - world->item._startup= (test_callback_fn*)world_test_startup; - world->item._flush= (test_callback_fn*)world_flush; - 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->collections(collection); - world->collection_startup= (test_callback_fn*)world_container_startup; - world->collection_shutdown= (test_callback_fn*)world_container_shutdown; + world->create((test_callback_create_fn*)world_create); + world->destroy((test_callback_destroy_fn*)world_destroy); - world->set_runner(&defualt_libmemcached_runner); + world->set_runner(new LibmemcachedRunner); }