1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/Server.hpp"
4 #include "test/lib/ReturnMatcher.hpp"
6 using Catch::Matchers::Contains
;
8 TEST_CASE("bin/memping") {
9 Shell sh
{string
{TESTING_ROOT
"/../src/bin"}};
11 SECTION("no servers provided") {
13 REQUIRE_FALSE(sh
.run("memping", output
));
14 REQUIRE(output
== "No Servers provided\n");
19 REQUIRE(sh
.run("memping --help", output
));
20 REQUIRE_THAT(output
, Contains("memping"));
21 REQUIRE_THAT(output
, Contains("v1"));
22 REQUIRE_THAT(output
, Contains("help"));
23 REQUIRE_THAT(output
, Contains("version"));
24 REQUIRE_THAT(output
, Contains("option"));
25 REQUIRE_THAT(output
, Contains("--"));
26 REQUIRE_THAT(output
, Contains("="));
29 SECTION("with server") {
30 Server server
{MEMCACHED_BINARY
, {"-p", random_port_string
}};
32 LoneReturnMatcher test
{*memc
};
34 REQUIRE(server
.ensureListening());
35 auto port
= get
<int>(server
.getSocketOrPort());
36 auto comm
= "memping --servers=localhost:" + to_string(port
) + " ";
38 REQUIRE_SUCCESS(memcached_server_add(*memc
, "localhost", port
));
42 REQUIRE(sh
.run(comm
, output
));
43 REQUIRE(output
.empty());
46 SECTION("connection failure") {
47 server
.signal(SIGKILL
);
51 REQUIRE_FALSE(sh
.run(comm
, output
));
53 Contains("CONNECTION FAILURE")
54 || Contains("SERVER HAS FAILED")
55 || Contains("SYSTEM ERROR")
56 || Contains("TIMEOUT OCCURRED"));