From 6b2027e922a788af9b940497dd2c2aca306ba9c0 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Thu, 17 Dec 2009 08:19:11 -0800 Subject: [PATCH] Adding in a consistent test for crc. --- tests/function.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/function.c b/tests/function.c index c62e25c4..3d3abd98 100644 --- a/tests/function.c +++ b/tests/function.c @@ -3718,7 +3718,27 @@ static test_return_t set_memory_alloc(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t enable_consistent(memcached_st *memc) +static test_return_t enable_consistent_crc(memcached_st *memc) +{ + test_return_t rc; + memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT; + memcached_hash_t hash; + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value); + if ((rc= pre_crc(memc)) != TEST_SUCCESS) + return rc; + + value= (memcached_server_distribution_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION); + test_truth(value == MEMCACHED_DISTRIBUTION_CONSISTENT); + + hash= (memcached_hash_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH); + + if (hash != MEMCACHED_HASH_CRC) + return TEST_SKIPPED; + + return TEST_SUCCESS; +} + +static test_return_t enable_consistent_hsieh(memcached_st *memc) { test_return_t rc; memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT; @@ -5703,7 +5723,8 @@ collection_st collection[] ={ {"unix_socket_nodelay", (test_callback_fn)pre_nodelay, 0, tests}, {"poll_timeout", (test_callback_fn)poll_timeout, 0, tests}, {"gets", (test_callback_fn)enable_cas, 0, tests}, - {"consistent", (test_callback_fn)enable_consistent, 0, tests}, + {"consistent_crc", (test_callback_fn)enable_consistent_crc, 0, tests}, + {"consistent_hsieh", (test_callback_fn)enable_consistent_hsieh, 0, tests}, #ifdef MEMCACHED_ENABLE_DEPRECATED {"deprecated_memory_allocators", (test_callback_fn)deprecated_set_memory_alloc, 0, tests}, #endif @@ -5718,7 +5739,7 @@ collection_st collection[] ={ {"generate", 0, 0, generate_tests}, {"generate_hsieh", (test_callback_fn)pre_hsieh, 0, generate_tests}, {"generate_ketama", (test_callback_fn)pre_behavior_ketama, 0, generate_tests}, - {"generate_hsieh_consistent", (test_callback_fn)enable_consistent, 0, generate_tests}, + {"generate_hsieh_consistent", (test_callback_fn)enable_consistent_hsieh, 0, generate_tests}, {"generate_md5", (test_callback_fn)pre_md5, 0, generate_tests}, {"generate_murmur", (test_callback_fn)pre_murmur, 0, generate_tests}, {"generate_jenkins", (test_callback_fn)pre_jenkins, 0, generate_tests}, -- 2.30.2