Merge
[m6w6/libmemcached] / tests / debug.cc
index 4ba46eaed4c3b1f0d015a2952e17eeb17fbf56ca..5e72a0b6b52bf5c0496fa9797906f4d1d3653ecf 100644 (file)
@@ -44,6 +44,7 @@ using namespace libtest;
 
 #include <libmemcached/memcached.h>
 #include <tests/debug.h>
+#include <tests/print.h>
 
 /* Dump each server's keys */
 static memcached_return_t print_keys_callback(const memcached_st *,
@@ -96,7 +97,7 @@ static memcached_return_t server_wrapper_for_dump_callback(const memcached_st *,
 }
 
 
-test_return_t confirm_keys_exist(memcached_st *memc, const char * const *keys, const size_t number_of_keys, bool key_matches_value)
+test_return_t confirm_keys_exist(memcached_st *memc, const char * const *keys, const size_t number_of_keys, bool key_matches_value, bool require_all)
 {
   for (size_t x= 0; x < number_of_keys; ++x)
   {
@@ -106,12 +107,27 @@ test_return_t confirm_keys_exist(memcached_st *memc, const char * const *keys, c
                                test_string_make_from_cstr(keys[x]), // Keys
                                &value_length,
                                0, &rc);
-    test_true_got(value, keys[x]);
-    if (key_matches_value)
+    if (require_all)
     {
-      test_strcmp(keys[x], value);
+      test_true_got(value, keys[x]);
+      if (key_matches_value)
+      {
+        test_strcmp(keys[x], value);
+      }
+    }
+    else if (memcached_success(rc))
+    {
+      test_warn_hint(value, keys[x]);
+      if (value and key_matches_value)
+      {
+        test_strcmp(keys[x], value);
+      }
+    }
+
+    if (value)
+    {
+      free(value);
     }
-    free(value);
   }
 
   return TEST_SUCCESS;
@@ -179,3 +195,10 @@ size_t confirm_key_count(memcached_st *memc)
   memcached_free(clone);
   return count;
 }
+
+void print_servers(memcached_st *memc)
+{
+  memcached_server_fn callbacks[1];
+  callbacks[0]= server_print_callback;
+  memcached_server_cursor(memc, callbacks, NULL,  1);
+}