Merge Trond
authorBrian Aker <brian@gaz>
Tue, 22 Sep 2009 17:12:31 +0000 (10:12 -0700)
committerBrian Aker <brian@gaz>
Tue, 22 Sep 2009 17:12:31 +0000 (10:12 -0700)
1  2 
tests/function.c

diff --combined tests/function.c
index dfdb4d93b15fae8efa97f8014b9435d4456d93f8,661c324ee5ba99e490703a2a1f4038724ccea37b..418077717c8856ae51e397b0b9fdc54ab8f55bcc
@@@ -287,17 -287,25 +287,25 @@@ static test_return  connection_test(mem
  static test_return  error_test(memcached_st *memc)
  {
    memcached_return rc;
-   uint32_t values[] = { 851992627U, 2337886783U, 3196981036U, 4001849190U, 982370485U, 1263635348U, 4242906218U, 3829656100U, 1891735253U, 
-                         334139633U, 2257084983U, 3088286104U, 13199785U, 2542027183U, 1097051614U, 199566778U, 2748246961U, 2465192557U, 
-                         1664094137U, 2405439045U, 1842224848U, 692413798U, 3479807801U, 919913813U, 4269430871U, 610793021U, 527273862U, 
-                         1437122909U, 2300930706U, 2943759320U, 674306647U, 2400528935U, 54481931U, 4186304426U, 1741088401U, 2979625118U, 
-                         4159057246U };
-   assert(MEMCACHED_MAXIMUM_RETURN == 37); // You have updated the memcache_error messages but not updated docs/tests.
+   uint32_t values[] = { 851992627U, 2337886783U, 3196981036U, 4001849190U, 
+                         982370485U, 1263635348U, 4242906218U, 3829656100U, 
+                         1891735253U, 334139633U, 2257084983U, 3088286104U, 
+                         13199785U, 2542027183U, 1097051614U, 199566778U,
+                         2748246961U, 2465192557U, 1664094137U, 2405439045U, 
+                         1842224848U, 692413798U, 3479807801U, 919913813U,
+                         4269430871U, 610793021U, 527273862U, 1437122909U,
+                         2300930706U, 2943759320U, 674306647U, 2400528935U,
+                         54481931U, 4186304426U, 1741088401U, 2979625118U, 
+                         4159057246U, 3425930182U};
+   // You have updated the memcache_error messages but not updated docs/tests.
+   assert(MEMCACHED_MAXIMUM_RETURN == 38); 
    for (rc= MEMCACHED_SUCCESS; rc < MEMCACHED_MAXIMUM_RETURN; rc++)
    {
      uint32_t hash_val;
-     hash_val= memcached_generate_hash_value(memcached_strerror(memc, rc), strlen(memcached_strerror(memc, rc)), MEMCACHED_HASH_JENKINS);
+     const char *msg=  memcached_strerror(memc, rc);
+     hash_val= memcached_generate_hash_value(msg, strlen(msg), 
+                                             MEMCACHED_HASH_JENKINS);
      assert(values[rc] == hash_val);
    }
  
@@@ -1042,70 -1050,6 +1050,70 @@@ static test_return get_test5(memcached_
    return TEST_SUCCESS;
  }
  
 +static test_return  mget_end(memcached_st *memc)
 +{
 +  const char *keys[]= { "foo", "foo2" };
 +  size_t lengths[]= { 3, 4 };
 +  const char *values[]= { "fjord", "41" };
 +
 +  memcached_return rc;
 +
 +  // Set foo and foo2
 +  for (int i= 0; i < 2; i++)
 +  {
 +    rc= memcached_set(memc, keys[i], lengths[i], values[i], strlen(values[i]),
 +                    (time_t)0, (uint32_t)0);
 +    assert(rc == MEMCACHED_SUCCESS);
 +  }
 +
 +  char *string;
 +  size_t string_length;
 +  uint32_t flags;
 +
 +  // retrieve both via mget
 +  rc= memcached_mget(memc, keys, lengths, 2);
 +  assert(rc == MEMCACHED_SUCCESS);
 +
 +  char key[MEMCACHED_MAX_KEY];
 +  size_t key_length;
 +
 +  // this should get both
 +  for (int i = 0; i < 2; i++) 
 +  {
 +    string= memcached_fetch(memc, key, &key_length, &string_length,
 +                            &flags, &rc);
 +    assert(rc == MEMCACHED_SUCCESS);
 +    int val = 0;
 +    if (key_length == 4)
 +      val= 1;
 +    assert(string_length == strlen(values[val]));
 +    assert(strncmp(values[val], string, string_length) == 0);
 +    free(string);
 +  }
 +
 +  // this should indicate end
 +  string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
 +  assert(rc == MEMCACHED_END);
 +
 +  // now get just one
 +  rc= memcached_mget(memc, keys, lengths, 1);
 +  assert(rc == MEMCACHED_SUCCESS);
 +
 +  string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
 +  assert(key_length == lengths[0]);
 +  assert(strncmp(keys[0], key, key_length) == 0);
 +  assert(string_length == strlen(values[0]));
 +  assert(strncmp(values[0], string, string_length) == 0);
 +  assert(rc == MEMCACHED_SUCCESS);
 +  free(string);
 +
 +  // this should indicate end
 +  string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
 +  assert(rc == MEMCACHED_END);
 +
 +  return TEST_SUCCESS;
 +}
 +
  /* Do not copy the style of this code, I just access hosts to testthis function */
  static test_return  stats_servername_test(memcached_st *memc)
  {
@@@ -4449,6 -4393,28 +4457,28 @@@ static test_return jenkins_run (memcach
    return TEST_SUCCESS;
  }
  
+ static test_return regression_bug_434484(memcached_st *memc)
+ {
+   if (pre_binary(memc) != TEST_SUCCESS) 
+     return TEST_SUCCESS;
+    
+   memcached_return ret;
+   const char *key= "regression_bug_434484";
+   size_t keylen= strlen(key);
+   ret= memcached_append(memc, key, keylen, key, keylen, 0, 0);
+   assert(ret == MEMCACHED_NOTSTORED);
+   size_t size= 2048 * 1024;
+   void *data= malloc(size);
+   assert(data != NULL);
+   ret= memcached_set(memc, key, keylen, data, size, 0, 0);
+   assert(ret == MEMCACHED_E2BIG);
+   free(data);
+   return TEST_SUCCESS;
+ }
  test_st udp_setup_server_tests[] ={
    {"set_udp_behavior_test", 0, set_udp_behavior_test},
    {"add_tcp_server_udp_client_test", 0, add_tcp_server_udp_client_test},
@@@ -4511,7 -4477,6 +4541,7 @@@ test_st tests[] =
    {"mget_result", 1, mget_result_test },
    {"mget_result_alloc", 1, mget_result_alloc_test },
    {"mget_result_function", 1, mget_result_function },
 +  {"mget_end", 0, mget_end },
    {"get_stats", 0, get_stats },
    {"add_host_test", 0, add_host_test },
    {"add_host_test_1", 0, add_host_test1 },
@@@ -4602,6 -4567,17 +4632,17 @@@ test_st replication_tests[]= 
    {0, 0, 0}
  };
  
+ /*
+  * The following test suite is used to verify that we don't introduce
+  * regression bugs. If you want more information about the bug / test,
+  * you should look in the bug report at 
+  *   http://bugs.launchpad.net/libmemcached
+  */
+ test_st regression_tests[]= {
+   {"lp:434484", 1, regression_bug_434484 },
+   {0, 0, 0}
+ };
  test_st generate_tests[] ={
    {"generate_pairs", 1, generate_pairs },
    {"generate_data", 1, generate_data },
@@@ -4710,6 -4686,7 +4751,7 @@@ collection_st collection[] =
    {"test_hashes", 0, 0, hash_tests},
    {"replication", pre_replication, 0, replication_tests},
    {"replication_noblock", pre_replication_noblock, 0, replication_tests},
+   {"regression", 0, 0, regression_tests},
    {0, 0, 0, 0}
  };