From fd3e3ff98f94ba0f60abfd49ca393d1d5fb4d102 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Thu, 14 Jan 2010 11:51:32 -0800 Subject: [PATCH] Update tests for testplus. --- tests/atomsmasher.c | 45 ++++++-------------------------------- tests/include.am | 11 ++++++++++ tests/libmemcached_world.h | 2 +- tests/plus.cpp | 3 +++ 4 files changed, 22 insertions(+), 39 deletions(-) diff --git a/tests/atomsmasher.c b/tests/atomsmasher.c index 3d58960e..490a3f92 100644 --- a/tests/atomsmasher.c +++ b/tests/atomsmasher.c @@ -14,7 +14,6 @@ */ #include "libmemcached/common.h" -#include #include #include #include @@ -90,9 +89,13 @@ infinite: 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); + } else if (rc == MEMCACHED_NOTFOUND) + { continue; + } else { WATCHPOINT_ERROR(rc); @@ -117,45 +120,14 @@ infinite: if (getenv("MEMCACHED_ATOM_BURIN_IN")) goto infinite; - return 0; + return TEST_SUCCESS; } -static memcached_return_t pre_nonblock(memcached_st *memc) +static test_return_t pre_nonblock(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); - return MEMCACHED_SUCCESS; -} - -static memcached_return_t pre_md5(memcached_st *memc) -{ - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5); - - return MEMCACHED_SUCCESS; -} - -static memcached_return_t pre_hsieh(memcached_st *memc) -{ - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH); - - return MEMCACHED_SUCCESS; -} - -static memcached_return_t enable_consistent(memcached_st *memc) -{ - memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT; - memcached_hash_t hash; - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value); - pre_hsieh(memc); - - value= (memcached_server_distribution_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION); - assert(value == MEMCACHED_DISTRIBUTION_CONSISTENT); - - hash= (memcached_hash_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH); - assert(hash == MEMCACHED_HASH_HSIEH); - - - return MEMCACHED_SUCCESS; + return TEST_SUCCESS; } /* @@ -217,9 +189,6 @@ test_st smash_tests[] ={ collection_st collection[] ={ {"smash", 0, 0, smash_tests}, - {"smash_hsieh", (test_callback_fn)pre_hsieh, 0, smash_tests}, - {"smash_hsieh_consistent", (test_callback_fn)enable_consistent, 0, smash_tests}, - {"smash_md5", (test_callback_fn)pre_md5, 0, smash_tests}, {"smash_nonblock", (test_callback_fn)pre_nonblock, 0, smash_tests}, {0, 0, 0, 0} }; diff --git a/tests/include.am b/tests/include.am index ab48b42f..1c54c1f5 100644 --- a/tests/include.am +++ b/tests/include.am @@ -118,6 +118,8 @@ MEMSLAP_COMMAND= clients/memslap $(COLLECTION) $(SUITE) MEM_COMMAND= tests/testapp $(COLLECTION) $(SUITE) +PLUS_COMMAND= tests/testplus $(COLLECTION) $(SUITE) + ATOM_COMMAND= tests/atomsmasher $(COLLECTION) $(SUITE) HASH_COMMAND= tests/testhashkit $(COLLECTION) $(SUITE) @@ -128,6 +130,9 @@ test-mem: tests/testapp test-atom: tests/atomsmasher $(ATOM_COMMAND) +test-plus: tests/testplus + $(PLUS_COMMAND) + test-hash: tests/testhashkit $(HASH_COMMAND) @@ -137,6 +142,9 @@ gdb-mem: tests/testapp gdb-atom: tests/atomsmasher $(DEBUG_COMMAND) $(ATOM_COMMAND) +gdb-plus: tests/testplus + $(DEBUG_COMMAND) $(PLUS_COMMAND) + gdb-hash: tests/testhashkit $(DEBUG_COMMAND) $(HASH_COMMAND) @@ -149,6 +157,9 @@ valgrind-mem: tests/testapp valgrind-atom: tests/atomsmasher $(VALGRIND_COMMAND) $(ATOM_COMMAND) +valgrind-plus: tests/testplus + $(VALGRIND_COMMAND) $(PLUS_COMMAND) + valgrind-hash: tests/testhashkit $(VALGRIND_COMMAND) $(HASH_COMMAND) diff --git a/tests/libmemcached_world.h b/tests/libmemcached_world.h index d51d3ad7..aab09ea3 100644 --- a/tests/libmemcached_world.h +++ b/tests/libmemcached_world.h @@ -111,7 +111,7 @@ test_return_t world_pre_run(libmemcached_test_container_st *container) test_return_t world_post_run(libmemcached_test_container_st *container) { - assert(container->memc); + test_truth(container->memc); return TEST_SUCCESS; } diff --git a/tests/plus.cpp b/tests/plus.cpp index 7a37ee17..f9cbdd5e 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -309,5 +309,8 @@ void get_world(world_st *world) world->test.post_run= reinterpret_cast(world_post_run); world->test.on_error= reinterpret_cast(world_on_error); + world->collection.startup= reinterpret_cast(world_container_startup); + world->collection.shutdown= reinterpret_cast(world_container_shutdown); + world->runner= &defualt_libmemcached_runner; } -- 2.30.2