From c4150c3ae1ba9fa96fc42ad32c972d599e88e9bd Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 2 Mar 2023 12:28:20 +0100 Subject: [PATCH] tests: add test for php-memcached-dev/php-memcached#531 --- .../regression/gh-php-memcached_0531.cpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/tests/memcached/regression/gh-php-memcached_0531.cpp diff --git a/test/tests/memcached/regression/gh-php-memcached_0531.cpp b/test/tests/memcached/regression/gh-php-memcached_0531.cpp new file mode 100644 index 00000000..227a1507 --- /dev/null +++ b/test/tests/memcached/regression/gh-php-memcached_0531.cpp @@ -0,0 +1,29 @@ +#include "test/lib/common.hpp" +#include "test/lib/MemcachedCluster.hpp" + +TEST_CASE("memcached_regression_gh-php-memcached_0531") { + auto test = MemcachedCluster{Cluster{Server{MEMCACHED_BINARY, {"-p", random_socket_or_port_string("-p")}}, 1}}; + auto memc = &test.memc; + auto nonblock = GENERATE(0, 1); + + INFO("nonblock=" << nonblock); + + REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, nonblock)); + + REQUIRE_SUCCESS(memcached_set(memc, S("first"), S("first"), 0, 0)); + REQUIRE_SUCCESS(memcached_set(memc, S("second"), S("second"), 0, 0)); + + REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, 0)); + + memcached_return_t rc; + size_t len; + Malloced value1(memcached_get(memc, S("first"), &len, nullptr, &rc)); + REQUIRE_RC(MEMCACHED_TIMEOUT, rc); + REQUIRE_FALSE(*value1); + + REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, 100)); + + Malloced value2(memcached_get(memc, S("second"), &len, nullptr, &rc)); + REQUIRE_SUCCESS(rc); + REQUIRE(string(*value2) == string("second")); +} -- 2.30.2