tests: honor EPIPE in kill(HUP) test
[awesomized/libmemcached] / clients / memcapable.cc
index f914520658aa0324a5ba9b63c270aa231f0b8630..c52b3c46b62ef484650dec7c52ef31a48bf4c570 100644 (file)
@@ -37,7 +37,7 @@
 #include <libmemcached-1.0/memcached.h>
 
 #include "libmemcached/socket.hpp"
-#include "libmemcached/memcached/protocol_binary.h"
+#include "libmemcachedprotocol-0.0/binary.h"
 #include "libmemcached/byteorder.h"
 #include "clients/utilities.h"
 
@@ -186,8 +186,9 @@ static memcached_socket_t connect_server(const char *hostname, const char *port)
       }
     }
     else
-      fprintf(stderr, "Failed to create socket: %s\n",
-              strerror(get_socket_errno()));
+    {
+      fprintf(stderr, "Failed to create socket: %s\n", strerror(get_socket_errno()));
+    }
 
     freeaddrinfo(ai);
   }
@@ -535,6 +536,7 @@ static enum test_return do_validate_response_header(response *rsp,
     case PROTOCOL_BINARY_CMD_REPLACEQ:
     case PROTOCOL_BINARY_CMD_SETQ:
       verify("Quiet command shouldn't return on success" == NULL);
+      /* fall through */
     default:
       break;
     }
@@ -1301,7 +1303,7 @@ static enum test_return test_ascii_verbosity(void)
   execute(receive_error_response());
 
   execute(send_string("verbosity noreply\r\n"));
-  execute(receive_error_response());
+  execute(test_ascii_version());
 
   execute(send_string("verbosity 0 noreply\r\n"));
   execute(test_ascii_version());
@@ -2078,8 +2080,8 @@ int main(int argc, char **argv)
   struct test_type_st tests= { true, true };
   int total= 0;
   int failed= 0;
-  const char *hostname= "localhost";
-  const char *port= "11211";
+  const char *hostname= NULL;
+  const char *port= MEMCACHED_DEFAULT_PORT_STRING;
   int cmd;
   bool prompt= false;
   const char *testname= NULL;
@@ -2147,12 +2149,18 @@ int main(int argc, char **argv)
     }
   }
 
+  if (!hostname)
+  {
+    fprintf(stderr, "No hostname was provided.\n");
+    return EXIT_FAILURE;
+  }
+
   initialize_sockets();
   sock= connect_server(hostname, port);
   if (sock == INVALID_SOCKET)
   {
     fprintf(stderr, "Failed to connect to <%s:%s>: %s\n",
-            hostname, port, strerror(get_socket_errno()));
+            hostname?:"(null)", port?:"(null)", strerror(get_socket_errno()));
     return EXIT_FAILURE;
   }
 
@@ -2224,7 +2232,7 @@ int main(int argc, char **argv)
       closesocket(sock);
       if ((sock= connect_server(hostname, port)) == INVALID_SOCKET)
       {
-        fprintf(stderr, "Failed to connect to <%s:%s>: %s\n", hostname, port, strerror(get_socket_errno()));
+        fprintf(stderr, "Failed to connect to <%s:%s>: %s\n", hostname?:"(null)", port?:"(null)", strerror(get_socket_errno()));
         fprintf(stderr, "%d of %d tests failed\n", failed, total);
         return EXIT_FAILURE;
       }