X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fatomsmasher.cc;h=573e7f53f62f129a628aff3748c02a3c09d6bb4b;hb=e4e6bde654ddb9017f090f3a36d6e9f5fd70b354;hp=a525b95e3dd8cc0eabbd36735f97faaf31c74554;hpb=50dc8599f105fe915607e6f2d57851fd9acad839;p=m6w6%2Flibmemcached diff --git a/tests/atomsmasher.cc b/tests/atomsmasher.cc index a525b95e..573e7f53 100644 --- a/tests/atomsmasher.cc +++ b/tests/atomsmasher.cc @@ -12,25 +12,30 @@ /* Sample test application. */ -#include "config.h" +#include + +#include #include #include -#include -#include +#include +#include #include -#include +#include #include #include #include #include -#include +#include #include #include #include -#include + +#include + +using namespace libtest; /* Number of items generated for tests */ #define GLOBAL_COUNT 100000 @@ -43,17 +48,15 @@ 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 *memc) +static test_return_t cleanup_pairs(memcached_st *) { - (void)memc; pairs_free(global_pairs); return TEST_SUCCESS; } -static test_return_t generate_pairs(memcached_st *memc) +static test_return_t generate_pairs(memcached_st *) { - (void)memc; global_pairs= pairs_generate(GLOBAL_COUNT, 400); global_count= GLOBAL_COUNT; @@ -68,14 +71,14 @@ static test_return_t generate_pairs(memcached_st *memc) static test_return_t drizzle(memcached_st *memc) { - memcached_return_t rc; - char *return_value; - size_t return_value_length; - uint32_t flags; - infinite: for (size_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; @@ -116,7 +119,9 @@ infinite: } if (getenv("MEMCACHED_ATOM_BURIN_IN")) + { goto infinite; + } return TEST_SUCCESS; } @@ -134,30 +139,32 @@ static test_return_t pre_nonblock(memcached_st *memc) */ static test_return_t add_test(memcached_st *memc) { - memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; - unsigned long long setting_value; - - setting_value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK); + memcached_return_t rc; rc= memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); - test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); + test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); memcached_quit(memc); rc= memcached_add(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); + if (rc == MEMCACHED_CONNECTION_FAILURE) + { + print_servers(memc); + } + /* Too many broken OS'es have broken loopback in async, so we can't be sure of the result */ - if (setting_value) + if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK)) { - test_true(rc == MEMCACHED_NOTSTORED || rc == MEMCACHED_STORED); + test_true(rc == MEMCACHED_NOTSTORED or rc == MEMCACHED_STORED); } else { - test_true(rc == MEMCACHED_NOTSTORED); + test_compare_got(MEMCACHED_NOTSTORED, rc, memcached_strerror(NULL, rc)); } return TEST_SUCCESS; @@ -169,18 +176,19 @@ static test_return_t add_test(memcached_st *memc) */ static test_return_t many_adds(memcached_st *memc) { + test_true(memc); for (size_t x= 0; x < TEST_COUNTER; x++) { - add_test(memc); + test_compare_got(TEST_SUCCESS, add_test(memc), x); } return TEST_SUCCESS; } test_st smash_tests[] ={ - {"generate_pairs", 1, (test_callback_fn*)generate_pairs }, - {"drizzle", 1, (test_callback_fn*)drizzle }, - {"cleanup", 1, (test_callback_fn*)cleanup_pairs }, - {"many_adds", 1, (test_callback_fn*)many_adds }, + {"generate_pairs", true, (test_callback_fn*)generate_pairs }, + {"drizzle", true, (test_callback_fn*)drizzle }, + {"cleanup", true, (test_callback_fn*)cleanup_pairs }, + {"many_adds", true, (test_callback_fn*)many_adds }, {0, 0, 0} }; @@ -194,9 +202,8 @@ struct benchmark_state_st memcached_st *clone; } benchmark_state; -static test_return_t memcached_create_benchmark(memcached_st *memc) +static test_return_t memcached_create_benchmark(memcached_st *) { - (void)memc; benchmark_state.create_init= true; for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) @@ -225,9 +232,8 @@ static test_return_t memcached_clone_benchmark(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t pre_allocate(memcached_st *memc) +static test_return_t pre_allocate(memcached_st *) { - (void)memc; memset(&benchmark_state, 0, sizeof(benchmark_state)); benchmark_state.create= (memcached_st *)calloc(BENCHMARK_TEST_LOOP, sizeof(memcached_st)); @@ -238,16 +244,19 @@ static test_return_t pre_allocate(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t post_allocate(memcached_st *memc) +static test_return_t post_allocate(memcached_st *) { - (void)memc; for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { if (benchmark_state.create_init) + { memcached_free(&benchmark_state.create[x]); + } if (benchmark_state.clone_init) + { memcached_free(&benchmark_state.clone[x]); + } } free(benchmark_state.create); @@ -281,7 +290,7 @@ 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._flush= (test_callback_fn*)world_flush; @@ -292,5 +301,5 @@ void get_world(Framework *world) 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); }