From 04e4d81e039c4aa1f048782c13a6771e8aa2172c Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 6 Aug 2013 06:04:31 -0400 Subject: [PATCH] Fix tests (namely the "s" for CLI options). --- tests/memcat.cc | 12 +++++++----- tests/memdump.cc | 5 +++-- tests/memexist.cc | 16 ++++++++-------- tests/memping.cc | 4 ++-- tests/memrm.cc | 4 +++- tests/memtouch.cc | 14 +++++++------- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/tests/memcat.cc b/tests/memcat.cc index 2910e4b9..3b3b021f 100644 --- a/tests/memcat.cc +++ b/tests/memcat.cc @@ -64,10 +64,10 @@ static test_return_t help_test(void *) static test_return_t cat_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; - memcached_st *memc= memcached(buffer, strlen(buffer)); + memcached_st *memc= memcached(buffer, length); test_true(memc); test_compare(MEMCACHED_SUCCESS, @@ -77,6 +77,7 @@ static test_return_t cat_test(void *) test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); @@ -90,11 +91,11 @@ static test_return_t cat_test(void *) static test_return_t NOT_FOUND_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; - memcached_st *memc= memcached(buffer, strlen(buffer)); - test_true(memc); + memcached_st *memc= memcached(buffer, length); + ASSERT_TRUE(memc); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); @@ -102,6 +103,7 @@ static test_return_t NOT_FOUND_test(void *) test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); diff --git a/tests/memdump.cc b/tests/memdump.cc index a43a6124..2a502371 100644 --- a/tests/memdump.cc +++ b/tests/memdump.cc @@ -75,10 +75,10 @@ static test_return_t server_test(void *) static test_return_t FOUND_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, 0 }; - memcached_st *memc= memcached(buffer, strlen(buffer)); + memcached_st *memc= memcached(buffer, length); test_true(memc); test_compare(MEMCACHED_SUCCESS, @@ -91,6 +91,7 @@ static test_return_t FOUND_test(void *) test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); + length= snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE); memcached_free(memc); diff --git a/tests/memexist.cc b/tests/memexist.cc index 0c57c029..41a4648d 100644 --- a/tests/memexist.cc +++ b/tests/memexist.cc @@ -64,10 +64,10 @@ static test_return_t help_test(void *) static test_return_t exist_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; - memcached_st *memc= memcached(buffer, strlen(buffer)); + memcached_st *memc= memcached(buffer, length); test_true(memc); test_compare(MEMCACHED_SUCCESS, @@ -90,11 +90,11 @@ static test_return_t exist_test(void *) static test_return_t NOT_FOUND_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; - memcached_st *memc= memcached(buffer, strlen(buffer)); - test_true(memc); + memcached_st *memc= memcached(buffer, length); + ASSERT_TRUE(memc); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); @@ -115,9 +115,9 @@ static test_return_t NOT_FOUND_test(void *) 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); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + memcached_st *memc= memcached(buffer, length); + ASSERT_TRUE(memc); test_return_t result= TEST_SUCCESS; if (libmemcached_util_version_check(memc, 1, 4, 8) == false) diff --git a/tests/memping.cc b/tests/memping.cc index 543efc7c..af057def 100644 --- a/tests/memping.cc +++ b/tests/memping.cc @@ -64,7 +64,7 @@ static test_return_t help_test(void *) static test_return_t ping_TEST(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); @@ -75,7 +75,7 @@ static test_return_t ping_TEST(void *) static test_return_t NOT_FOUND_TEST(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=nonexist.libmemcached.org:%d", int(default_port())); + snprintf(buffer, sizeof(buffer), "--servers=nonexist.libmemcached.org:%d", int(default_port())); const char *args[]= { buffer, 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); diff --git a/tests/memrm.cc b/tests/memrm.cc index 043e0ce5..6955f1fa 100644 --- a/tests/memrm.cc +++ b/tests/memrm.cc @@ -84,6 +84,8 @@ static test_return_t rm_test(void *) test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); + char memrm_buffer[1024]; + snprintf(memrm_buffer, sizeof(memrm_buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); @@ -121,7 +123,7 @@ static test_return_t NOT_FOUND_TEST(void *) static test_return_t multiple_NOT_FOUND_TEST(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, "protocols", "foo", "mine", "bar", "dog", "cat", "foo", "mine", "eye", "for", "the", "to", "not", "know", "what", "I", "should", "be", "doing", 0 }; diff --git a/tests/memtouch.cc b/tests/memtouch.cc index 5617fa28..761a7072 100644 --- a/tests/memtouch.cc +++ b/tests/memtouch.cc @@ -65,9 +65,9 @@ static test_return_t help_test(void *) static test_return_t touch_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); - memcached_st *memc= memcached(buffer, strlen(buffer)); + memcached_st *memc= memcached(buffer, length); test_true(memc); test_compare(MEMCACHED_SUCCESS, @@ -89,15 +89,15 @@ 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)); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + memcached_st *memc= memcached(buffer, length); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo"))); - snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + length= snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { "--expire=30", buffer, "foo", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); @@ -111,8 +111,8 @@ static test_return_t NOT_FOUND_test(void *) 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)); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + memcached_st *memc= memcached(buffer, length); test_true(memc); test_return_t result= TEST_SUCCESS; -- 2.30.2