From 91e92172731fe8a37e562a165d25a312569aff44 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 26 Jul 2011 09:19:26 -0700 Subject: [PATCH] OSX fixes, make memcapable a test. --- .bzrignore | 1 + Makefile.am | 1 - libmemcached/connect.cc | 11 +++- libmemcached/error.cc | 6 +- libmemcached/error.hpp | 5 +- libmemcached/fetch.cc | 6 +- libmemcached/server.cc | 4 ++ libtest/comparison.hpp | 23 +++++++- libtest/include.am | 2 + libtest/memcached.cc | 2 + tests/cycle.cc | 3 +- tests/error_conditions.cc | 4 +- tests/include.am | 43 +++++++------- tests/mem_functions.cc | 17 ++++-- tests/memcapable.cc | 115 ++++++++++++++++++++++++++++++++++++++ tests/namespace.cc | 8 +-- tests/parser.cc | 31 +++++----- tests/plus.cpp | 6 +- tests/replication.cc | 4 +- 19 files changed, 229 insertions(+), 63 deletions(-) create mode 100644 tests/memcapable.cc diff --git a/.bzrignore b/.bzrignore index 7a79ca5e..f091ff10 100644 --- a/.bzrignore +++ b/.bzrignore @@ -112,3 +112,4 @@ tests/var/ unittests/unittests out *.orig +tests/memcapable diff --git a/Makefile.am b/Makefile.am index 16b22797..b47dfc82 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,6 @@ ACLOCAL_AMFLAGS = -I m4 # includes append to these: SUFFIXES = .PHONY = -PHONY = TESTS = CLEANFILES = DISTCLEANFILES = diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index ecff6386..7044306e 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -515,11 +515,20 @@ static memcached_return_t network_connect(memcached_server_st *ptr) struct timeval next_time; if (gettimeofday(&next_time, NULL) == 0) + { ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout; + } + } + + if (memcached_has_current_error(*ptr)) + { + return memcached_server_error_return(ptr); } - if (timeout_error_occured) + if (timeout_error_occured and ptr->state < MEMCACHED_SERVER_STATE_IN_PROGRESS) + { return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT); + } return memcached_set_error(*ptr, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_AT); /* The last error should be from connect() */ } diff --git a/libmemcached/error.cc b/libmemcached/error.cc index 70f5d227..391e67c1 100644 --- a/libmemcached/error.cc +++ b/libmemcached/error.cc @@ -407,7 +407,6 @@ const char *memcached_last_error_message(memcached_st *memc) return memc->error_messages->message; } - bool memcached_has_current_error(memcached_st &memc) { if (memc.error_messages @@ -420,6 +419,11 @@ bool memcached_has_current_error(memcached_st &memc) return false; } +bool memcached_has_current_error(memcached_server_st& server) +{ + return memcached_has_current_error(*(server.root)); +} + memcached_return_t memcached_last_error(memcached_st *memc) { if (not memc) diff --git a/libmemcached/error.hpp b/libmemcached/error.hpp index 55ff1bd9..1eaba13f 100644 --- a/libmemcached/error.hpp +++ b/libmemcached/error.hpp @@ -82,7 +82,10 @@ LIBMEMCACHED_LOCAL memcached_return_t memcached_set_errno(memcached_server_st&, int local_errno, const char *at); LIBMEMCACHED_LOCAL -bool memcached_has_current_error(memcached_st &memc); +bool memcached_has_current_error(memcached_st&); + +LIBMEMCACHED_LOCAL +bool memcached_has_current_error(memcached_server_st&); LIBMEMCACHED_LOCAL void memcached_error_free(memcached_st&); diff --git a/libmemcached/fetch.cc b/libmemcached/fetch.cc index 7ef608dd..d5730105 100644 --- a/libmemcached/fetch.cc +++ b/libmemcached/fetch.cc @@ -163,7 +163,11 @@ memcached_result_st *memcached_fetch_result(memcached_st *ptr, char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; *error= memcached_response(server, buffer, sizeof(buffer), result); - if (*error == MEMCACHED_SUCCESS) + if (*error == MEMCACHED_IN_PROGRESS) + { + continue; + } + else if (*error == MEMCACHED_SUCCESS) { result->count++; return result; diff --git a/libmemcached/server.cc b/libmemcached/server.cc index 98b16eef..bde53c7e 100644 --- a/libmemcached/server.cc +++ b/libmemcached/server.cc @@ -119,7 +119,9 @@ memcached_server_st *__server_create_with(const memcached_st *memc, self= _server_create(self, memc); if (not self) + { return NULL; + } _server_init(self, const_cast(memc), hostname, port, weight, type); @@ -237,7 +239,9 @@ memcached_return_t memcached_server_execute(memcached_st *ptr, unsigned int iferror= (*callback)(ptr, instance, context); if (iferror) + { continue; + } } return MEMCACHED_SUCCESS; diff --git a/libtest/comparison.hpp b/libtest/comparison.hpp index f02e8d88..86661a28 100644 --- a/libtest/comparison.hpp +++ b/libtest/comparison.hpp @@ -36,6 +36,10 @@ #pragma once +#include +#include +#include + namespace libtest { template @@ -55,7 +59,24 @@ bool _compare(const char *file, int line, const char *func, T_comparable __expec { if (__expected != __actual) { - libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\""; + if (typeid(__expected) == typeid(memcached_return_t)) + { + libtest::stream::make_cerr(file, line, func) << "Expected \"" + << memcached_strerror(NULL, memcached_return_t(__expected)) + << "\" got \"" + << memcached_strerror(NULL, memcached_return_t(__actual)) << "\""; + } + else if (typeid(__expected) == typeid(test_return_t)) + { + libtest::stream::make_cerr(file, line, func) << "Expected \"" + << test_strerror(test_return_t(__expected)) + << "\" got \"" + << test_strerror(test_return_t(__actual)) << "\""; + } + else + { + libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\""; + } return false; } diff --git a/libtest/include.am b/libtest/include.am index 4fcfa1b9..7cda0f9b 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -99,6 +99,8 @@ tests/var/tmp: tests/var/run: $(mkdir_p) tests/var/run +.PHONY+= tests/var + libtest_unittest_CFLAGS= libtest_unittest_LDADD= ${LIBTEST_LDADD} diff --git a/libtest/memcached.cc b/libtest/memcached.cc index 3b63c0fc..e7112ed6 100644 --- a/libtest/memcached.cc +++ b/libtest/memcached.cc @@ -196,6 +196,8 @@ bool Memcached::build(int argc, const char *argv[]) arg_buffer << " -u root "; } + arg_buffer << " -l 127.0.0.1 "; + for (int x= 1 ; x < argc ; x++) { arg_buffer << " " << argv[x] << " "; diff --git a/tests/cycle.cc b/tests/cycle.cc index 04b00f70..957b52b0 100644 --- a/tests/cycle.cc +++ b/tests/cycle.cc @@ -53,8 +53,6 @@ using namespace libtest; -#define SERVERS_TO_CREATE 5 - #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif @@ -148,5 +146,6 @@ void get_world(Framework *world) world->collection_shutdown= (test_callback_fn*)world_container_shutdown; world->set_runner(&defualt_libmemcached_runner); + world->set_socket(); } diff --git a/tests/error_conditions.cc b/tests/error_conditions.cc index bd80f8e7..66e7c44e 100644 --- a/tests/error_conditions.cc +++ b/tests/error_conditions.cc @@ -52,10 +52,10 @@ test_return_t memcached_increment_MEMCACHED_NO_SERVERS(memcached_st *) memc_ptr= memcached_create(NULL); test_true(memc_ptr); - memcached_increment(memc_ptr, memcached_literal_param("dead key"), 1, NULL); + memcached_increment(memc_ptr, test_literal_param("dead key"), 1, NULL); test_true(memcached_last_error(memc_ptr) == MEMCACHED_NO_SERVERS); - memcached_increment(memc_ptr, memcached_literal_param("dead key"), 1, NULL); + memcached_increment(memc_ptr, test_literal_param("dead key"), 1, NULL); test_true(memcached_last_error(memc_ptr) == MEMCACHED_NO_SERVERS); memcached_free(memc_ptr); diff --git a/tests/include.am b/tests/include.am index 93f26bed..954f32b2 100644 --- a/tests/include.am +++ b/tests/include.am @@ -41,22 +41,13 @@ noinst_HEADERS+= \ tests/string.h \ tests/virtual_buckets.h - -noinst_PROGRAMS+= \ - tests/atomsmasher \ - tests/cycle \ - tests/hash_plus \ - tests/testapp \ - tests/testhashkit \ - tests/testplus \ - tests/testudp - # Cycle should always run first tests_cycle_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) tests_cycle_SOURCES= tests/cycle.cc tests_cycle_DEPENDENCIES= $(TESTS_LDADDS) tests_cycle_LDADD= $(tests_cycle_DEPENDENCIES) check_PROGRAMS+= tests/cycle +noinst_PROGRAMS+= tests/cycle tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) @@ -87,12 +78,14 @@ tests_testapp_LDADD= \ libhashkit/libhashkit.la \ libmemcached/libmemcachedinternal.la check_PROGRAMS+= tests/testapp +noinst_PROGRAMS+= tests/testapp tests_testplus_SOURCES= tests/plus.cpp tests_testplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_testplus_DEPENDENCIES= $(TESTS_LDADDS) tests_testplus_LDADD= $(tests_testplus_DEPENDENCIES) $(LIBSASL) check_PROGRAMS+= tests/testplus +noinst_PROGRAMS+= tests/testplus tests_atomsmasher_SOURCES= \ tests/atomsmasher.cc \ @@ -102,38 +95,43 @@ tests_atomsmasher_SOURCES= \ clients/execute.cc tests_atomsmasher_DEPENDENCIES= $(TESTS_LDADDS) tests_atomsmasher_LDADD= $(tests_atomsmasher_DEPENDENCIES) $(LIBSASL) +noinst_PROGRAMS+= tests/atomsmasher tests_testudp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) tests_testudp_SOURCES= tests/mem_udp.cc tests_testudp_DEPENDENCIES= $(TESTS_LDADDS) tests_testudp_LDADD= $(tests_testudp_DEPENDENCIES) $(LIBSASL) check_PROGRAMS+= tests/testudp +noinst_PROGRAMS+= tests/testudp tests_testhashkit_SOURCES = tests/hashkit_functions.cc tests_testhashkit_DEPENDENCIES = libtest/libtest.la libhashkit/libhashkit.la $(TESTS_LDADDS) tests_testhashkit_LDADD = $(tests_testhashkit_DEPENDENCIES) check_PROGRAMS+= tests/testhashkit +noinst_PROGRAMS+= tests/testhashkit tests_hash_plus_SOURCES= tests/hash_plus.cc tests_hash_plus_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) -tests_hash_plus_DEPENDENCIES= $(tests_testhashkit_DEPENDENCIES) $(TESTS_LDADDS) +tests_hash_plus_DEPENDENCIES= $(tests_testhashkit_DEPENDENCIES) tests_hash_plus_LDADD= $(tests_testhashkit_DEPENDENCIES) check_PROGRAMS+= tests/hash_plus +noinst_PROGRAMS+= tests/hash_plus + +tests_memcapable_SOURCES= tests/memcapable.cc +tests_memcapable_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) +tests_memcapable_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) +tests_memcapable_LDADD= $(tests_memcapable_DEPENDENCIES) +check_PROGRAMS+= tests/memcapable +noinst_PROGRAMS+= tests/memcapable test: check -check-local: tests/var $(TEST_DOCS) memcapable +check-local: tests/var $(TEST_DOCS) @echo "Tests completed" test-x: tests/var test-plus test-memcat test-memcp test-memrm test-memerror test-memdump test-memflush test-memstat @echo "Tests completed" -memcapable: clients/memcapable - @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555 - @clients/memcapable -p 12555 || echo "Your memcached server does not support all commands" - @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server" - @rm tests/Xumemc.pid - test-memcat: clients/memcat clients/memcp @echo "Testing memcat" @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555 @@ -259,6 +257,9 @@ test-hashplus: tests/var tests/hash_plus test-cycle: tests/var tests/cycle @tests/cycle +test-memcapable: tests/var tests/memcapable + @tests/memcapable + pahole-mem: tests/testapp @$(PAHOLE_COMMAND) tests/testapp @@ -307,7 +308,7 @@ valgrind-hash: tests/testhashkit valgrind-hashplus: tests/hash_plus @$(VALGRIND_COMMAND) tests/hash_plus -PHONY += valgrind +.PHONY += valgrind valgrind: valgrind-cycle valgrind-mem valgrind-udp valgrind-plus valgrind-hash valgrind-hashplus helgrind-cycle: tests/cycle @@ -334,14 +335,14 @@ helgrind-hashplus: tests/hash_plus .PHONY += helgrind helgrind: helgrind-cycle helgrind-mem helgrind-udp helgrind-plus helgrind-hash helgrind-hashplus -PHONY += cachegrind +.PHONY += cachegrind CLEANFILES += tests/cachegrind.out cachegrind: rm -f tests/cachegrind.out.* $(LIBTOOL) --mode=execute valgrind --tool=cachegrind --cachegrind-out-file=tests/cachegrind.out.%p --branch-sim=yes tests/testapp cg_annotate tests/cachegrind.out.* --auto=yes > tests/cachegrind.out -PHONY += callgrind +.PHONY += callgrind CLEANFILES += tests/callgrind.out callgrind: rm -f tests/callgrind.out.* diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index bf2f3ee0..9f0e48ec 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -456,8 +456,8 @@ static test_return_t error_test(memcached_st *memc) static test_return_t set_test(memcached_st *memc) { memcached_return_t rc= memcached_set(memc, - memcached_literal_param("foo"), - memcached_literal_param("when we sanitize"), + test_literal_param("foo"), + test_literal_param("when we sanitize"), time_t(0), (uint32_t)0); test_true_got(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); @@ -3441,6 +3441,11 @@ static test_return_t mget_read_result(memcached_st *memc) memcached_return_t rc; while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { + if (rc == MEMCACHED_IN_PROGRESS) + { + continue; + } + test_true(results); test_compare(MEMCACHED_SUCCESS, rc); } @@ -3629,7 +3634,7 @@ static test_return_t pre_nonblock_binary(memcached_st *memc) memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); - test_compare(1UL, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); + test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); } else { @@ -4396,7 +4401,7 @@ static test_return_t connection_pool_test(memcached_st *memc) test_compare(MEMCACHED_SUCCESS, memcached_set(mmc[0], key, keylen, "0", 1, 0, 0)); - for (size_t x= 0; x < POOL_SIZE; ++x) + for (uint64_t x= 0; x < POOL_SIZE; ++x) { uint64_t number_value; test_compare(MEMCACHED_SUCCESS, @@ -4951,7 +4956,7 @@ static test_return_t ketama_compatibility_libmemcached(memcached_st *) test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1)); - test_compare(1UL, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED)); + test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA)); test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, memcached_behavior_get_distribution(memc)); @@ -5818,7 +5823,7 @@ static test_return_t regression_bug_583031(memcached_st *) test_false(value); test_zero(length); - test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(memc, rc)); + test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_last_error_message(memc)); memcached_free(memc); diff --git a/tests/memcapable.cc b/tests/memcapable.cc new file mode 100644 index 00000000..f2e347dd --- /dev/null +++ b/tests/memcapable.cc @@ -0,0 +1,115 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Test memcapable + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* + Test that we are cycling the servers we are creating during testing. +*/ + +#include + +#include +#include + +using namespace libtest; + +#ifndef __INTEL_COMPILER +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif + +static std::string executable; + +static test_return_t help_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "-p %d", int(default_port())); + const char *args[]= { buffer, "--help", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t ascii_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "-p %d", int(default_port())); + const char *args[]= { buffer, " -a ", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t binary_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "-p %d", int(default_port())); + const char *args[]= { buffer, " -b ", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +test_st memcapable_tests[] ={ + {"--help", 0, help_test}, + {"-a, ascii", 0, ascii_test}, + {"-b, binary", 0, binary_test}, + {0, 0, 0} +}; + +collection_st collection[] ={ + {"memcapable", 0, 0, memcapable_tests }, + {0, 0, 0, 0} +}; + +static void *world_create(server_startup_st& servers, test_return_t& error) +{ + const char *argv[1]= { "memcapable" }; + if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv)) + { + error= TEST_FAILURE; + } + + return &servers; +} + + +void get_world(Framework *world) +{ + executable= "./clients/memcapable"; + world->collections= collection; + world->_create= world_create; +} + diff --git a/tests/namespace.cc b/tests/namespace.cc index 83c03165..57ecc606 100644 --- a/tests/namespace.cc +++ b/tests/namespace.cc @@ -58,13 +58,13 @@ test_return_t memcached_increment_namespace(memcached_st *memc) memcached_increment(memc, test_literal_param("number"), 1, &new_number)); - test_compare(1UL, new_number); + test_compare(uint64_t(1), new_number); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); - test_compare(2UL, new_number); + test_compare(uint64_t(2), new_number); memcached_st *clone= memcached_clone(NULL, memc); @@ -94,13 +94,13 @@ test_return_t memcached_increment_namespace(memcached_st *memc) memcached_increment(clone, test_literal_param("number"), 1, &new_number)); - test_compare(11UL, new_number); + test_compare(uint64_t(11), new_number); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); - test_compare(3UL, new_number); + test_compare(uint64_t(3), new_number); memcached_free(clone); diff --git a/tests/parser.cc b/tests/parser.cc index 598e2edd..b29a6fdc 100644 --- a/tests/parser.cc +++ b/tests/parser.cc @@ -374,8 +374,8 @@ test_return_t libmemcached_check_configuration_test(memcached_st*) memcached_return_t rc; char buffer[BUFSIZ]; - rc= libmemcached_check_configuration(test_literal_param("--server=localhost"), buffer, sizeof(buffer)); - test_true_got(rc == MEMCACHED_SUCCESS, buffer); + test_compare(MEMCACHED_SUCCESS, + libmemcached_check_configuration(test_literal_param("--server=localhost"), buffer, sizeof(buffer))); rc= libmemcached_check_configuration(test_literal_param("--dude=localhost"), buffer, sizeof(buffer)); test_false_with(rc == MEMCACHED_SUCCESS, buffer); @@ -403,9 +403,8 @@ test_return_t test_include_keyword(memcached_st*) return TEST_SKIPPED; char buffer[BUFSIZ]; - memcached_return_t rc; - rc= libmemcached_check_configuration(test_literal_param("INCLUDE \"support/example.cnf\""), buffer, sizeof(buffer)); - test_true_got(rc == MEMCACHED_SUCCESS, buffer); + test_compare(MEMCACHED_SUCCESS, + libmemcached_check_configuration(test_literal_param("INCLUDE \"support/example.cnf\""), buffer, sizeof(buffer))); return TEST_SUCCESS; } @@ -413,9 +412,8 @@ test_return_t test_include_keyword(memcached_st*) test_return_t test_end_keyword(memcached_st*) { char buffer[BUFSIZ]; - memcached_return_t rc; - rc= libmemcached_check_configuration(test_literal_param("--server=localhost END bad keywords"), buffer, sizeof(buffer)); - test_true_got(rc == MEMCACHED_SUCCESS, buffer); + test_compare(MEMCACHED_SUCCESS, + libmemcached_check_configuration(test_literal_param("--server=localhost END bad keywords"), buffer, sizeof(buffer))); return TEST_SUCCESS; } @@ -423,9 +421,8 @@ test_return_t test_end_keyword(memcached_st*) test_return_t test_reset_keyword(memcached_st*) { char buffer[BUFSIZ]; - memcached_return_t rc; - rc= libmemcached_check_configuration(test_literal_param("--server=localhost reset --server=bad.com"), buffer, sizeof(buffer)); - test_true_got(rc == MEMCACHED_SUCCESS, buffer); + test_compare(MEMCACHED_SUCCESS, + libmemcached_check_configuration(test_literal_param("--server=localhost reset --server=bad.com"), buffer, sizeof(buffer))); return TEST_SUCCESS; } @@ -620,17 +617,17 @@ test_return_t regression_bug_71231153_connect(memcached_st *) return TEST_SKIPPED; { // Test the connect-timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE - memcached_st *memc= memcached(memcached_literal_param("--SERVER=10.0.2.252 --CONNECT-TIMEOUT=0")); + memcached_st *memc= memcached(test_literal_param("--SERVER=10.0.2.252 --CONNECT-TIMEOUT=0")); test_true(memc); test_zero(memc->connect_timeout); test_compare(MEMCACHED_DEFAULT_TIMEOUT, memc->poll_timeout); memcached_return_t rc; size_t value_len; - char *value= memcached_get(memc, memcached_literal_param("test"), &value_len, NULL, &rc); + char *value= memcached_get(memc, test_literal_param("test"), &value_len, NULL, &rc); test_false(value); test_zero(value_len); - test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(NULL, rc)); + test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_last_error_message(memc)); memcached_free(memc); } @@ -644,17 +641,17 @@ test_return_t regression_bug_71231153_poll(memcached_st *) return TEST_SKIPPED; { // Test the poll timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE - memcached_st *memc= memcached(memcached_literal_param("--SERVER=10.0.2.252 --POLL-TIMEOUT=0")); + memcached_st *memc= memcached(test_literal_param("--SERVER=10.0.2.252 --POLL-TIMEOUT=0")); test_true(memc); test_compare(MEMCACHED_DEFAULT_CONNECT_TIMEOUT, memc->connect_timeout); test_zero(memc->poll_timeout); memcached_return_t rc; size_t value_len; - char *value= memcached_get(memc, memcached_literal_param("test"), &value_len, NULL, &rc); + char *value= memcached_get(memc, test_literal_param("test"), &value_len, NULL, &rc); test_false(value); test_zero(value_len); - test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(NULL, rc)); + test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_last_error_message(memc)); memcached_free(memc); } diff --git a/tests/plus.cpp b/tests/plus.cpp index 90f7a0da..aed34a49 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -128,13 +128,13 @@ test_return_t increment_test(memcached_st *original) test_compare(int_inc_value, int_ret_value); test_true(mcach.increment(key, 1, &int_ret_value)); - test_compare(2UL, int_ret_value); + test_compare(uint64_t(2), int_ret_value); test_true(mcach.increment(key, 1, &int_ret_value)); - test_compare(3UL, int_ret_value); + test_compare(uint64_t(3), int_ret_value); test_true(mcach.increment(key, 5, &int_ret_value)); - test_compare(8UL, int_ret_value); + test_compare(uint64_t(8), int_ret_value); return TEST_SUCCESS; } diff --git a/tests/replication.cc b/tests/replication.cc index 1c210b08..033b4322 100644 --- a/tests/replication.cc +++ b/tests/replication.cc @@ -249,10 +249,10 @@ test_return_t replication_delete_test(memcached_st *memc_just_cloned) // Make one copy test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_replicated, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 1UL)); - test_compare(1UL, memcached_behavior_get(memc_replicated, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS)); + test_compare(uint64_t(1), memcached_behavior_get(memc_replicated, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_not_replicate, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0UL)); - test_compare(0UL, memcached_behavior_get(memc_not_replicate, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS)); + test_compare(uint64_t(0), memcached_behavior_get(memc_not_replicate, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS)); for (size_t x= 0; x < test_array_length(keys); ++x) { -- 2.30.2