1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/Server.hpp"
5 using Catch::Matchers::Contains
;
7 TEST_CASE("bin/memcapable") {
8 Shell sh
{string
{TESTING_ROOT
"/../src/bin"}};
10 SECTION("no servers provided") {
12 REQUIRE_FALSE(sh
.run("memcapable", output
));
13 REQUIRE(output
== "No hostname was provided.\n");
19 REQUIRE(sh
.run("memcapable --help", output
));
20 REQUIRE_THAT(output
, Contains("memcapable") && Contains("binary") && Contains("ascii"));
23 SECTION("with server") {
24 Server server
{MEMCACHED_BINARY
, {"-p", random_port_string
}};
26 REQUIRE(server
.ensureListening());
28 SECTION("ascii only") {
30 REQUIRE(sh
.run("memcapable -a -h localhost -p " + to_string(get
<int>(server
.getSocketOrPort())), output
));
31 REQUIRE_THAT(output
, Contains("pass") && Contains("ascii"));
32 REQUIRE_THAT(output
, !Contains("fail") && !Contains("binary"));
34 SECTION("binary only") {
36 REQUIRE(sh
.run("memcapable -b -h localhost -p " + to_string(get
<int>(server
.getSocketOrPort())), output
));
37 REQUIRE_THAT(output
, Contains("pass") && Contains("binary"));
38 REQUIRE_THAT(output
, !Contains("fail") && !Contains("ascii"));
40 SECTION("ascii and binary") {
42 REQUIRE(sh
.run("memcapable -h localhost -p " + to_string(get
<int>(server
.getSocketOrPort())), output
));
43 REQUIRE_THAT(output
, Contains("pass") && Contains("ascii") && Contains("binary"));
44 REQUIRE_THAT(output
, !Contains("fail"));
48 server
.signal(SIGKILL
);