X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fmem_functions.cc;h=d7402dbd0b2f8b4786f396c79cb4f6d711cb0555;hb=e82f6a9bffe896a579ae5013a9cab51180cd003d;hp=3c2064f1131cb97d3cf549578e05b886070c3b49;hpb=d8dedbd561c7cb57daf4192fe57ce5e205bcadd7;p=awesomized%2Flibmemcached diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index 3c2064f1..d7402dbd 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -66,6 +66,7 @@ #include "tests/deprecated.h" #include "tests/parser.h" #include "tests/pool.h" +#include "tests/namespace.h" #include "tests/string.h" #include "tests/replication.h" #include "tests/basic.h" @@ -1135,30 +1136,28 @@ static test_return_t get_test3(memcached_st *memc) static test_return_t get_test4(memcached_st *memc) { - memcached_return_t rc; const char *key= "foo"; - char *value; size_t value_length= 8191; - char *string; - size_t string_length; - uint32_t flags; - uint32_t x; - value = (char*)malloc(value_length); + char *value= (char*)malloc(value_length); test_true(value); - for (x= 0; x < value_length; x++) + for (uint32_t x= 0; x < value_length; x++) + { value[x] = (char) (x % 127); + } - rc= memcached_set(memc, key, strlen(key), - value, value_length, - (time_t)0, (uint32_t)0); - test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); + memcached_return_t rc= memcached_set(memc, key, strlen(key), + value, value_length, + (time_t)0, (uint32_t)0); + test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); - for (x= 0; x < 10; x++) + for (uint32_t x= 0; x < 10; x++) { - string= memcached_get(memc, key, strlen(key), - &string_length, &flags, &rc); + uint32_t flags; + size_t string_length; + char *string= memcached_get(memc, key, strlen(key), + &string_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(string); @@ -2911,19 +2910,14 @@ static test_return_t user_supplied_bug17(memcached_st *memc) From Andrei on IRC */ -static test_return_t user_supplied_bug19(memcached_st *not_used) +static test_return_t user_supplied_bug19(memcached_st *) { - memcached_st *memc; - const memcached_server_st *server; memcached_return_t res; - (void)not_used; - - memc= memcached_create(NULL); - memcached_server_add_with_weight(memc, "localhost", 11311, 100); - memcached_server_add_with_weight(memc, "localhost", 11312, 100); + memcached_st *memc= memcached(test_literal_param("--server=localhost:11311/?100 --server=localhost:11312/?100")); - server= memcached_server_by_key(memc, "a", 1, &res); + const memcached_server_st *server= memcached_server_by_key(memc, "a", 1, &res); + test_true(server); memcached_free(memc); @@ -3978,16 +3972,12 @@ static test_return_t selection_of_namespace_tests(memcached_st *memc) memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, long_key)); /* Test for a bad prefix, but with a short key */ - test_compare_got(MEMCACHED_SUCCESS, + test_compare_got(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) ? MEMCACHED_INVALID_ARGUMENTS : MEMCACHED_SUCCESS, rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, 1), memcached_strerror(NULL, rc)); - if (not memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)) - { - strncpy(long_key, "dog cat", sizeof(long_key)); - test_compare(MEMCACHED_BAD_KEY_PROVIDED, - memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, long_key)); - } + test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) ? MEMCACHED_SUCCESS : MEMCACHED_BAD_KEY_PROVIDED, + memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, "dog cat")); } return TEST_SUCCESS; @@ -4880,26 +4870,18 @@ static test_return_t memcached_get_hashkit_test (memcached_st *memc) We are testing the error condition when we connect to a server via memcached_get() but find that the server is not available. */ -static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc) +static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *) { - (void)memc; - memcached_st *tl_memc_h; - const char *key= "MemcachedLives"; size_t len; uint32_t flags; memcached_return rc; - char *value; // Create a handle. - tl_memc_h= memcached_create(NULL); - memcached_server_st *servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist - test_true(servers); - memcached_server_push(tl_memc_h, servers); - memcached_server_list_free(servers); + memcached_st *tl_memc_h= memcached(test_literal_param("--server=localhost:9898 --server=localhost:9899")); // This server should not exist // See if memcached is reachable. - value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc); + char *value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc); test_false(value); test_compare(0, len); @@ -6475,6 +6457,7 @@ test_st parser_tests[] ={ {"bad server strings", 0, (test_callback_fn*)servers_bad_test }, {"server with weights", 0, (test_callback_fn*)server_with_weight_test }, {"parsing servername, port, and weight", 0, (test_callback_fn*)test_hostname_port_weight }, + {"--socket=", 0, (test_callback_fn*)test_parse_socket }, {0, 0, (test_callback_fn*)0} }; @@ -6484,10 +6467,8 @@ test_st virtual_bucket_tests[] ={ }; test_st namespace_tests[] ={ - {"basic tests", 0, (test_callback_fn*)selection_of_namespace_tests }, -#if 0 - {"increment", 0, (test_callback_fn*)memcached_increment_namespace }, -#endif + {"basic tests", true, (test_callback_fn*)selection_of_namespace_tests }, + {"increment", true, (test_callback_fn*)memcached_increment_namespace }, {0, 0, (test_callback_fn*)0} }; @@ -6526,13 +6507,14 @@ collection_st collection[] ={ {"namespace", (test_callback_fn*)set_namespace, 0, tests}, {"namespace(BINARY)", (test_callback_fn*)set_namespace_and_binary, 0, tests}, {"specific namespace", 0, 0, namespace_tests}, + {"specific namespace(BINARY)", (test_callback_fn*)pre_binary, 0, namespace_tests}, {"sasl_auth", (test_callback_fn*)pre_sasl, 0, sasl_auth_tests }, {"sasl", (test_callback_fn*)pre_sasl, 0, tests }, {"version_1_2_3", (test_callback_fn*)check_for_1_2_3, 0, version_1_2_3}, {"string", 0, 0, string_tests}, {"result", 0, 0, result_tests}, {"async", (test_callback_fn*)pre_nonblock, 0, async_tests}, - {"async_binary", (test_callback_fn*)pre_nonblock_binary, 0, async_tests}, + {"async(BINARY)", (test_callback_fn*)pre_nonblock_binary, 0, async_tests}, {"Cal Haldenbrand's tests", 0, 0, haldenbrand_tests}, {"user", 0, 0, user_tests}, {"generate", 0, 0, generate_tests},