From: Brian Aker Date: Tue, 28 Feb 2012 05:36:11 +0000 (-0800) Subject: Fix exist and touch to just run if the server supports them. X-Git-Tag: 1.0.5~19 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=91d6a7efc71376a7fffee6ed1dd2ce3f6feaa2bb;p=m6w6%2Flibmemcached Fix exist and touch to just run if the server supports them. --- diff --git a/tests/cli.am b/tests/cli.am index 32b87981..b42d394f 100644 --- a/tests/cli.am +++ b/tests/cli.am @@ -92,8 +92,11 @@ test-memstat: tests/memstat test-memerror: tests/memerror tests/memerror +test-memtouch: tests/memtouch + tests/memtouch + valgrind-memerror: tests/memerror @$(VALGRIND_COMMAND) tests/memerror valgrind-memtouch: tests/memtouch - @$(VALGRIND_COMMAND) tests/memerror + @$(VALGRIND_COMMAND) tests/memtouch diff --git a/tests/memexist.cc b/tests/memexist.cc index a0fec9e0..29ad5091 100644 --- a/tests/memexist.cc +++ b/tests/memexist.cc @@ -43,6 +43,7 @@ #include #include +#include using namespace libtest; @@ -111,6 +112,23 @@ static test_return_t NOT_FOUND_test(void *) return TEST_SUCCESS; } +static test_return_t check_version(void*) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + memcached_st *memc= memcached(buffer, strlen(buffer)); + test_true(memc); + + test_return_t result= TEST_SUCCESS; + if (libmemcached_util_version_check(memc, 1, 4, 8) == false) + { + result= TEST_SKIPPED; + } + memcached_free(memc); + + return result; +} + test_st memexist_tests[] ={ {"--help", true, help_test }, {"exist(FOUND)", true, exist_test }, @@ -119,7 +137,7 @@ test_st memexist_tests[] ={ }; collection_st collection[] ={ - {"memexist", 0, 0, memexist_tests }, + {"memexist", check_version, 0, memexist_tests }, {0, 0, 0, 0} }; diff --git a/tests/memtouch.cc b/tests/memtouch.cc index df597e0f..fa65e8b4 100644 --- a/tests/memtouch.cc +++ b/tests/memtouch.cc @@ -43,6 +43,7 @@ #include #include +#include using namespace libtest; @@ -88,7 +89,6 @@ static test_return_t touch_test(void *) static test_return_t NOT_FOUND_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); @@ -108,6 +108,23 @@ static test_return_t NOT_FOUND_test(void *) return TEST_SUCCESS; } +static test_return_t check_version(void*) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + memcached_st *memc= memcached(buffer, strlen(buffer)); + test_true(memc); + + test_return_t result= TEST_SUCCESS; + if (libmemcached_util_version_check(memc, 1, 4, 8) == false) + { + result= TEST_SKIPPED; + } + memcached_free(memc); + + return result; +} + test_st memtouch_tests[] ={ {"--help", true, help_test }, {"touch(FOUND)", true, touch_test }, @@ -116,7 +133,7 @@ test_st memtouch_tests[] ={ }; collection_st collection[] ={ - {"memtouch", 0, 0, memtouch_tests }, + {"memtouch", check_version, 0, memtouch_tests }, {0, 0, 0, 0} };