From: Brian Aker Date: Fri, 30 Dec 2011 18:47:14 +0000 (-0800) Subject: Update tests for style/correctness. X-Git-Tag: 1.0.3~3^2~1^2~8 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=dbd192a1c0caf4eb95c433d21d124c359c00381d;p=m6w6%2Flibmemcached Update tests for style/correctness. --- diff --git a/clients/client_options.h b/clients/client_options.h index 57aefd2b..c3420b49 100644 --- a/clients/client_options.h +++ b/clients/client_options.h @@ -35,6 +35,7 @@ enum memcached_options { OPT_HASH, OPT_BINARY, OPT_UDP, + OPT_BUFFER, OPT_USERNAME, OPT_PASSWD, OPT_STAT_ARGS, diff --git a/clients/execute.cc b/clients/execute.cc index 1ada836f..6d82df6f 100644 --- a/clients/execute.cc +++ b/clients/execute.cc @@ -27,9 +27,10 @@ unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int numbe memcached_return_t rc= memcached_set(memc, pairs[x].key, pairs[x].key_length, pairs[x].value, pairs[x].value_length, 0, 0); - if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED) + if (rc != MEMCACHED_SUCCESS and rc != MEMCACHED_BUFFERED) { - fprintf(stderr, "Failured on insert of %.*s\n", + fprintf(stderr, "Failure on insert (%s) of %.*s\n", + memcached_last_error_message(memc), (unsigned int)pairs[x].key_length, pairs[x].key); } else @@ -65,12 +66,17 @@ unsigned int execute_get(memcached_st *memc, pairs_st *pairs, unsigned int numbe &value_length, &flags, &rc); if (rc != MEMCACHED_SUCCESS) - fprintf(stderr, "Failured on read of %.*s\n", + { + fprintf(stderr, "Failure on read(%s) of %.*s\n", + memcached_last_error_message(memc), (unsigned int)pairs[fetch_key].key_length, pairs[fetch_key].key); + } else + { retrieved++; + } - free(value); + ::free(value); } return retrieved; diff --git a/clients/memcp.cc b/clients/memcp.cc index 38462213..5422aa73 100644 --- a/clients/memcp.cc +++ b/clients/memcp.cc @@ -42,6 +42,8 @@ static void options_parse(int argc, char *argv[]); static bool opt_binary= false; +static bool opt_udp= false; +static bool opt_buffer= false; static int opt_verbose= 0; static char *opt_servers= NULL; static char *opt_hash= NULL; @@ -85,6 +87,37 @@ int main(int argc, char *argv[]) initialize_sockets(); memcached_st *memc= memcached_create(NULL); + + if (opt_udp) + { + if (opt_verbose) + { + std::cout << "Enabling UDP" << std::endl; + } + + if (memcached_failed(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, opt_udp))) + { + memcached_free(memc); + std::cerr << "Could not enable UDP protocol." << std::endl; + return EXIT_FAILURE; + } + } + + if (opt_buffer) + { + if (opt_verbose) + { + std::cout << "Enabling MEMCACHED_BEHAVIOR_BUFFER_REQUESTS" << std::endl; + } + + if (memcached_failed(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, opt_buffer))) + { + memcached_free(memc); + std::cerr << "Could not enable MEMCACHED_BEHAVIOR_BUFFER_REQUESTS." << std::endl; + return EXIT_FAILURE; + } + } + process_hash_option(memc, opt_hash); if (opt_servers == NULL) @@ -114,9 +147,7 @@ int main(int argc, char *argv[]) memcached_server_push(memc, servers); memcached_server_list_free(servers); - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, - (uint64_t)opt_binary); - + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary); if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { memcached_free(memc); @@ -180,7 +211,7 @@ int main(int argc, char *argv[]) } ssize_t read_length; - if ((read_length= read(fd, file_buffer_ptr, (size_t)sbuf.st_size)) == -1) + if ((read_length= ::read(fd, file_buffer_ptr, (size_t)sbuf.st_size)) == -1) { std::cerr << "Error while reading file " << file_buffer_ptr << " (" << strerror(errno) << ")" << std::endl; exit(EXIT_FAILURE); @@ -212,14 +243,14 @@ int main(int argc, char *argv[]) opt_expires, opt_flags); } - if (rc != MEMCACHED_SUCCESS) + if (memcached_failed(rc)) { std::cerr << "Error occrrured during operation: " << memcached_last_error_message(memc) << std::endl; exit_code= EXIT_FAILURE; } - free(file_buffer_ptr); - close(fd); + ::free(file_buffer_ptr); + ::close(fd); optind++; } @@ -250,6 +281,8 @@ static void options_parse(int argc, char *argv[]) {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, + {(OPTIONSTRING)"udp", no_argument, NULL, OPT_UDP}, + {(OPTIONSTRING)"buffer", no_argument, NULL, OPT_BUFFER}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, @@ -357,6 +390,14 @@ static void options_parse(int argc, char *argv[]) close_stdio(); break; + case OPT_UDP: + opt_udp= true; + break; + + case OPT_BUFFER: + opt_buffer= true; + break; + case '?': /* getopt_long already printed an error message. */ exit(1); diff --git a/clients/memslap.cc b/clients/memslap.cc index f00ba457..a8c0da1e 100644 --- a/clients/memslap.cc +++ b/clients/memslap.cc @@ -53,6 +53,8 @@ #include #include +#include + #include #include "client_options.h" @@ -152,7 +154,7 @@ static unsigned int opt_createial_load= 0; static unsigned int opt_concurrency= 0; static int opt_displayflag= 0; static char *opt_servers= NULL; -static int opt_udp_io= 0; +static bool opt_udp_io= false; test_t opt_test= SET_TEST; extern "C" { @@ -243,26 +245,31 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion) memcached_st *memc= memcached_create(NULL); + memcached_server_push(memc, servers); + /* We need to set udp behavior before adding servers to the client */ if (opt_udp_io) { - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, - (uint64_t)opt_udp_io); - for (uint32_t x= 0; x < memcached_server_list_count(servers); x++ ) + if (memcached_failed(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, opt_udp_io))) { - servers[x].type= MEMCACHED_CONNECTION_UDP; + std::cerr << "Failed to enable UDP." << std::endl; + memcached_free(memc); + exit(EXIT_FAILURE); } } - memcached_server_push(memc, servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t)opt_binary); if (opt_flush) + { flush_all(memc); + } if (opt_createial_load) + { pairs= load_create_data(memc, opt_createial_load, &actual_loaded); + } char **keys= static_cast(calloc(actual_loaded, sizeof(char*))); size_t *key_lengths= static_cast(calloc(actual_loaded, sizeof(size_t))); @@ -399,7 +406,7 @@ void options_parse(int argc, char *argv[]) "does not currently support get ops.\n"); exit(1); } - opt_udp_io= 1; + opt_udp_io= true; break; case OPT_BINARY: diff --git a/clients/utilities.cc b/clients/utilities.cc index 79f2f2ae..d0b3dba8 100644 --- a/clients/utilities.cc +++ b/clients/utilities.cc @@ -98,6 +98,7 @@ static const char *lookup_help(memcached_options option) case OPT_BINARY: return("Switch to binary protocol."); case OPT_ANALYZE: return("Analyze the provided servers."); case OPT_UDP: return("Use UDP protocol when communicating with server."); + case OPT_BUFFER: return("Enable request buffering."); case OPT_USERNAME: return "Username to use for SASL authentication"; case OPT_PASSWD: return "Password to use for SASL authentication"; case OPT_FILE: return "Path to file in which to save result"; diff --git a/tests/include.am b/tests/include.am index 35b0a913..5afdf5bf 100644 --- a/tests/include.am +++ b/tests/include.am @@ -202,8 +202,8 @@ valgrind-memstat: clients/memstat @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server" @rm tests/Xumemc.pid -test-mem: tests/var tests/testapp - @tests/testapp +test-mem: tests/var tests/libmemcached-1.0/testapp + @tests/libmemcached-1.0/testapp test-sasl: tests/sasl @tests/sasl @@ -238,9 +238,6 @@ gdb-sasl: tests/sasl gdb-atom: tests/atomsmasher @$(DEBUG_COMMAND) tests/atomsmasher -gdb-udp: tests/testudp - @$(DEBUG_COMMAND) tests/testudp - gdb-plus: tests/testplus $(DEBUG_COMMAND) tests/testplus @@ -268,9 +265,6 @@ valgrind-failure: tests/failure valgrind-atom: tests/atomsmasher $(VALGRIND_COMMAND) tests/atomsmasher -valgrind-udp: tests/testudp - $(VALGRIND_COMMAND) tests/testudp - valgrind-plus: tests/testplus @$(VALGRIND_COMMAND) tests/testplus @@ -292,9 +286,6 @@ helgrind-mem: tests/testapp helgrind-atom: tests/atomsmasher @$(HELGRIND_COMMAND) tests/atomsmasher -helgrind-udp: tests/testudp - @$(HELGRIND_COMMAND) tests/testudp - helgrind-plus: tests/testplus @$(HELGRIND_COMMAND) tests/testplus diff --git a/tests/libmemcached-1.0/include.am b/tests/libmemcached-1.0/include.am index 29c02b32..81653a1c 100644 --- a/tests/libmemcached-1.0/include.am +++ b/tests/libmemcached-1.0/include.am @@ -123,6 +123,9 @@ tests_testudp_LDADD= $(tests_testudp_DEPENDENCIES) check_PROGRAMS+= tests/testudp noinst_PROGRAMS+= tests/testudp +test-udp: tests/testudp + @tests/testudp + tests_testplus_SOURCES= tests/libmemcached-1.0/plus.cpp tests_testplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_testplus_DEPENDENCIES= $(TESTS_LDADDS) diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 83ea4460..a9933f6f 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -997,8 +997,8 @@ static test_return_t read_through(memcached_st *memc) test_false(string_length); test_false(string); - rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_GET_FAILURE, *(void **)&cb); - test_compare(MEMCACHED_SUCCESS, rc); + test_compare(MEMCACHED_SUCCESS, + memcached_callback_set(memc, MEMCACHED_CALLBACK_GET_FAILURE, *(void **)&cb)); string= memcached_get(memc, test_literal_param(__func__), @@ -1035,7 +1035,7 @@ static test_return_t get_test(memcached_st *memc) rc= memcached_delete(memc, test_literal_param(__func__), time_t(0)); - test_true_got(rc == MEMCACHED_BUFFERED || rc == MEMCACHED_NOTFOUND, memcached_last_error_message(memc)); + test_true_got(rc == MEMCACHED_BUFFERED or rc == MEMCACHED_NOTFOUND, memcached_last_error_message(memc)); test_compare(query_id +1, memcached_query_id(memc)); string= memcached_get(memc, @@ -1253,8 +1253,6 @@ static test_return_t mget_end(memcached_st *memc) size_t lengths[]= { 3, 4 }; const char *values[]= { "fjord", "41" }; - memcached_return_t rc; - // Set foo and foo2 for (size_t x= 0; x < test_array_length(keys); x++) { @@ -1277,6 +1275,7 @@ static test_return_t mget_end(memcached_st *memc) char key[MEMCACHED_MAX_KEY]; size_t key_length; + memcached_return_t rc; // this should get both for (size_t x= 0; x < test_array_length(keys); x++) @@ -1382,25 +1381,24 @@ static test_return_t increment_with_initial_test(memcached_st *memc) static test_return_t decrement_test(memcached_st *memc) { - uint64_t new_number; - memcached_return_t rc; - const char *value= "3"; - - rc= memcached_set(memc, - test_literal_param("number"), - value, strlen(value), - (time_t)0, (uint32_t)0); - test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); + test_compare(return_value_based_on_buffering(memc), + memcached_set(memc, + test_literal_param(__func__), + test_literal_param("3"), + time_t(0), uint32_t(0))); + // Make sure we flush the value we just set + test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); + uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_decrement(memc, - test_literal_param("number"), + test_literal_param(__func__), 1, &new_number)); test_compare(uint64_t(2), new_number); test_compare(MEMCACHED_SUCCESS, memcached_decrement(memc, - test_literal_param("number"), + test_literal_param(__func__), 1, &new_number)); test_compare(uint64_t(1), new_number); @@ -1411,21 +1409,23 @@ static test_return_t decrement_with_initial_test(memcached_st *memc) { test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); - uint64_t new_number; uint64_t initial= 3; test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); + uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_decrement_with_initial(memc, - test_literal_param("number"), - 1, initial, 0, &new_number)); + test_literal_param(__func__), + 1, initial, + 0, &new_number)); test_compare(new_number, initial); test_compare(MEMCACHED_SUCCESS, memcached_decrement_with_initial(memc, - test_literal_param("number"), - 1, initial, 0, &new_number)); + test_literal_param(__func__), + 1, initial, + 0, &new_number)); test_compare(new_number, (initial - 1)); return TEST_SUCCESS; @@ -1433,24 +1433,28 @@ static test_return_t decrement_with_initial_test(memcached_st *memc) static test_return_t increment_by_key_test(memcached_st *memc) { - uint64_t new_number; - memcached_return_t rc; const char *master_key= "foo"; const char *key= "number"; const char *value= "0"; - rc= memcached_set_by_key(memc, master_key, strlen(master_key), - key, strlen(key), - value, strlen(value), - (time_t)0, (uint32_t)0); - test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); + test_compare(return_value_based_on_buffering(memc), + memcached_set_by_key(memc, master_key, strlen(master_key), + key, strlen(key), + value, strlen(value), + time_t(0), uint32_t(0))); + + // Make sure we flush the value we just set + test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); + uint64_t new_number; test_compare(MEMCACHED_SUCCESS, - memcached_increment_by_key(memc, master_key, strlen(master_key), key, strlen(key), 1, &new_number)); + memcached_increment_by_key(memc, master_key, strlen(master_key), + key, strlen(key), 1, &new_number)); test_compare(uint64_t(1), new_number); test_compare(MEMCACHED_SUCCESS, - memcached_increment_by_key(memc, master_key, strlen(master_key), key, strlen(key), 1, &new_number)); + memcached_increment_by_key(memc, master_key, strlen(master_key), + key, strlen(key), 1, &new_number)); test_compare(uint64_t(2), new_number); return TEST_SUCCESS; @@ -1461,21 +1465,20 @@ static test_return_t increment_with_initial_by_key_test(memcached_st *memc) test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); uint64_t new_number; - memcached_return_t rc; const char *master_key= "foo"; const char *key= "number"; uint64_t initial= 0; - rc= memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), - key, strlen(key), - 1, initial, 0, &new_number); - test_compare(MEMCACHED_SUCCESS, rc); + test_compare(MEMCACHED_SUCCESS, + memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), + key, strlen(key), + 1, initial, 0, &new_number)); test_compare(new_number, initial); - rc= memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), - key, strlen(key), - 1, initial, 0, &new_number); - test_compare(MEMCACHED_SUCCESS, rc); + test_compare(MEMCACHED_SUCCESS, + memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), + key, strlen(key), + 1, initial, 0, &new_number)); test_compare(new_number, (initial +1)); return TEST_SUCCESS; @@ -1484,15 +1487,14 @@ static test_return_t increment_with_initial_by_key_test(memcached_st *memc) static test_return_t decrement_by_key_test(memcached_st *memc) { uint64_t new_number; - memcached_return_t rc; const char *value= "3"; - rc= memcached_set_by_key(memc, - test_literal_param("foo"), - test_literal_param("number"), - value, strlen(value), - (time_t)0, (uint32_t)0); - test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); + test_compare(return_value_based_on_buffering(memc), + memcached_set_by_key(memc, + test_literal_param("foo"), + test_literal_param("number"), + value, strlen(value), + (time_t)0, (uint32_t)0)); test_compare(MEMCACHED_SUCCESS, memcached_decrement_by_key(memc, @@ -1542,12 +1544,11 @@ static test_return_t binary_increment_with_prefix_test(memcached_st *orig_memc) test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, (void *)"namespace:")); - memcached_return_t rc; - rc= memcached_set(memc, - test_literal_param("number"), - test_literal_param("0"), - (time_t)0, (uint32_t)0); - test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); + test_compare(return_value_based_on_buffering(memc), + memcached_set(memc, + test_literal_param("number"), + test_literal_param("0"), + (time_t)0, (uint32_t)0)); uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, @@ -1566,20 +1567,20 @@ static test_return_t binary_increment_with_prefix_test(memcached_st *orig_memc) static test_return_t quit_test(memcached_st *memc) { - memcached_return_t rc; - const char *key= "fudge"; const char *value= "sanford and sun"; - rc= memcached_set(memc, key, strlen(key), - value, strlen(value), - (time_t)10, (uint32_t)3); - test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); + test_compare(return_value_based_on_buffering(memc), + memcached_set(memc, + test_literal_param(__func__), + value, strlen(value), + (time_t)10, (uint32_t)3)); memcached_quit(memc); - rc= memcached_set(memc, key, strlen(key), - value, strlen(value), - (time_t)50, (uint32_t)9); - test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); + test_compare(return_value_based_on_buffering(memc), + memcached_set(memc, + test_literal_param(__func__), + value, strlen(value), + (time_t)50, (uint32_t)9)); return TEST_SUCCESS; } @@ -1706,16 +1707,15 @@ static test_return_t mget_result_function(memcached_st *memc) size_t counter; memcached_execute_fn callbacks[1]; - /* We need to empty the server before continueing test */ - test_compare(MEMCACHED_SUCCESS, - memcached_flush(memc, 0)); for (uint32_t x= 0; x < 3; x++) { - memcached_return_t rc= memcached_set(memc, keys[x], key_length[x], - keys[x], key_length[x], - (time_t)50, (uint32_t)9); - test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); + test_compare(return_value_based_on_buffering(memc), + memcached_set(memc, keys[x], key_length[x], + keys[x], key_length[x], + time_t(50), uint32_t(9))); } + test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); + memcached_quit(memc); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); @@ -1741,10 +1741,6 @@ static test_return_t mget_test(memcached_st *memc) char *return_value; size_t return_value_length; - /* We need to empty the server before continueing test */ - test_compare(MEMCACHED_SUCCESS, - memcached_flush(memc, 0)); - test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); @@ -2119,36 +2115,24 @@ static test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned, const memcached_return_t expect) +static test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned, memcached_return_t& rc) { - memcached_return_t rc; - char return_key[MEMCACHED_MAX_KEY]; - size_t return_key_length; - char *return_value; - size_t return_value_length; - uint32_t flags; - keys_returned= 0; - while ((return_value= memcached_fetch(memc, return_key, &return_key_length, - &return_value_length, &flags, &rc))) + + memcached_result_st* result; + while ((result= memcached_fetch_result(memc, NULL, &rc))) { - test_true(return_value); - test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); - free(return_value); + test_compare(MEMCACHED_SUCCESS, rc); keys_returned+= 1; } - if (memcached_success(expect) and memcached_success(rc)) - { - return TEST_SUCCESS; - } - else if (expect == rc) - { - return TEST_SUCCESS; - } - fprintf(stderr, "\n%s:%u %s(#%u)\n", __FILE__, __LINE__, memcached_strerror(NULL, rc), keys_returned); + return TEST_SUCCESS; +} - return TEST_FAILURE; +static test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned) +{ + memcached_return_t rc; + return fetch_all_results(memc, keys_returned, rc); } /* Test case provided by Cal Haldenbrand */ @@ -2180,10 +2164,12 @@ static test_return_t user_supplied_bug1(memcached_st *memc) } total+= size; - char key[22]; + char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int key_length= snprintf(key, sizeof(key), "%u", x); test_compare(MEMCACHED_SUCCESS, - memcached_set(memc, key, key_length, randomstuff, strlen(randomstuff), time_t(0), HALDENBRAND_FLAG_KEY)); + memcached_set(memc, key, key_length, + randomstuff, strlen(randomstuff), + time_t(0), HALDENBRAND_FLAG_KEY)); } test_true(total > HALDENBRAND_KEY_COUNT); @@ -2233,10 +2219,11 @@ static test_return_t user_supplied_bug2(memcached_st *memc) continue; } test_compare(uint32_t(HALDENBRAND_FLAG_KEY), flags); + test_true(getval); total_value_length+= val_len; errors= 0; - free(getval); + ::free(getval); } return TEST_SUCCESS; @@ -2245,8 +2232,8 @@ static test_return_t user_supplied_bug2(memcached_st *memc) /* Do a large mget() over all the keys we think exist */ static test_return_t user_supplied_bug3(memcached_st *memc) { - test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1)); - test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1)); + test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true)); + test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true)); #ifdef NOT_YET memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576); @@ -2272,14 +2259,14 @@ static test_return_t user_supplied_bug3(memcached_st *memc) memcached_mget(memc, &keys[0], &key_lengths[0], key_lengths.size())); unsigned int keys_returned; - test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned, MEMCACHED_SUCCESS)); + test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned)); test_compare(HALDENBRAND_KEY_COUNT, keys_returned); for (std::vector::iterator iter= keys.begin(); iter != keys.end(); iter++) { - free(*iter); + ::free(*iter); } return TEST_SUCCESS; @@ -2302,9 +2289,13 @@ static test_return_t user_supplied_bug4(memcached_st *memc) test_compare(MEMCACHED_NO_SERVERS, memcached_mget(memc, keys, key_length, 3)); - unsigned int keys_returned; - test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned, MEMCACHED_NOTFOUND)); - test_zero(keys_returned); + { + unsigned int keys_returned; + memcached_return_t rc; + test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned, rc)); + test_compare(MEMCACHED_NOTFOUND, rc); + test_zero(keys_returned); + } for (uint32_t x= 0; x < 3; x++) { @@ -2364,7 +2355,8 @@ static test_return_t user_supplied_bug5(memcached_st *memc) memcached_mget(memc, keys, key_length, 4)); unsigned int count; - test_compare(TEST_SUCCESS, fetch_all_results(memc, count, MEMCACHED_NOTFOUND)); + test_compare(TEST_SUCCESS, fetch_all_results(memc, count, rc)); + test_compare(MEMCACHED_NOTFOUND, rc); test_zero(count); for (uint32_t x= 0; x < 4; x++) @@ -2381,12 +2373,12 @@ static test_return_t user_supplied_bug5(memcached_st *memc) &value_length, &flags, &rc); test_compare(rc, MEMCACHED_SUCCESS); test_true(value); - free(value); + ::free(value); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 4)); - test_compare(TEST_SUCCESS, fetch_all_results(memc, count, MEMCACHED_SUCCESS)); + test_compare(TEST_SUCCESS, fetch_all_results(memc, count)); test_compare(4U, count); } delete [] insert_data; @@ -3205,6 +3197,7 @@ static test_return_t get_read_count(memcached_st *memc) static test_return_t get_read(memcached_st *memc) { + size_t keys_returned= 0; for (size_t x= 0; x < global_count; x++) { size_t return_value_length; @@ -3218,9 +3211,11 @@ static test_return_t get_read(memcached_st *memc) */ if (rc == MEMCACHED_SUCCESS && return_value) { + keys_returned++; free(return_value); } } + test_compare_warn_hint(global_count, keys_returned, "Possible false, positive, memcached may have ejected key/value based on memory needs"); return TEST_SUCCESS; } @@ -3236,7 +3231,7 @@ static test_return_t mget_read(memcached_st *memc) // Go fetch the keys and test to see if all of them were returned { unsigned int keys_returned; - test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned, MEMCACHED_SUCCESS)); + test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned)); test_true(keys_returned > 0); test_compare_warn_hint(global_count, keys_returned, "Possible false, positive, memcached may have ejected key/value based on memory needs"); } @@ -3361,10 +3356,15 @@ static test_return_t mget_read_function(memcached_st *memc) static test_return_t delete_generate(memcached_st *memc) { + size_t total= 0; for (size_t x= 0; x < global_count; x++) { - (void)memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0); + if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0))) + { + total++; + } } + test_compare_warn_hint(global_count, total, "Possible false, positive, memcached may have ejected key/value based on memory needs"); return TEST_SUCCESS; } @@ -3373,10 +3373,15 @@ static test_return_t delete_buffer_generate(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true); + size_t total= 0; for (size_t x= 0; x < global_count; x++) { - (void)memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0); + if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0))) + { + total++; + } } + test_compare_warn_hint(global_count, total, "Possible false, positive, memcached may have ejected key/value based on memory needs"); return TEST_SUCCESS; } diff --git a/util/instance.cc b/util/instance.cc index 23c8aec4..19d01fcf 100644 --- a/util/instance.cc +++ b/util/instance.cc @@ -192,7 +192,7 @@ bool Instance::run() switch(errno) { default: - std::cerr << "Failed during send(" << strerror(errno) << ")" << std::endl; + std::cerr << "Failed dureng send(" << strerror(errno) << ")" << std::endl; break; } }