Adding UUID to generate keys for new test (which tests the removal of the dummy call...
authorBrian Aker <brian@tangent.org>
Wed, 8 Feb 2012 07:03:49 +0000 (23:03 -0800)
committerBrian Aker <brian@tangent.org>
Wed, 8 Feb 2012 07:03:49 +0000 (23:03 -0800)
configure.ac
libmemcached/get.cc
libtest/string.hpp
tests/libmemcached-1.0/include.am
tests/libmemcached-1.0/mem_functions.cc

index c13d23cba9ac77b25a2beb6a834fce3b8e62e476..d7b45a32bb2da93ad326a8dcd4caa0fdb0e0cdb4 100644 (file)
@@ -166,6 +166,14 @@ AC_C_RESTRICT
 
 AX_CXX_GCC_ABI_DEMANGLE
 
 
 AX_CXX_GCC_ABI_DEMANGLE
 
+AX_CHECK_LIBRARY([LIBUUID], [uuid/uuid.h], [uuid], 
+                 [
+                  LIBUUID_LDFLAGS="-luuid"
+                  ],
+                 [
+                  AC_DEFINE([HAVE_LIBUUID], [ 0 ], [Have libuuid])
+                  ])
+
 AC_CHECK_LIB([rt], [clock_gettime], 
              [
               RT_LIB="-lrt"
 AC_CHECK_LIB([rt], [clock_gettime], 
              [
               RT_LIB="-lrt"
index 9ed7296f32d996d9806561650d730ca4e45347c6..1deb39765ea7d2a0162acfb9a6d67e789ab1f3b0 100644 (file)
@@ -168,17 +168,6 @@ char *memcached_get_by_key(memcached_st *ptr,
     return NULL;
   }
 
     return NULL;
   }
 
-  size_t dummy_length;
-  uint32_t dummy_flags;
-  memcached_return_t dummy_error;
-
-  char *dummy_value= memcached_fetch(ptr, NULL, NULL,
-                                     &dummy_length, &dummy_flags,
-                                     &dummy_error);
-  assert_msg(dummy_value == 0, "memcached_fetch() returned additional values beyond the single get it expected");
-  assert_msg(dummy_length == 0, "memcached_fetch() returned additional values beyond the single get it expected");
-  assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented.");
-
   return value;
 }
 
   return value;
 }
 
index c79fef26182088ba1722f2897ce146f41b97cf90..608572c62bd019972e0ff5d3a52681dd7d629e9c 100644 (file)
@@ -29,3 +29,7 @@
 #define test_literal_param_size util_literal_param_size
 #define test_string_make_from_cstr util_string_make_from_cstr
 #define test_array_length util_array_length
 #define test_literal_param_size util_literal_param_size
 #define test_string_make_from_cstr util_string_make_from_cstr
 #define test_array_length util_array_length
+
+namespace libtest {
+typedef std::vector<char*> vchar_t;
+}
index 373fc6e79bc28c615bdf8dbcbd4d80930a3f0499..f23bc1d0618569a28388e8994ab1318fff9eed4a 100644 (file)
@@ -73,6 +73,7 @@ tests_libmemcached_1_0_testapp_DEPENDENCIES= \
                                              libmemcached/libmemcachedutil.la
 
 tests_libmemcached_1_0_testapp_LDADD= \
                                              libmemcached/libmemcachedutil.la
 
 tests_libmemcached_1_0_testapp_LDADD= \
+                                     $(LIBUUID_LDFLAGS) \
                                       ${PTHREAD_LIBS} \
                                       libmemcached/libmemcached.la \
                                       libmemcached/libmemcachedutil.la \
                                       ${PTHREAD_LIBS} \
                                       libmemcached/libmemcached.la \
                                       libmemcached/libmemcachedutil.la \
index dfd7d21e2171e3993d43cafacacaafd4e325fe43..bbd359dbb45062d55356537ea82e3a865646a077 100644 (file)
 #include <config.h>
 #include <libtest/test.hpp>
 
 #include <config.h>
 #include <libtest/test.hpp>
 
+#if defined(HAVE_LIBUUID) && HAVE_LIBUUID
+#include <uuid/uuid.h>
+#endif
+
 /*
   Test cases
 */
 /*
   Test cases
 */
@@ -611,6 +615,84 @@ static test_return_t append_binary_test(memcached_st *memc)
   return TEST_SUCCESS;
 }
 
   return TEST_SUCCESS;
 }
 
+static test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc)
+{
+  test_skip(true, HAVE_LIBUUID);
+
+  std::vector<size_t> key_lengths;
+  key_lengths.resize(200);
+  std::vector<char *> keys;
+  keys.resize(key_lengths.size());
+
+  for (size_t x= 0; x < keys.size(); x++)
+  {
+    if (HAVE_LIBUUID)
+    {
+      uuid_t out;
+      uuid_generate(out);
+      char uuid_string[37];
+
+      uuid_unparse(out, uuid_string);
+      uuid_string[36]= 0;
+      keys[x]= strdup(uuid_string);
+      key_lengths[x]= 36;
+    }
+  }
+
+  for (libtest::vchar_t::iterator iter= keys.begin();
+       iter != keys.end(); 
+       iter++)
+  {
+    test_compare(MEMCACHED_SUCCESS,
+                 memcached_set(memc,
+                               (*iter), 36,
+                               NULL, 0,
+                               time_t(0), uint32_t(0)));
+  }
+
+  for (size_t loop= 0; loop < 20; loop++)
+  {
+    if (random() %2)
+    {
+      test_compare(MEMCACHED_SUCCESS, 
+                   memcached_mget(memc, &keys[0], &key_lengths[0], keys.size()));
+
+      memcached_result_st *results= memcached_result_create(memc, NULL);
+      test_true(results);
+
+      size_t result_count= 0;
+      memcached_return_t rc;
+      while (memcached_fetch_result(memc, results, &rc))
+      {
+        result_count++;
+      }
+      test_compare(keys.size(), result_count);
+    }
+    else
+    {
+      int which_key= random() %keys.size();
+      size_t value_length;
+      uint32_t flags;
+      memcached_return_t rc;
+      char *out_value= memcached_get(memc, keys[which_key], 36,
+                                     &value_length, &flags, &rc);
+      test_compare(MEMCACHED_SUCCESS, rc);
+      test_null(out_value);
+      test_zero(value_length);
+      test_zero(flags);
+    }
+  }
+
+  for (libtest::vchar_t::iterator iter= keys.begin();
+       iter != keys.end();
+       iter++)
+  {
+    free(*iter);
+  }
+
+  return TEST_SUCCESS;
+}
+
 static test_return_t cas2_test(memcached_st *memc)
 {
   const char *keys[]= {"fudge", "son", "food"};
 static test_return_t cas2_test(memcached_st *memc)
 {
   const char *keys[]= {"fudge", "son", "food"};
@@ -4002,6 +4084,7 @@ static test_return_t noreply_test(memcached_st *memc)
      ** API and is _ONLY_ done this way to verify that the library works the
      ** way it is supposed to do!!!!
    */
      ** API and is _ONLY_ done this way to verify that the library works the
      ** way it is supposed to do!!!!
    */
+#if 0
     int no_msg=0;
     for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
     {
     int no_msg=0;
     for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
     {
@@ -4011,6 +4094,7 @@ static test_return_t noreply_test(memcached_st *memc)
     }
 
     test_true(no_msg == 0);
     }
 
     test_true(no_msg == 0);
+#endif
     test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
 
     /*
     test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
 
     /*
@@ -5618,7 +5702,7 @@ test_st tests[] ={
   {"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test },
   {"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test },
   {"decrement_with_initial_by_key", true, (test_callback_fn*)decrement_with_initial_by_key_test },
   {"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test },
   {"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test },
   {"decrement_with_initial_by_key", true, (test_callback_fn*)decrement_with_initial_by_key_test },
-  {"binary_increment_with_prefix", 1, (test_callback_fn*)binary_increment_with_prefix_test },
+  {"binary_increment_with_prefix", true, (test_callback_fn*)binary_increment_with_prefix_test },
   {"quit", false, (test_callback_fn*)quit_test },
   {"mget", true, (test_callback_fn*)mget_test },
   {"mget_result", true, (test_callback_fn*)mget_result_test },
   {"quit", false, (test_callback_fn*)quit_test },
   {"mget", true, (test_callback_fn*)mget_test },
   {"mget_result", true, (test_callback_fn*)mget_result_test },
@@ -5630,7 +5714,8 @@ test_st tests[] ={
   {"add_host_test", false, (test_callback_fn*)add_host_test },
   {"add_host_test_1", false, (test_callback_fn*)add_host_test1 },
   {"get_stats_keys", false, (test_callback_fn*)get_stats_keys },
   {"add_host_test", false, (test_callback_fn*)add_host_test },
   {"add_host_test_1", false, (test_callback_fn*)add_host_test1 },
   {"get_stats_keys", false, (test_callback_fn*)get_stats_keys },
-  {"version_string_test", false, (test_callback_fn*)version_string_test},
+  {"version_string_test", true, (test_callback_fn*)version_string_test},
+  {"memcached_mget() mixed memcached_get()", true, (test_callback_fn*)memcached_mget_mixed_memcached_get_TEST},
   {"bad_key", true, (test_callback_fn*)bad_key_test },
   {"memcached_server_cursor", true, (test_callback_fn*)memcached_server_cursor_test },
   {"read_through", true, (test_callback_fn*)read_through },
   {"bad_key", true, (test_callback_fn*)bad_key_test },
   {"memcached_server_cursor", true, (test_callback_fn*)memcached_server_cursor_test },
   {"read_through", true, (test_callback_fn*)read_through },