From: Michael Wallner Date: Tue, 10 Nov 2020 09:59:16 +0000 (+0100) Subject: testing: more memcp options X-Git-Tag: 1.1.0-beta1~120 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2899ca181d15b8606c3317f3204e7186846e93cf;p=m6w6%2Flibmemcached testing: more memcp options --- diff --git a/src/bin/memcp.cc b/src/bin/memcp.cc index 8ab28928..632cea30 100644 --- a/src/bin/memcp.cc +++ b/src/bin/memcp.cc @@ -232,7 +232,7 @@ int main(int argc, char *argv[]) { } if (memcached_failed(rc)) { - std::cerr << "Error occrrured during memcached_set(): " << memcached_last_error_message(memc) + std::cerr << "Error occurred during memcached_set(): " << memcached_last_error_message(memc) << std::endl; exit_code = EXIT_FAILURE; } diff --git a/test/tests/bin/memcp.cpp b/test/tests/bin/memcp.cpp index 83fe9749..fc61e57f 100644 --- a/test/tests/bin/memcp.cpp +++ b/test/tests/bin/memcp.cpp @@ -28,7 +28,7 @@ TEST_CASE("bin/memcp") { } SECTION("with server") { - Server server{MEMCACHED_BINARY, {"-p", random_port_string}}; + Server server{MEMCACHED_BINARY, {"-U", random_port_string}}; MemcachedPtr memc; LoneReturnMatcher test{*memc}; @@ -39,20 +39,52 @@ TEST_CASE("bin/memcp") { REQUIRE_SUCCESS(memcached_server_add(*memc, "localhost", port)); SECTION("okay") { - Tempfile temp; - temp.put(S("123")); + auto udp_buffer = GENERATE(0,1,2); + auto binary = GENERATE(0,1); + auto set_add_replace = GENERATE(0,1,2); + auto expire = GENERATE(0, random_num(10,12345)); + string set_add_replace_s[3] = { + "set", "add", "replace" + }; - string output; - REQUIRE(sh.run(comm + temp.getFn(), output)); - REQUIRE(output == ""); + DYNAMIC_SECTION("udp=" << (udp_buffer==1) <<" buffer=" << (udp_buffer==2) << " binary=" << binary << " mode=" << set_add_replace_s[set_add_replace] << " expire=" << expire) { + Tempfile temp; + temp.put(S("123")); + + if (udp_buffer == 1) { + comm += " --udp "; + } else if (udp_buffer == 2) { + comm += " --buffer "; + } + if(binary) { + comm += " --binary "; + } + if (expire) { + comm += " --expire " + to_string(expire) + " "; + } + switch (set_add_replace) { + case 2: + comm += " --replace "; + REQUIRE_SUCCESS(memcached_set(*memc, S(temp.getFn()), S("foo"), 0, 0)); + break; + case 1: + comm += " --add "; + } + + INFO(comm); + string output; + auto ok = sh.run(comm + temp.getFn(), output); + REQUIRE(output == ""); + REQUIRE(ok); - size_t len; - memcached_return_t rc; - Malloced val(memcached_get(*memc, S(temp.getFn()), &len, nullptr, &rc)); + size_t len; + memcached_return_t rc; + Malloced val(memcached_get(*memc, S(temp.getFn()), &len, nullptr, &rc)); - REQUIRE(*val); - REQUIRE_SUCCESS(rc); - REQUIRE(string(*val, len) == "123"); + REQUIRE(*val); + REQUIRE_SUCCESS(rc); + REQUIRE(string(*val, len) == "123"); + } } SECTION("connection failure") {