X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Ffunction.c;h=3d3abd9869cef0cdbc8ea19505e6044589023c5a;hb=dec0636927f5d0ae4cf06ad2710d022990419879;hp=65d414829879e39a10d2ccc306d1cba54913a0f7;hpb=965bde2b42f5ef2dd7b55b6b4b74822e7cfaa1de;p=m6w6%2Flibmemcached diff --git a/tests/function.c b/tests/function.c index 65d41482..3d3abd98 100644 --- a/tests/function.c +++ b/tests/function.c @@ -235,8 +235,6 @@ static test_return_t clone_test(memcached_st *memc) test_truth(memc_clone->flags.no_block == memc->flags.no_block); test_truth(memc_clone->flags.tcp_nodelay == memc->flags.tcp_nodelay); test_truth(memc_clone->flags.reuse_memory == memc->flags.reuse_memory); - test_truth(memc_clone->flags.use_md5 == memc->flags.use_md5); - test_truth(memc_clone->flags.use_crc == memc->flags.use_crc); test_truth(memc_clone->flags.use_cache_lookups == memc->flags.use_cache_lookups); test_truth(memc_clone->flags.support_cas == memc->flags.support_cas); test_truth(memc_clone->flags.buffer_requests == memc->flags.buffer_requests); @@ -2817,8 +2815,11 @@ static test_return_t pre_binary(memcached_st *memc); static test_return_t user_supplied_bug21(memcached_st *memc) { - if (pre_binary(memc) != MEMCACHED_SUCCESS) - return TEST_SKIPPED; + test_return_t test_rc; + test_rc= pre_binary(memc); + + if (test_rc != TEST_SUCCESS) + return test_rc; test_return_t rc; @@ -2949,7 +2950,7 @@ static test_return_t output_ketama_weighted_keys(memcached_st *trash) uint32_t server_idx = memcached_generate_hash(memc, key, strlen(key)); char *hostname = memc->hosts[server_idx].hostname; - unsigned int port = memc->hosts[server_idx].port; + in_port_t port = memc->hosts[server_idx].port; fprintf(fp, "key %s is on host /%s:%u\n", key, hostname, port); } fclose(fp); @@ -3522,8 +3523,11 @@ static test_return_t pre_binary(memcached_st *memc) static test_return_t pre_replication(memcached_st *memc) { - if (pre_binary(memc) != TEST_SUCCESS) - return TEST_FAILURE; + test_return_t test_rc; + test_rc= pre_binary(memc); + + if (test_rc != TEST_SUCCESS) + return test_rc; /* * Make sure that we store the item on all servers @@ -3714,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; @@ -4394,7 +4418,12 @@ static test_return_t init_udp(memcached_st *memc) static test_return_t binary_init_udp(memcached_st *memc) { - pre_binary(memc); + test_return_t test_rc; + test_rc= pre_binary(memc); + + if (test_rc != TEST_SUCCESS) + return test_rc; + return init_udp(memc); } @@ -4972,8 +5001,11 @@ static test_return_t ketama_compatibility_spymemcached(memcached_st *trash) static test_return_t regression_bug_434484(memcached_st *memc) { - if (pre_binary(memc) != MEMCACHED_SUCCESS) - return TEST_SKIPPED; + test_return_t test_rc; + test_rc= pre_binary(memc); + + if (test_rc != TEST_SUCCESS) + return test_rc; memcached_return_t ret; const char *key= "regression_bug_434484"; @@ -4994,8 +5026,11 @@ static test_return_t regression_bug_434484(memcached_st *memc) static test_return_t regression_bug_434843(memcached_st *memc) { - if (pre_binary(memc) != MEMCACHED_SUCCESS) - return TEST_SKIPPED; + test_return_t test_rc; + test_rc= pre_binary(memc); + + if (test_rc != TEST_SUCCESS) + return test_rc; memcached_return_t rc; unsigned int counter= 0; @@ -5201,8 +5236,9 @@ static test_return_t regression_bug_447342(memcached_st *memc) * This is to verify correct behavior in the library. Fake that two servers * are dead.. */ - unsigned int port0= memc->hosts[0].port; - unsigned int port2= memc->hosts[2].port; + in_port_t port0= memc->hosts[0].port; + in_port_t port2= memc->hosts[2].port; + memc->hosts[0].port= 0; memc->hosts[2].port= 0; @@ -5221,11 +5257,13 @@ static test_return_t regression_bug_447342(memcached_st *memc) /* Remove half of the objects */ for (int x= 0; x < (int)max_keys; ++x) + { if (x & 1) { rc= memcached_delete(memc, keys[x], key_length[x], 0); assert(rc == MEMCACHED_SUCCESS); } + } memcached_quit(memc); memc->hosts[0].port= 0; @@ -5248,6 +5286,7 @@ static test_return_t regression_bug_447342(memcached_st *memc) /* restore the memc handle */ memc->hosts[0].port= port0; memc->hosts[2].port= port2; + return TEST_SUCCESS; } @@ -5684,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 @@ -5699,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},