Additional test key.w
authorBrian Aker <brian@tangent.org>
Mon, 9 Apr 2012 15:22:46 +0000 (08:22 -0700)
committerBrian Aker <brian@tangent.org>
Mon, 9 Apr 2012 15:22:46 +0000 (08:22 -0700)
x

tests/include.am
tests/libmemcached-1.0/all_tests.h
tests/libmemcached-1.0/encoding_key.cc
tests/libmemcached-1.0/encoding_key.h

index f4c6dcfd743a8c0161e0074d081d8df310c5e7b9..c0d7771c1e125c5d7cccdb8783f23e7a799b38be 100644 (file)
@@ -66,28 +66,28 @@ test: check
 check-local: $(TEST_DOCS)
        @echo "Tests completed"
 
-test-mem: tests/var tests/libmemcached-1.0/testapp
+test-mem: tests/libmemcached-1.0/testapp
        @tests/libmemcached-1.0/testapp
 
 test-sasl: tests/sasl
        @tests/sasl
 
-test-atom: tests/var tests/atomsmasher
+test-atom: tests/atomsmasher
        @tests/atomsmasher
 
-test-plus: tests/var tests/testplus
+test-plus: tests/testplus
        @tests/testplus
 
-test-hash: tests/var tests/testhashkit
+test-hash: tests/testhashkit
        @tests/testhashkit
 
-test-hashplus: tests/var tests/hash_plus
+test-hashplus: tests/hash_plus
        @tests/hash_plus
 
-test-cycle: tests/var tests/cycle
+test-cycle: tests/cycle
        @tests/cycle
 
-test-memcapable: tests/var tests/memcapable
+test-memcapable: tests/memcapable
        @tests/memcapable
 
 pahole-mem: tests/testapp
index 9f01ae29f1fb51605d42482a17e51193c1fbb4b3..4dab69ff7310ddc63e11c448a205f5e81af6780d 100644 (file)
@@ -414,6 +414,7 @@ test_st memcached_set_encoding_key_TESTS[] ={
   {"memcached_set_encoding_key() +increment_with_initial()", true, (test_callback_fn*)memcached_set_encoding_key_increment_with_initial_TEST },
   {"memcached_set_encoding_key() +decrement_with_initial()", true, (test_callback_fn*)memcached_set_encoding_key_decrement_with_initial_TEST },
   {"memcached_set_encoding_key() +set() +get() +cloen()", true, (test_callback_fn*)memcached_set_encoding_key_set_get_clone_TEST },
+  {"memcached_set_encoding_key() +set() +get() increase value size", true, (test_callback_fn*)memcached_set_encoding_key_set_grow_key_TEST },
   {0, 0, (test_callback_fn*)0}
 };
 
index 114de1f1a6bd711dfca3ffff89d00dbc5d0b7811..b9edbc672e9782e88afd56dc531f8efff2711c46 100644 (file)
@@ -317,3 +317,64 @@ test_return_t memcached_set_encoding_key_set_get_clone_TEST(memcached_st* memc)
 
   return TEST_SUCCESS;
 }
+
+test_return_t memcached_set_encoding_key_set_grow_key_TEST(memcached_st* memc)
+{
+  memcached_st *memc_no_crypt= memcached_clone(NULL, memc);
+  test_true(memc_no_crypt);
+  test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__)));
+
+  size_t payload_size[] = { 100, 1000, 10000, 1000000, 1000000, 0 };
+  libtest::vchar_t payload;
+  for (size_t *ptr= payload_size; *ptr; ptr++)
+  {
+    payload.reserve(*ptr);
+    for (size_t x= payload.size(); x < *ptr; x++)
+    { 
+      payload.push_back(rand());
+    }
+
+    {
+      memcached_return_t rc= memcached_set(memc,
+                                           test_literal_param(__func__), // Key
+                                           &payload[0], payload.size(), // Value
+                                           time_t(0),
+                                           uint32_t(0));
+
+      // If we run out of space on the server, we just end the test early.
+      if (rc == MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE)
+      {
+        break;
+      }
+      test_compare_hint(MEMCACHED_SUCCESS, rc, memcached_last_error_message(memc));
+    }
+
+    {
+      memcached_return_t rc;
+      size_t value_length;
+      char *value;
+      test_true((value= memcached_get(memc,
+                                      test_literal_param(__func__), // Key
+                                      &value_length, NULL, &rc)));
+      test_compare(MEMCACHED_SUCCESS, rc);
+      test_compare(payload.size(), value_length);
+      test_memcmp(&payload[0], value, value_length);
+
+      size_t raw_value_length;
+      char *raw_value;
+      test_true((raw_value= memcached_get(memc_no_crypt,
+                                          test_literal_param(__func__), // Key
+                                          &raw_value_length, NULL, &rc)));
+      test_compare(MEMCACHED_SUCCESS, rc);
+      test_ne_compare(payload.size(), raw_value_length);
+      test_ne_compare(0, memcmp(&payload[0], raw_value, raw_value_length));
+
+      free(value);
+      free(raw_value);
+    }
+  }
+
+  memcached_free(memc_no_crypt);
+
+  return TEST_SUCCESS;
+}
index 3abbf0e6768e55c0c0f108a63ea7b30108805c53..4be0cb14b8f98aeee7a760e4f8d3cd8c40b0b912 100644 (file)
@@ -48,3 +48,4 @@ test_return_t memcached_set_encoding_key_decrement_with_initial_TEST(memcached_s
 test_return_t memcached_set_encoding_key_prepend_TEST(memcached_st*);
 test_return_t memcached_set_encoding_key_append_TEST(memcached_st*);
 test_return_t memcached_set_encoding_key_set_get_clone_TEST(memcached_st*);
+test_return_t memcached_set_encoding_key_set_grow_key_TEST(memcached_st*);