X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Flibmemcached-1.0%2Fmem_functions.cc;h=44143983555b429fb7f52d1dbdcb959c1ed3a940;hb=bf8213041709c75147393c8bd6b51b8f9e064f7c;hp=3884ac52e5fb0b10372f67f769a2951aab73c8e8;hpb=ad5cb8f903869065c72bb18bf98af6909189a5a9;p=awesomized%2Flibmemcached diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 3884ac52..44143983 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -39,7 +39,7 @@ #include #if defined(HAVE_LIBUUID) && HAVE_LIBUUID -#include +# include #endif /* @@ -47,8 +47,8 @@ */ #include -#include -#include +#include "libmemcached/is.h" +#include "libmemcached/server_instance.h" #include @@ -86,12 +86,13 @@ using namespace libtest; #include "tests/libmemcached-1.0/setup_and_teardowns.h" #include "tests/print.h" #include "tests/debug.h" +#include "tests/memc.hpp" #define UUID_STRING_MAXLENGTH 36 #include "tests/keys.hpp" -#include "libmemcached/instance.h" +#include "libmemcached/instance.hpp" static memcached_st * create_single_instance_memcached(const memcached_st *original_memc, const char *options) { @@ -823,6 +824,34 @@ test_return_t memcached_add_SUCCESS_TEST(memcached_st *memc) return TEST_SUCCESS; } +test_return_t regression_1067242_TEST(memcached_st *memc) +{ + test_compare(MEMCACHED_SUCCESS, memcached_set(memc, + test_literal_param(__func__), + test_literal_param("-2"), + 0, 0)); + + memcached_return_t rc; + char* value; + test_true((value= memcached_get(memc, test_literal_param(__func__), NULL, NULL, &rc))); + test_compare(MEMCACHED_SUCCESS, rc); + free(value); + + for (size_t x= 0; x < 10; x++) + { + uint64_t new_number; + test_compare(MEMCACHED_CLIENT_ERROR, + memcached_increment(memc, + test_literal_param(__func__), 1, &new_number)); + test_compare(MEMCACHED_CLIENT_ERROR, memcached_last_error(memc)); + test_true((value= memcached_get(memc, test_literal_param(__func__), NULL, NULL, &rc))); + test_compare(MEMCACHED_SUCCESS, rc); + free(value); + } + + return TEST_SUCCESS; +} + /* Set the value, then quit to make sure it is flushed. Come back in and test that add fails. @@ -1845,6 +1874,34 @@ test_return_t add_host_test(memcached_st *memc) return TEST_SUCCESS; } +test_return_t regression_1048945_TEST(memcached_st*) +{ + memcached_return status; + + memcached_server_st* list= memcached_server_list_append_with_weight(NULL, "a", 11211, 0, &status); + test_compare(status, MEMCACHED_SUCCESS); + + list= memcached_server_list_append_with_weight(list, "b", 11211, 0, &status); + test_compare(status, MEMCACHED_SUCCESS); + + list= memcached_server_list_append_with_weight(list, "c", 11211, 0, &status); + test_compare(status, MEMCACHED_SUCCESS); + + memcached_st* memc= memcached_create(NULL); + + status= memcached_server_push(memc, list); + memcached_server_list_free(list); + test_compare(status, MEMCACHED_SUCCESS); + + memcached_server_instance_st server= memcached_server_by_key(memc, test_literal_param(__func__), &status); + test_true(server); + test_compare(status, MEMCACHED_SUCCESS); + + memcached_free(memc); + + return TEST_SUCCESS; +} + test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc) { memcached_return_t rc; @@ -2708,6 +2765,25 @@ test_return_t user_supplied_bug21(memcached_st *memc) return TEST_SUCCESS; } +test_return_t ketama_TEST(memcached_st *) +{ + test::Memc memc("--server=10.0.1.1:11211 --server=10.0.1.2:11211"); + + test_compare(MEMCACHED_SUCCESS, + memcached_behavior_set(&memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, true)); + + test_compare(memcached_behavior_get(&memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED), uint64_t(1)); + + test_compare(memcached_behavior_set(&memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5), MEMCACHED_SUCCESS); + + test_compare(memcached_behavior_get(&memc, MEMCACHED_BEHAVIOR_KETAMA_HASH), MEMCACHED_HASH_MD5); + + test_compare(memcached_behavior_set_distribution(&memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY), MEMCACHED_SUCCESS); + + + return TEST_SUCCESS; +} + test_return_t output_ketama_weighted_keys(memcached_st *) { memcached_st *memc= memcached_create(NULL); @@ -3627,6 +3703,27 @@ test_return_t murmur_run (memcached_st *) #endif } +test_return_t murmur3_TEST(hashkit_st *) +{ + test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR3)); + +#ifdef WORDS_BIGENDIAN + (void)murmur3_values; + return TEST_SKIPPED; +#else + uint32_t x; + const char **ptr; + + for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) + { + test_compare(murmur3_values[x], + memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_MURMUR3)); + } + + return TEST_SUCCESS; +#endif +} + test_return_t jenkins_run (memcached_st *) { uint32_t x; @@ -4852,11 +4949,11 @@ test_return_t kill_HUP_TEST(memcached_st *original_memc) 0, 0)); test_true_got(kill(pid, SIGHUP) == 0, strerror(errno)); - test_compare(MEMCACHED_CONNECTION_FAILURE, - memcached_set(memc, - test_literal_param(__func__), // Keys - test_literal_param(__func__), // Values - 0, 0)); + memcached_return_t ret= memcached_set(memc, + test_literal_param(__func__), // Keys + test_literal_param(__func__), // Values + 0, 0); + test_compare(ret, MEMCACHED_CONNECTION_FAILURE); memcached_free(memc);