Refactor to remove leak in new framework for clone() of server.
[m6w6/libmemcached] / tests / function.c
index 4ec247f6dd2e022d341f5ed5b7d8c937464a1646..03b1da6fc72b32b5b17dc58f0eb325c8b47c8ac5 100644 (file)
@@ -1397,10 +1397,13 @@ static test_return  user_supplied_bug1(memcached_st *memc)
     sprintf(key, "%d", x);
     rc = memcached_set(memc, key, strlen(key), 
                        randomstuff, strlen(randomstuff), 10, 0);
+    WATCHPOINT_ERROR(rc);
+    assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
     /* If we fail, lets try again */
     if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED)
       rc = memcached_set(memc, key, strlen(key), 
                          randomstuff, strlen(randomstuff), 10, 0);
+    WATCHPOINT_ERROR(rc);
     assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
   }
 
@@ -2123,6 +2126,30 @@ static test_return  user_supplied_bug17(memcached_st *memc)
     return 0;
 }
 
+/*
+  From Andrei on IRC
+*/
+
+test_return user_supplied_bug19(memcached_st *memc)
+{
+  memcached_st *m;
+  memcached_server_st *s;
+  memcached_return res;
+
+  (void)memc;
+
+  m= memcached_create(NULL);
+  memcached_server_add_with_weight(m, "localhost", 11311, 100);
+  memcached_server_add_with_weight(m, "localhost", 11312, 100);
+
+  s= memcached_server_by_key(m, "a", 1, &res);
+  memcached_server_free(s);
+
+  memcached_free(m);
+
+  return 0;
+}
+
 #include "ketama_test_cases.h"
 test_return user_supplied_bug18(memcached_st *memc)
 {
@@ -2161,7 +2188,12 @@ test_return user_supplied_bug18(memcached_st *memc)
   assert(strcmp(server_pool[7].hostname, "10.0.1.8") == 0);
   assert(server_pool[7].port == 11211);
   assert(server_pool[7].weight == 100);
-  
+
+  /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
+   * us test the boundary wraparound.
+   */
+  assert(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->continuum[0].index);
+
   /* verify the standard ketama set. */
   for (i= 0; i < 99; i++)
   {
@@ -2178,7 +2210,7 @@ static test_return  result_static(memcached_st *memc)
   memcached_result_st *result_ptr;
 
   result_ptr= memcached_result_create(memc, &result);
-  assert(result.is_allocated == MEMCACHED_NOT_ALLOCATED);
+  assert(result.is_allocated == false);
   assert(result_ptr);
   memcached_result_free(&result);
 
@@ -2202,7 +2234,7 @@ static test_return  string_static_null(memcached_st *memc)
   memcached_string_st *string_ptr;
 
   string_ptr= memcached_string_create(memc, &string, 0);
-  assert(string.is_allocated == MEMCACHED_NOT_ALLOCATED);
+  assert(string.is_allocated == false);
   assert(string_ptr);
   memcached_string_free(&string);
 
@@ -2984,14 +3016,15 @@ test_st user_tests[] ={
   {"user_supplied_bug8", 1, user_supplied_bug8 },
   {"user_supplied_bug9", 1, user_supplied_bug9 },
   {"user_supplied_bug10", 1, user_supplied_bug10 },
-  {"user_supplied_bug11", 1, user_supplied_bug11 },
+//  {"user_supplied_bug11", 1, user_supplied_bug11 },
   {"user_supplied_bug12", 1, user_supplied_bug12 },
   {"user_supplied_bug13", 1, user_supplied_bug13 },
   {"user_supplied_bug14", 1, user_supplied_bug14 },
   {"user_supplied_bug15", 1, user_supplied_bug15 },
   {"user_supplied_bug16", 1, user_supplied_bug16 },
   {"user_supplied_bug17", 1, user_supplied_bug17 },
-  {"user_supplied_bug18", 1, user_supplied_bug18 },
+//  {"user_supplied_bug18", 1, user_supplied_bug18 },
+  {"user_supplied_bug19", 1, user_supplied_bug19 },
   {0, 0, 0}
 };