ctrl_dhcp6_srv_unittest.cc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. // Copyright (C) 2012-2013, 2015 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <config.h>
  15. #include <cc/command_interpreter.h>
  16. #include <config/command_mgr.h>
  17. #include <dhcpsrv/cfgmgr.h>
  18. #include <dhcp6/ctrl_dhcp6_srv.h>
  19. #include <hooks/hooks_manager.h>
  20. #include "marker_file.h"
  21. #include "test_libraries.h"
  22. #include <boost/scoped_ptr.hpp>
  23. #include <gtest/gtest.h>
  24. #include <sys/select.h>
  25. #include <sys/ioctl.h>
  26. #include <cstdlib>
  27. using namespace std;
  28. using namespace isc::config;
  29. using namespace isc::data;
  30. using namespace isc::dhcp;
  31. using namespace isc::dhcp::test;
  32. using namespace isc::hooks;
  33. namespace {
  34. /// Class that acts as a UnixCommandSocket client
  35. /// It can connect to an open UnixCommandSocket and exchange ControlChannel
  36. /// commands and responses.
  37. class UnixControlClient {
  38. public:
  39. UnixControlClient() {
  40. socket_fd_ = -1;
  41. }
  42. ~UnixControlClient() {
  43. disconnectFromServer();
  44. }
  45. /// @brief Closes the Control Channel socket
  46. void disconnectFromServer() {
  47. if (socket_fd_ >= 0) {
  48. static_cast<void>(close(socket_fd_));
  49. socket_fd_ = -1;
  50. }
  51. }
  52. /// @brief Connects to a Unix socket at the given path
  53. /// @param socket_path pathname of the socket to open
  54. /// @return true if the connect was successful, false otherwise
  55. bool connectToServer(const std::string& socket_path) {
  56. // Create UNIX socket
  57. socket_fd_ = socket(AF_UNIX, SOCK_STREAM, 0);
  58. if (socket_fd_ < 0) {
  59. const char* errmsg = strerror(errno);
  60. ADD_FAILURE() << "Failed to open unix stream socket: " << errmsg;
  61. return (false);
  62. }
  63. struct sockaddr_un srv_addr;
  64. if (socket_path.size() > sizeof(srv_addr.sun_path) - 1) {
  65. ADD_FAILURE() << "Socket path specified (" << socket_path
  66. << ") is larger than " << (sizeof(srv_addr.sun_path) - 1)
  67. << " allowed.";
  68. disconnectFromServer();
  69. return (false);
  70. }
  71. // Prepare socket address
  72. memset(&srv_addr, 0, sizeof(srv_addr));
  73. srv_addr.sun_family = AF_UNIX;
  74. strncpy(srv_addr.sun_path, socket_path.c_str(),
  75. sizeof(srv_addr.sun_path));
  76. socklen_t len = sizeof(srv_addr);
  77. // Connect to the specified UNIX socket
  78. int status = connect(socket_fd_, (struct sockaddr*)&srv_addr, len);
  79. if (status == -1) {
  80. const char* errmsg = strerror(errno);
  81. ADD_FAILURE() << "Failed to connect unix socket: fd=" << socket_fd_
  82. << ", path=" << socket_path << " : " << errmsg;
  83. disconnectFromServer();
  84. return (false);
  85. }
  86. return (true);
  87. }
  88. /// @brief Sends the given command across the open Control Channel
  89. /// @param command the command text to execute in JSON form
  90. /// @return true if the send succeeds, false otherwise
  91. bool sendCommand(const std::string& command) {
  92. // Send command
  93. int bytes_sent = send(socket_fd_, command.c_str(), command.length(), 0);
  94. if (bytes_sent < command.length()) {
  95. const char* errmsg = strerror(errno);
  96. ADD_FAILURE() << "Failed to send " << command.length()
  97. << " bytes, send() returned " << bytes_sent
  98. << " : " << errmsg;
  99. return (false);
  100. }
  101. return (true);
  102. }
  103. /// @brief Reads the response text from the open Control Channel
  104. /// @param response variable into which the received response should be
  105. /// placed.
  106. /// @return true if data was successfully read from the socket,
  107. /// false otherwise
  108. bool getResponse(std::string& response) {
  109. // Receive response
  110. // @todo implement select check to see if data is waiting
  111. char buf[65536];
  112. memset(buf, 0, sizeof(buf));
  113. switch (selectCheck()) {
  114. case -1: {
  115. const char* errmsg = strerror(errno);
  116. ADD_FAILURE() << "getResponse - select failed: " << errmsg;
  117. return (false);
  118. }
  119. case 0:
  120. ADD_FAILURE() << "No response data sent";
  121. return (false);
  122. default:
  123. break;
  124. }
  125. int bytes_rcvd = recv(socket_fd_, buf, sizeof(buf), 0);
  126. if (bytes_rcvd < 0) {
  127. const char* errmsg = strerror(errno);
  128. ADD_FAILURE() << "Failed to receive a response. recv() returned "
  129. << bytes_rcvd << " : " << errmsg;
  130. return (false);
  131. }
  132. if (bytes_rcvd >= sizeof(buf)) {
  133. ADD_FAILURE() << "Response size too large: " << bytes_rcvd;
  134. return (false);
  135. }
  136. // Convert the response to a string
  137. response = string(buf, bytes_rcvd);
  138. return (true);
  139. }
  140. /// @brief Uses select to poll the Control Channel for data waiting
  141. /// @return -1 on error, 0 if no data is available, 1 if data is ready
  142. int selectCheck() {
  143. int maxfd = 0;
  144. fd_set read_fds;
  145. FD_ZERO(&read_fds);
  146. // Add this socket to listening set
  147. FD_SET(socket_fd_, &read_fds);
  148. maxfd = socket_fd_;
  149. struct timeval select_timeout;
  150. select_timeout.tv_sec = 0;
  151. select_timeout.tv_usec = 0;
  152. return (select(maxfd + 1, &read_fds, NULL, NULL, &select_timeout));
  153. }
  154. /// @brief Retains the fd of the open socket
  155. int socket_fd_;
  156. };
  157. class NakedControlledDhcpv6Srv: public ControlledDhcpv6Srv {
  158. // "Naked" DHCPv6 server, exposes internal fields
  159. public:
  160. NakedControlledDhcpv6Srv():ControlledDhcpv6Srv(DHCP6_SERVER_PORT + 10000) {
  161. }
  162. /// @brief Exposes server's receivePacket method
  163. virtual Pkt6Ptr receivePacket(int timeout) {
  164. return(Dhcpv6Srv::receivePacket(timeout));
  165. }
  166. };
  167. class CtrlDhcpv6SrvTest : public ::testing::Test {
  168. public:
  169. CtrlDhcpv6SrvTest() {
  170. reset();
  171. }
  172. virtual ~CtrlDhcpv6SrvTest() {
  173. reset();
  174. };
  175. /// @brief Reset hooks data
  176. ///
  177. /// Resets the data for the hooks-related portion of the test by ensuring
  178. /// that no libraries are loaded and that any marker files are deleted.
  179. virtual void reset() {
  180. // Unload any previously-loaded libraries.
  181. HooksManager::unloadLibraries();
  182. // Get rid of any marker files.
  183. static_cast<void>(remove(LOAD_MARKER_FILE));
  184. static_cast<void>(remove(UNLOAD_MARKER_FILE));
  185. IfaceMgr::instance().deleteAllExternalSockets();
  186. CfgMgr::instance().clear();
  187. }
  188. };
  189. class CtrlChannelDhcpv6SrvTest : public CtrlDhcpv6SrvTest {
  190. public:
  191. std::string socket_path_;
  192. boost::shared_ptr<NakedControlledDhcpv6Srv> server_;
  193. CtrlChannelDhcpv6SrvTest() {
  194. const char* env = getenv("KEA_SOCKET_TEST_DIR");
  195. if (env) {
  196. socket_path_ = string(env) + "/kea6.sock";
  197. } else {
  198. socket_path_ = string(TEST_DATA_BUILDDIR) + "/kea6.sock";
  199. }
  200. reset();
  201. }
  202. ~CtrlChannelDhcpv6SrvTest() {
  203. server_.reset();
  204. reset();
  205. };
  206. void createUnixChannelServer() {
  207. static_cast<void>(::remove(socket_path_.c_str()));
  208. // Just a simple config. The important part here is the socket
  209. // location information.
  210. std::string header =
  211. "{"
  212. " \"interfaces-config\": {"
  213. " \"interfaces\": [ \"*\" ]"
  214. " },"
  215. " \"rebind-timer\": 2000, "
  216. " \"renew-timer\": 1000, "
  217. " \"subnet6\": [ ],"
  218. " \"valid-lifetime\": 4000,"
  219. " \"control-socket\": {"
  220. " \"socket-type\": \"unix\","
  221. " \"socket-name\": \"";
  222. std::string footer =
  223. "\" },"
  224. " \"lease-database\": {"
  225. " \"type\": \"memfile\", \"persist\": false }"
  226. "}";
  227. // Fill in the socket-name value with socket_path_ to
  228. // make the actual configuration text.
  229. std::string config_txt = header + socket_path_ + footer;
  230. ASSERT_NO_THROW(server_.reset(new NakedControlledDhcpv6Srv()));
  231. ConstElementPtr config = Element::fromJSON(config_txt);
  232. ConstElementPtr answer = server_->processConfig(config);
  233. ASSERT_TRUE(answer);
  234. int status = 0;
  235. ConstElementPtr txt = isc::config::parseAnswer(status, answer);
  236. // This should succeed. If not, print the error message.
  237. ASSERT_EQ(0, status) << txt->str();
  238. // Now check that the socket was indeed open.
  239. ASSERT_GT(isc::config::CommandMgr::instance().getControlSocketFD(), -1);
  240. }
  241. /// @brief Reset
  242. void reset() {
  243. CtrlDhcpv6SrvTest::reset();
  244. static_cast<void>(::remove(socket_path_.c_str()));
  245. }
  246. /// @brief Conducts a command/response exchange via UnixCommandSocket
  247. ///
  248. /// This method connects to the given server over the given socket path.
  249. /// If successful, it then sends the given command and retrieves the
  250. /// server's response. Note that it calls the server's receivePacket()
  251. /// method where needed to cause the server to process IO events on
  252. /// control channel the control channel sockets.
  253. ///
  254. /// @param command the command text to execute in JSON form
  255. /// @param response variable into which the received response should be
  256. /// placed.
  257. void sendUnixCommand(const std::string& command, std::string& response) {
  258. response = "";
  259. boost::scoped_ptr<UnixControlClient> client;
  260. client.reset(new UnixControlClient());
  261. ASSERT_TRUE(client);
  262. // Connect and then call server's receivePacket() so it can
  263. // detect the control socket connect and call the accept handler
  264. ASSERT_TRUE(client->connectToServer(socket_path_));
  265. ASSERT_NO_THROW(server_->receivePacket(0));
  266. // Send the command and then call server's receivePacket() so it can
  267. // detect the inbound data and call the read handler
  268. ASSERT_TRUE(client->sendCommand(command));
  269. ASSERT_NO_THROW(server_->receivePacket(0));
  270. // Read the response generated by the server. Note that getResponse
  271. // only fails if there an IO error or no response data was present.
  272. // It is not based on the response content.
  273. ASSERT_TRUE(client->getResponse(response));
  274. // Now disconnect and process the close event
  275. client->disconnectFromServer();
  276. ASSERT_NO_THROW(server_->receivePacket(0));
  277. }
  278. };
  279. TEST_F(CtrlDhcpv6SrvTest, commands) {
  280. boost::scoped_ptr<ControlledDhcpv6Srv> srv;
  281. ASSERT_NO_THROW(
  282. srv.reset(new ControlledDhcpv6Srv(DHCP6_SERVER_PORT + 10000))
  283. );
  284. // Use empty parameters list
  285. ElementPtr params(new isc::data::MapElement());
  286. int rcode = -1;
  287. // Case 1: send bogus command
  288. ConstElementPtr result = ControlledDhcpv6Srv::processCommand("blah", params);
  289. ConstElementPtr comment = isc::config::parseAnswer(rcode, result);
  290. EXPECT_EQ(1, rcode); // expect failure (no such command as blah)
  291. // Case 2: send shutdown command without any parameters
  292. result = ControlledDhcpv6Srv::processCommand("shutdown", params);
  293. comment = isc::config::parseAnswer(rcode, result);
  294. EXPECT_EQ(0, rcode); // expect success
  295. const pid_t pid(getpid());
  296. ConstElementPtr x(new isc::data::IntElement(pid));
  297. params->set("pid", x);
  298. // Case 3: send shutdown command with 1 parameter: pid
  299. result = ControlledDhcpv6Srv::processCommand("shutdown", params);
  300. comment = isc::config::parseAnswer(rcode, result);
  301. EXPECT_EQ(0, rcode); // Expect success
  302. }
  303. // Check that the "libreload" command will reload libraries
  304. TEST_F(CtrlDhcpv6SrvTest, libreload) {
  305. // Sending commands for processing now requires a server that can process
  306. // them.
  307. boost::scoped_ptr<ControlledDhcpv6Srv> srv;
  308. ASSERT_NO_THROW(
  309. srv.reset(new ControlledDhcpv6Srv(0))
  310. );
  311. // Ensure no marker files to start with.
  312. ASSERT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
  313. ASSERT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
  314. // Load two libraries
  315. std::vector<std::string> libraries;
  316. libraries.push_back(CALLOUT_LIBRARY_1);
  317. libraries.push_back(CALLOUT_LIBRARY_2);
  318. HooksManager::loadLibraries(libraries);
  319. // Check they are loaded.
  320. std::vector<std::string> loaded_libraries =
  321. HooksManager::getLibraryNames();
  322. ASSERT_TRUE(libraries == loaded_libraries);
  323. // ... which also included checking that the marker file created by the
  324. // load functions exists and holds the correct value (of "12" - the
  325. // first library appends "1" to the file, the second appends "2"). Also
  326. // check that the unload marker file does not yet exist.
  327. EXPECT_TRUE(checkMarkerFile(LOAD_MARKER_FILE, "12"));
  328. EXPECT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
  329. // Now execute the "libreload" command. This should cause the libraries
  330. // to unload and to reload.
  331. // Use empty parameters list
  332. ElementPtr params(new isc::data::MapElement());
  333. int rcode = -1;
  334. ConstElementPtr result =
  335. ControlledDhcpv6Srv::processCommand("libreload", params);
  336. ConstElementPtr comment = isc::config::parseAnswer(rcode, result);
  337. EXPECT_EQ(0, rcode); // Expect success
  338. // Check that the libraries have unloaded and reloaded. The libraries are
  339. // unloaded in the reverse order to which they are loaded. When they load,
  340. // they should append information to the loading marker file.
  341. EXPECT_TRUE(checkMarkerFile(UNLOAD_MARKER_FILE, "21"));
  342. EXPECT_TRUE(checkMarkerFile(LOAD_MARKER_FILE, "1212"));
  343. }
  344. // Check that the "configReload" command will reload libraries
  345. TEST_F(CtrlDhcpv6SrvTest, configReload) {
  346. // Sending commands for processing now requires a server that can process
  347. // them.
  348. boost::scoped_ptr<ControlledDhcpv6Srv> srv;
  349. ASSERT_NO_THROW(
  350. srv.reset(new ControlledDhcpv6Srv(0))
  351. );
  352. // Now execute the "libreload" command. This should cause the libraries
  353. // to unload and to reload.
  354. // Use empty parameters list
  355. // Prepare configuration file.
  356. string config_txt = "{ \"interfaces-config\": {"
  357. " \"interfaces\": [ \"*\" ]"
  358. "},"
  359. "\"preferred-lifetime\": 3000,"
  360. "\"rebind-timer\": 2000, "
  361. "\"renew-timer\": 1000, "
  362. "\"subnet6\": [ { "
  363. " \"pools\": [ { \"pool\": \"2001:db8:1::/80\" } ],"
  364. " \"subnet\": \"2001:db8:1::/64\" "
  365. " },"
  366. " {"
  367. " \"pools\": [ { \"pool\": \"2001:db8:2::/80\" } ],"
  368. " \"subnet\": \"2001:db8:2::/64\", "
  369. " \"id\": 0"
  370. " },"
  371. " {"
  372. " \"pools\": [ { \"pool\": \"2001:db8:3::/80\" } ],"
  373. " \"subnet\": \"2001:db8:3::/64\" "
  374. " } ],"
  375. "\"valid-lifetime\": 4000 }";
  376. ElementPtr config = Element::fromJSON(config_txt);
  377. // Make sure there are no subnets configured.
  378. CfgMgr::instance().clear();
  379. // Now send the command
  380. int rcode = -1;
  381. ConstElementPtr result =
  382. ControlledDhcpv6Srv::processCommand("config-reload", config);
  383. ConstElementPtr comment = isc::config::parseAnswer(rcode, result);
  384. EXPECT_EQ(0, rcode); // Expect success
  385. // Check that the config was indeed applied.
  386. const Subnet6Collection* subnets =
  387. CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->getAll();
  388. EXPECT_EQ(3, subnets->size());
  389. // Clean up after the test.
  390. CfgMgr::instance().clear();
  391. }
  392. typedef std::map<std::string, isc::data::ConstElementPtr> ElementMap;
  393. // This test checks which commands are registered by the DHCPv4 server.
  394. TEST_F(CtrlDhcpv6SrvTest, commandsRegistration) {
  395. ConstElementPtr list_cmds = createCommand("list-commands");
  396. ConstElementPtr answer;
  397. // By default the list should be empty (except the standard list-commands
  398. // supported by the CommandMgr itself)
  399. EXPECT_NO_THROW(answer = CommandMgr::instance().processCommand(list_cmds));
  400. ASSERT_TRUE(answer);
  401. ASSERT_TRUE(answer->get("arguments"));
  402. EXPECT_EQ("[ \"list-commands\" ]", answer->get("arguments")->str());
  403. // Created server should register several additional commands.
  404. boost::scoped_ptr<ControlledDhcpv6Srv> srv;
  405. ASSERT_NO_THROW(
  406. srv.reset(new ControlledDhcpv6Srv(0));
  407. );
  408. EXPECT_NO_THROW(answer = CommandMgr::instance().processCommand(list_cmds));
  409. ASSERT_TRUE(answer);
  410. ASSERT_TRUE(answer->get("arguments"));
  411. std::string command_list = answer->get("arguments")->str();
  412. EXPECT_TRUE(command_list.find("\"list-commands\"") != string::npos);
  413. EXPECT_TRUE(command_list.find("\"statistic-get\"") != string::npos);
  414. EXPECT_TRUE(command_list.find("\"statistic-get-all\"") != string::npos);
  415. EXPECT_TRUE(command_list.find("\"statistic-remove\"") != string::npos);
  416. EXPECT_TRUE(command_list.find("\"statistic-remove-all\"") != string::npos);
  417. EXPECT_TRUE(command_list.find("\"statistic-reset\"") != string::npos);
  418. EXPECT_TRUE(command_list.find("\"statistic-reset-all\"") != string::npos);
  419. // Ok, and now delete the server. It should deregister its commands.
  420. srv.reset();
  421. // The list should be (almost) empty again.
  422. EXPECT_NO_THROW(answer = CommandMgr::instance().processCommand(list_cmds));
  423. ASSERT_TRUE(answer);
  424. ASSERT_TRUE(answer->get("arguments"));
  425. EXPECT_EQ("[ \"list-commands\" ]", answer->get("arguments")->str());
  426. }
  427. // Tests that the server properly responds to invalid commands sent
  428. // via ControlChannel
  429. TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelNegative) {
  430. createUnixChannelServer();
  431. std::string response;
  432. sendUnixCommand("{ \"command\": \"bogus\" }", response);
  433. EXPECT_EQ("{ \"result\": 1,"
  434. " \"text\": \"'bogus' command not supported.\" }", response);
  435. sendUnixCommand("utter nonsense", response);
  436. EXPECT_EQ("{ \"result\": 1, "
  437. "\"text\": \"error: unexpected character u in <string>:1:2\" }",
  438. response);
  439. }
  440. // Tests that the server properly responds to shtudown command sent
  441. // via ControlChannel
  442. TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelShutdown) {
  443. createUnixChannelServer();
  444. std::string response;
  445. sendUnixCommand("{ \"command\": \"shutdown\" }", response);
  446. EXPECT_EQ("{ \"result\": 0, \"text\": \"Shutting down.\" }",response);
  447. }
  448. // Tests that the server properly responds to statistics commands. Note this
  449. // is really only intended to verify that the appropriate Statistics handler
  450. // is called based on the command. It is not intended to be an exhaustive
  451. // test of Dhcpv6 statistics.
  452. TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelStats) {
  453. createUnixChannelServer();
  454. std::string response;
  455. // Check statistic-get
  456. sendUnixCommand("{ \"command\" : \"statistic-get\", "
  457. " \"arguments\": {"
  458. " \"name\":\"bogus\" }}", response);
  459. EXPECT_EQ("{ \"arguments\": { }, \"result\": 0 }", response);
  460. // Check statistic-get-all
  461. sendUnixCommand("{ \"command\" : \"statistic-get-all\", "
  462. " \"arguments\": {}}", response);
  463. EXPECT_EQ("{ \"arguments\": { }, \"result\": 0 }", response);
  464. // Check statistic-reset
  465. sendUnixCommand("{ \"command\" : \"statistic-reset\", "
  466. " \"arguments\": {"
  467. " \"name\":\"bogus\" }}", response);
  468. EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
  469. response);
  470. // Check statistic-reset-all
  471. sendUnixCommand("{ \"command\" : \"statistic-reset-all\", "
  472. " \"arguments\": {}}", response);
  473. EXPECT_EQ("{ \"result\": 0, \"text\": "
  474. "\"All statistics reset to neutral values.\" }", response);
  475. // Check statistic-remove
  476. sendUnixCommand("{ \"command\" : \"statistic-remove\", "
  477. " \"arguments\": {"
  478. " \"name\":\"bogus\" }}", response);
  479. EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
  480. response);
  481. // Check statistic-remove-all
  482. sendUnixCommand("{ \"command\" : \"statistic-remove-all\", "
  483. " \"arguments\": {}}", response);
  484. EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics removed.\" }",
  485. response);
  486. }
  487. } // End of anonymous namespace