jenkins-promote-staging-trunk-libmemcached-17
authorContinuous Integration <ci@tangent.org>
Thu, 10 May 2012 23:10:50 +0000 (16:10 -0700)
committerContinuous Integration <ci@tangent.org>
Thu, 10 May 2012 23:10:50 +0000 (16:10 -0700)
libmemcached-1.0/memcached.h
libmemcached/behavior.cc
libmemcached/io.cc
libtest/include.am
libtest/stream.cc [deleted file]
libtest/stream.h
m4/bottom.m4
tests/libmemcached-1.0/replication.cc

index fa9661528002e9f3712ace1f0679065d678c9213..23462a760bf97f672571d20fb873d0a0be60af0e 100644 (file)
@@ -38,7 +38,9 @@
 #pragma once
 
 /* This seems to be required for older compilers @note http://stackoverflow.com/questions/8132399/how-to-printf-uint64-t  */
-#define __STDC_FORMAT_MACROS
+#ifndef __STDC_FORMAT_MACROS
+#  define __STDC_FORMAT_MACROS
+#endif
 
 #ifdef __cplusplus
 #  include <tr1/cinttypes>
index 8ffbd665ec570ae29d76fddc7571d9804d6849fe..68e617d1410c6332b7d1bf5f9e69fd8efc072c18 100644 (file)
@@ -287,7 +287,7 @@ bool _is_auto_eject_host(const memcached_st *ptr)
 uint64_t memcached_behavior_get(memcached_st *ptr,
                                 const memcached_behavior_t flag)
 {
-  if (not ptr)
+  if (ptr == NULL)
   {
     return MEMCACHED_INVALID_ARGUMENTS;
   }
index e83522b984f99124429714469ea902db91c76336..8fb6ffda1bf7419a097fee68eff6d6893148e69e 100644 (file)
@@ -551,15 +551,17 @@ memcached_return_t memcached_io_slurp(memcached_server_write_instance_st ptr)
   return MEMCACHED_CONNECTION_FAILURE;
 }
 
-static ssize_t _io_write(memcached_server_write_instance_st ptr,
-                         const void *buffer, size_t length, bool with_flush)
+static bool _io_write(memcached_server_write_instance_st ptr,
+                      const void *buffer, size_t length, bool with_flush,
+                      size_t& written)
 {
   WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
   assert(memcached_is_udp(ptr->root) == false);
 
-  size_t original_length= length;
   const char *buffer_ptr= static_cast<const char *>(buffer);
 
+  const size_t original_length= length;
+
   while (length)
   {
     char *write_ptr;
@@ -580,7 +582,8 @@ static ssize_t _io_write(memcached_server_write_instance_st ptr,
       memcached_return_t rc;
       if (io_flush(ptr, with_flush, rc) == false)
       {
-        return -1;
+        written= original_length -length;
+        return false;
       }
     }
   }
@@ -591,22 +594,33 @@ static ssize_t _io_write(memcached_server_write_instance_st ptr,
     WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
     if (io_flush(ptr, with_flush, rc) == false)
     {
-      return -1;
+      written= original_length -length;
+      return false;
     }
   }
 
-  return ssize_t(original_length);
+  written= original_length -length;
+
+  return true;
 }
 
 bool memcached_io_write(memcached_server_write_instance_st ptr)
 {
-  return (_io_write(ptr, NULL, 0, true) >= 0);
+  size_t written;
+  return _io_write(ptr, NULL, 0, true, written);
 }
 
 ssize_t memcached_io_write(memcached_server_write_instance_st ptr,
                            const void *buffer, const size_t length, const bool with_flush)
 {
-  return _io_write(ptr, buffer, length, with_flush);
+  size_t written;
+
+  if (_io_write(ptr, buffer, length, with_flush, written) == false)
+  {
+    return -1;
+  }
+
+  return ssize_t(written);
 }
 
 ssize_t memcached_io_writev(memcached_server_write_instance_st ptr,
@@ -617,15 +631,14 @@ ssize_t memcached_io_writev(memcached_server_write_instance_st ptr,
 
   for (size_t x= 0; x < number_of; x++, vector++)
   {
-    ssize_t returnable;
-
     if (vector->length)
     {
-      if ((returnable= _io_write(ptr, vector->buffer, vector->length, false)) == -1)
+      size_t written;
+      if ((_io_write(ptr, vector->buffer, vector->length, false, written)) == false)
       {
         return -1;
       }
-      total+= returnable;
+      total+= written;
     }
   }
 
index 7e9be22da54672e5814bb197dc304a9bbec4ab4a..a0d5aa040433df53672dfa09521dfd2c89ee3e8c 100644 (file)
@@ -113,7 +113,6 @@ libtest_libtest_la_SOURCES+= libtest/server.cc
 libtest_libtest_la_SOURCES+= libtest/server_container.cc 
 libtest_libtest_la_SOURCES+= libtest/signal.cc 
 libtest_libtest_la_SOURCES+= libtest/socket.cc 
-libtest_libtest_la_SOURCES+= libtest/stream.cc 
 libtest_libtest_la_SOURCES+= libtest/strerror.cc 
 libtest_libtest_la_SOURCES+= libtest/timer.cc 
 libtest_libtest_la_SOURCES+= libtest/tmpfile.cc 
diff --git a/libtest/stream.cc b/libtest/stream.cc
deleted file mode 100644 (file)
index a9d769f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- *  Data Differential YATL (i.e. libtest)  library
- *
- *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are
- *  met:
- *
- *      * Redistributions of source code must retain the above copyright
- *  notice, this list of conditions and the following disclaimer.
- *
- *      * Redistributions in binary form must reproduce the above
- *  copyright notice, this list of conditions and the following disclaimer
- *  in the documentation and/or other materials provided with the
- *  distribution.
- *
- *      * The names of its contributors may not be used to endorse or
- *  promote products derived from this software without specific prior
- *  written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <config.h>
-#include <libtest/stream.h>
-
-namespace libtest {
-namespace stream {
-
-namespace detail {
-
-} // namespace detail
-
-make_cerr::make_cerr(const char* filename, int line_number, const char* func) :
-  log(std::cerr, filename, line_number, func)
-{ }
-
-cerr::cerr(const char* filename, int line_number, const char* func) :
-  log(std::cout, filename, line_number, func)
-  { }
-
-clog::clog(const char* filename, int line_number, const char* func) :
-  log(std::clog, filename, line_number, func)
-  { }
-
-cout::cout(const char* filename, int line_number, const char* func) :
-  log(std::cout, filename, line_number, func)
-  { }
-
-} // namespace stream
-} // namespace libtest
index 9917b94df253ed0ae103e834bf0e0ae26e7f3040..a32362f28977110fd25ba49e679547f03a6039a1 100644 (file)
@@ -150,22 +150,30 @@ template<template <class Ch, class Tr, class A> class OutputPolicy, class Ch = c
 
 class make_cerr : public detail::log<detail::channelln> {
 public:
-  make_cerr(const char* filename, int line_number, const char* func);
+  make_cerr(const char* filename, int line_number, const char* func) :
+    detail::log<detail::channelln>(std::cerr, filename, line_number, func)
+  { }
 };
 
 class cerr : public detail::log<detail::channel> {
 public:
-  cerr(const char* filename, int line_number, const char* func);
+  cerr(const char* filename, int line_number, const char* func) :
+    detail::log<detail::channel>(std::cout, filename, line_number, func)
+  { }
 };
 
 class clog : public detail::log<detail::channel> {
 public:
-  clog(const char* filename, int line_number, const char* func);
+  clog(const char* filename, int line_number, const char* func) :
+    detail::log<detail::channel>(std::clog, filename, line_number, func)
+  { }
 };
 
 class cout : public detail::log<detail::channel> {
 public:
-  cout(const char* filename, int line_number, const char* func);
+  cout(const char* filename, int line_number, const char* func) :
+    detail::log<detail::channel>(std::cout, filename, line_number, func)
+  { }
 };
 
 
index 303aaf7a6cc7d614c0088362f4a85ddbeb5333fc..a772e05945054718d2d1f8a1db8f2cc927e6277f 100644 (file)
@@ -12,7 +12,9 @@ AH_TOP([
 
 AH_BOTTOM([
 
-#define __STDC_FORMAT_MACROS
+#ifndef __STDC_FORMAT_MACROS
+#  define __STDC_FORMAT_MACROS
+#endif
  
 #if defined(__cplusplus) 
 #  include CINTTYPES_H 
index da3f82b3b131e0738139b63c40243d48d13eea80..502bd541d26586084f08467283fa5fbb6d2f2e57 100644 (file)
@@ -50,7 +50,8 @@ using namespace libtest;
 test_return_t check_replication_sanity_TEST(memcached_st *memc)
 {
   test_true(memc);
-  test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
+  test_compare(uint64_t(1), 
+               memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
 
   /*
    * Make sure that we store the item on all servers
@@ -63,9 +64,10 @@ test_return_t check_replication_sanity_TEST(memcached_st *memc)
 
 test_return_t replication_set_test(memcached_st *memc)
 {
-  memcached_return_t rc;
   memcached_st *memc_clone= memcached_clone(NULL, memc);
-  memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0);
+  test_true(memc_clone);
+  test_compare(MEMCACHED_SUCCESS, 
+               memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0));
 
   test_compare(MEMCACHED_SUCCESS, 
                memcached_set(memc, "bubba", 5, "0", 1, 0, 0));
@@ -96,6 +98,7 @@ test_return_t replication_set_test(memcached_st *memc)
     const char key[2]= { (char)x, 0 };
     size_t len;
     uint32_t flags;
+    memcached_return_t rc;
     char *val= memcached_get_by_key(memc_clone, key, 1, "bubba", 5,
                                     &len, &flags, &rc);
     test_compare(MEMCACHED_SUCCESS, rc);
@@ -110,7 +113,6 @@ test_return_t replication_set_test(memcached_st *memc)
 
 test_return_t replication_get_test(memcached_st *memc)
 {
-  memcached_return_t rc;
 
   /*
    * Don't do the following in your code. I am abusing the internal details
@@ -130,6 +132,7 @@ test_return_t replication_get_test(memcached_st *memc)
       const char key[2]= { (char)x, 0 };
       size_t len;
       uint32_t flags;
+      memcached_return_t rc;
       char *val= memcached_get_by_key(memc_clone, key, 1, "bubba", 5,
                                       &len, &flags, &rc);
       test_compare(MEMCACHED_SUCCESS, rc);
@@ -145,17 +148,17 @@ test_return_t replication_get_test(memcached_st *memc)
 
 test_return_t replication_mget_test(memcached_st *memc)
 {
-  memcached_return_t rc;
   memcached_st *memc_clone= memcached_clone(NULL, memc);
-  memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0);
+  test_true(memc_clone);
+  test_compare(MEMCACHED_SUCCESS, 
+               memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0));
 
   const char *keys[]= { "bubba", "key1", "key2", "key3" };
   size_t len[]= { 5, 4, 4, 4 };
 
   for (size_t x= 0; x< 4; ++x)
   {
-    rc= memcached_set(memc, keys[x], len[x], "0", 1, 0, 0);
-    test_true(rc == MEMCACHED_SUCCESS);
+    test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[x], len[x], "0", 1, 0, 0));
   }
 
   /*
@@ -190,13 +193,14 @@ test_return_t replication_mget_test(memcached_st *memc)
     {
       char key[2]= { (char)x, 0 };
 
-      rc= memcached_mget_by_key(new_clone, key, 1, keys, len, 4);
-      test_true(rc == MEMCACHED_SUCCESS);
+      test_compare(MEMCACHED_SUCCESS,
+                   memcached_mget_by_key(new_clone, key, 1, keys, len, 4));
 
       memcached_result_st *results= memcached_result_create(new_clone, &result_obj);
       test_true(results);
 
       int hits= 0;
+      memcached_return_t rc;
       while ((results= memcached_fetch_result(new_clone, &result_obj, &rc)) != NULL)
       {
         hits++;
@@ -216,7 +220,6 @@ test_return_t replication_mget_test(memcached_st *memc)
 test_return_t replication_randomize_mget_test(memcached_st *memc)
 {
   memcached_result_st result_obj;
-  memcached_return_t rc;
   memcached_st *memc_clone= memcached_clone(NULL, memc);
   memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 3);
   memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, 1);
@@ -226,8 +229,8 @@ test_return_t replication_randomize_mget_test(memcached_st *memc)
 
   for (size_t x= 0; x< 7; ++x)
   {
-    rc= memcached_set(memc, keys[x], len[x], "1", 1, 0, 0);
-    test_true(rc == MEMCACHED_SUCCESS);
+    test_compare(MEMCACHED_SUCCESS,
+                 memcached_set(memc, keys[x], len[x], "1", 1, 0, 0));
   }
 
   memcached_quit(memc);
@@ -243,6 +246,7 @@ test_return_t replication_randomize_mget_test(memcached_st *memc)
     test_true(results);
 
     int hits= 0;
+    memcached_return_t rc;
     while ((results= memcached_fetch_result(memc_clone, &result_obj, &rc)) != NULL)
     {
       ++hits;
@@ -251,6 +255,7 @@ test_return_t replication_randomize_mget_test(memcached_st *memc)
     memcached_result_free(&result_obj);
   }
   memcached_free(memc_clone);
+
   return TEST_SUCCESS;
 }
 
@@ -261,7 +266,7 @@ test_return_t replication_delete_test(memcached_st *memc_just_cloned)
   memcached_st *memc_replicated= memcached_clone(NULL, memc_just_cloned);
   const char *keys[]= { "bubba", "key1", "key2", "key3", "key4" };
 
-  test_true(memcached_behavior_get(memc_replicated, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
+  test_compare(uint64_t(1), memcached_behavior_get(memc_replicated, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
   test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_replicated, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, false));
 
   // Make one copy
@@ -331,11 +336,11 @@ test_return_t replication_randomize_mget_fail_test(memcached_st *memc)
   for (int x= int(MEMCACHED_SUCCESS); x < int(MEMCACHED_MAXIMUM_RETURN); ++x)
   {
     const char *key= memcached_strerror(NULL, memcached_return_t(x));
-    memcached_return_t rc;
     uint32_t flags;
     size_t value_length;
+    memcached_return_t rc;
     char *value= memcached_get(memc_clone, key, strlen(key), &value_length, &flags, &rc);
-    test_true(rc == MEMCACHED_SUCCESS);
+    test_compare(MEMCACHED_SUCCESS, rc);
     test_compare(strlen(key), value_length);
     test_strcmp(key, value);
     free(value);