configure_file(conf.h.in conf.h @ONLY)
add_executable(catch_main ${TESTING_SRC})
set_target_properties(catch_main PROPERTIES CXX_STANDARD 17)
-target_link_libraries(catch_main libhashkit libmemcached libmemcachedutil)
+target_include_directories(catch_main PRIVATE
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/src
+ ${CMAKE_BINARY_DIR}/src)
+target_link_libraries(catch_main PRIVATE libhashkit libmemcached libmemcachedutil)
add_dependencies(catch_main ${CLIENTS})
+
+add_test("lib/Server" catch_main "lib/Server")
+add_test("lib/Cluster" catch_main "lib/Cluster")
+
+add_test("hashkit" catch_main "hashkit")
+
+add_test("memcached_append" catch_main "memcached_append")
+add_test("memcached_basic" catch_main "memcached_basic")
+add_test("memcached_callbacks" catch_main "memcached_callbacks")
+add_test("memcached_cas" catch_main "memcached_cas")
+add_test("memcached_dump" catch_main "memcached_dump")
+add_test("memcached_encoding_key" catch_main "memcached_encoding_key")
+add_test("memcached_exist" catch_main "memcached_exist")
+add_test("memcached_generate_hash" catch_main "memcached_generate_hash")
+add_test("memcached_haldenbrand_nblock_tcp_ndelay" catch_main "memcached_haldenbrand_nblock_tcp_ndelay")
+add_test("memcached_inc_dec" catch_main "memcached_inc_dec")
+add_test("memcached_ketama_compat" catch_main "memcached_ketama_compat")
+add_test("memcached_noreply" catch_main "memcached_noreply")
+add_test("memcached_prepend" catch_main "memcached_prepend")
+add_test("memcached_regression_binary_block_add" catch_main "memcached_regression_binary_block_add")
+add_test("memcached_servers" catch_main "memcached_servers")
+add_test("memcached_simple" catch_main "memcached_simple")
+add_test("memcached_util" catch_main "memcached_util")
+
+add_test("memcat" catch_main "memcat")
+add_test("memcp" catch_main "memcp")
+add_test("memdump" catch_main "memdump")
+add_test("memerror" catch_main "memerror")
+add_test("memexist" catch_main "memexist")
REQUIRE_SUCCESS(memcached_set(*memc, S("key1"), S("val1"), 0, 0));
REQUIRE_SUCCESS(memcached_set(*memc, S("key2"), S("val2"), 0, 0));
+ this_thread::sleep_for(500ms);
+
string output;
REQUIRE(sh.run(comm, output));
REQUIRE_THAT(output, Contains("key1") && Contains("key2"));
DECLARE_STREQUAL;
-TEST_CASE("memcached append") {
+TEST_CASE("memcached_append") {
pair<string, MemcachedCluster> tests[] = {
{"bin_mixed", MemcachedCluster::mixed()},
{"mixed", MemcachedCluster::mixed()}
#include "libmemcached/is.h"
-TEST_CASE("memcached basic") {
+TEST_CASE("memcached_basic") {
SECTION("library") {
REQUIRE(string(LIBMEMCACHED_VERSION_STRING) == memcached_lib_version());
}
return MEMCACHED_SUCCESS;
}
-TEST_CASE("memcached callbacks") {
+TEST_CASE("memcached_callbacks") {
auto test{MemcachedCluster::mixed()};
auto memc = &test.memc;
memcached_return_t rc;
#include "testing/lib/common.hpp"
#include "testing/lib/MemcachedCluster.hpp"
-TEST_CASE("memcached cas") {
+TEST_CASE("memcached_cas") {
pair<string, MemcachedCluster> tests[] = {
{"network", MemcachedCluster::network()},
{"socket", MemcachedCluster::socket()}
return MEMCACHED_SUCCESS;
}
-TEST_CASE("memcached dump") {
+TEST_CASE("memcached_dump") {
pair<string, MemcachedCluster> tests[]{
{"mixed", MemcachedCluster::mixed()},
{"network", MemcachedCluster::network()},
REQUIRE_FALSE(memcmp(val, *enc_value, enc_length));
}
-TEST_CASE("memcached encoding_key") {
+TEST_CASE("memcached_encoding_key") {
pair<string, MemcachedCluster> tests[]{
{"network", MemcachedCluster::network()},
{"socket", MemcachedCluster::socket()}
#include "testing/lib/common.hpp"
#include "testing/lib/MemcachedCluster.hpp"
-TEST_CASE("memcached exist") {
+TEST_CASE("memcached_exist") {
pair<string, MemcachedCluster> tests[]{
{"bin_mixed", MemcachedCluster::mixed()},
{"network", MemcachedCluster::network()},
static constexpr const uint32_t crc_hosts[] = {2U, 4U, 1U, 0U, 2U, 4U, 4U, 4U, 1U, 2U, 3U, 4U, 3U, 4U, 1U, 3U, 3U, 2U, 0U, 0U, 0U, 1U, 2U, 4U, 0U};
static constexpr const uint32_t *hosts[] = {nullptr, md5_hosts, crc_hosts};
-TEST_CASE("memcached generate_hash") {
+TEST_CASE("memcached_generate_hash") {
MemcachedPtr memc(memcached(S("--server=localhost:1 --server=localhost:2 --server=localhost:3 --server=localhost:4 --server=localhost5 --DISTRIBUTION=modula")));
REQUIRE(*memc);
#include <cstdlib>
-TEST_CASE("memcached haldenbrand nblock_tcp_ndelay") {
+TEST_CASE("memcached_haldenbrand_nblock_tcp_ndelay") {
pair<string, MemcachedCluster> tests[] = {
{"network", MemcachedCluster::network()},
};
#include "testing/lib/common.hpp"
#include "testing/lib/MemcachedCluster.hpp"
-TEST_CASE("memcached inc_dec") {
+TEST_CASE("memcached_inc_dec") {
pair<string, MemcachedCluster> tests[] = {
{"mixed", MemcachedCluster::mixed()},
};
DECLARE_STREQUAL;
-TEST_CASE("memcached ketama_compat") {
+TEST_CASE("memcached_ketama_compat") {
auto test = MemcachedCluster::network();
auto memc = &test.memc;
constexpr static const int keys = 5000;
-TEST_CASE("memcached noreply") {
+TEST_CASE("memcached_noreply") {
auto test{MemcachedCluster::mixed()};
auto memc = &test.memc;
#include "testing/lib/common.hpp"
#include "testing/lib/MemcachedCluster.hpp"
-TEST_CASE("memcached prepend") {
+TEST_CASE("memcached_prepend") {
pair<string, MemcachedCluster> tests[] = {
{"network", MemcachedCluster::network()},
{"socket", MemcachedCluster::socket()}
#include "testing/lib/common.hpp"
#include "testing/lib/MemcachedCluster.hpp"
-TEST_CASE("memcached regression binary_block_add") {
+TEST_CASE("memcached_regression_binary_block_add") {
auto test = MemcachedCluster::network();
auto memc = &test.memc;
auto blob = random_ascii_string(1024);
return MEMCACHED_SUCCESS;
}
-TEST_CASE("memcached servers") {
+TEST_CASE("memcached_servers") {
SECTION("memcached_servers_parse") {
SECTION("does not leak memory") {
memcached_server_st *s = memcached_servers_parse("1.2.3.4:1234");
#include "testing/lib/common.hpp"
#include "testing/lib/MemcachedCluster.hpp"
-TEST_CASE("memcached simple") {
+TEST_CASE("memcached_simple") {
pair<string, MemcachedCluster> tests[] = {
{"network", MemcachedCluster::network()},
{"socket", MemcachedCluster::socket()}
return MEMCACHED_SUCCESS;
}
-TEST_CASE("memcached util") {
+TEST_CASE("memcached_util") {
SECTION("version_check") {
auto test = MemcachedCluster::mixed();
auto memc = &test.memc;
REQUIRE_SUCCESS(memcached_server_cursor(memc, fptr, nullptr, 1));
}
+
+ SECTION("flush") {
+ auto test = MemcachedCluster::network();
+
+ for (auto &server : test.cluster.getServers()) {
+ memcached_return_t rc;
+ REQUIRE(libmemcached_util_flush("localhost", get<int>(server.getSocketOrPort()), &rc));
+ REQUIRE_SUCCESS(rc);
+ }
+ }
}