+static test_return_t udp_buffered_delete_test(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
+ return udp_delete_test(memc);
+}
+
+static test_return_t udp_verbosity_test(memcached_st *memc)
+{
+ memcached_return_t rc;
+ uint16_t *expected_ids= get_udp_request_ids(memc);
+ unsigned int x;
+ for (x= 0; x < memcached_server_count(memc); x++)
+ increment_request_id(&expected_ids[x]);
+
+ rc= memcached_verbosity(memc,3);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ return post_udp_op_check(memc,expected_ids);
+}
+
+static test_return_t udp_quit_test(memcached_st *memc)
+{
+ uint16_t *expected_ids= get_udp_request_ids(memc);
+ memcached_quit(memc);
+ return post_udp_op_check(memc, expected_ids);
+}
+
+static test_return_t udp_flush_test(memcached_st *memc)
+{
+ memcached_return_t rc;
+ uint16_t *expected_ids= get_udp_request_ids(memc);
+ unsigned int x;
+ for (x= 0; x < memcached_server_count(memc);x++)
+ increment_request_id(&expected_ids[x]);
+
+ rc= memcached_flush(memc,0);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ return post_udp_op_check(memc,expected_ids);
+}
+
+static test_return_t udp_incr_test(memcached_st *memc)
+{
+ memcached_return_t rc;
+ const char *key= "incr";
+ const char *value= "1";
+ rc= memcached_set(memc, key, strlen(key),
+ value, strlen(value),
+ (time_t)0, (uint32_t)0);
+
+ test_truth(rc == MEMCACHED_SUCCESS);
+ uint16_t *expected_ids= get_udp_request_ids(memc);
+ unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
+ increment_request_id(&expected_ids[server_key]);
+ uint64_t newvalue;
+ rc= memcached_increment(memc, key, strlen(key), 1, &newvalue);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ return post_udp_op_check(memc, expected_ids);
+}
+
+static test_return_t udp_decr_test(memcached_st *memc)
+{
+ memcached_return_t rc;
+ const char *key= "decr";
+ const char *value= "1";
+ rc= memcached_set(memc, key, strlen(key),
+ value, strlen(value),
+ (time_t)0, (uint32_t)0);
+
+ test_truth(rc == MEMCACHED_SUCCESS);
+ uint16_t *expected_ids= get_udp_request_ids(memc);
+ unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
+ increment_request_id(&expected_ids[server_key]);
+ uint64_t newvalue;
+ rc= memcached_decrement(memc, key, strlen(key), 1, &newvalue);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ return post_udp_op_check(memc, expected_ids);
+}
+
+
+static test_return_t udp_stat_test(memcached_st *memc)
+{
+ memcached_stat_st * rv= NULL;
+ memcached_return_t rc;
+ char args[]= "";
+ uint16_t *expected_ids = get_udp_request_ids(memc);
+ rv = memcached_stat(memc, args, &rc);
+ free(rv);
+ test_truth(rc == MEMCACHED_NOT_SUPPORTED);
+ return post_udp_op_check(memc, expected_ids);
+}
+
+static test_return_t udp_version_test(memcached_st *memc)
+{
+ memcached_return_t rc;
+ uint16_t *expected_ids = get_udp_request_ids(memc);
+ rc = memcached_version(memc);
+ test_truth(rc == MEMCACHED_NOT_SUPPORTED);
+ return post_udp_op_check(memc, expected_ids);
+}
+
+static test_return_t udp_get_test(memcached_st *memc)
+{
+ memcached_return_t rc;
+ const char *key= "foo";
+ size_t vlen;
+ uint16_t *expected_ids = get_udp_request_ids(memc);
+ char *val= memcached_get(memc, key, strlen(key), &vlen, (uint32_t)0, &rc);
+ test_truth(rc == MEMCACHED_NOT_SUPPORTED);
+ test_truth(val == NULL);
+ return post_udp_op_check(memc, expected_ids);
+}
+
+static test_return_t udp_mixed_io_test(memcached_st *memc)
+{
+ test_st current_op;
+ test_st mixed_io_ops [] ={
+ {"udp_set_test", 0,
+ (test_callback_fn)udp_set_test},
+ {"udp_set_too_big_test", 0,
+ (test_callback_fn)udp_set_too_big_test},
+ {"udp_delete_test", 0,
+ (test_callback_fn)udp_delete_test},
+ {"udp_verbosity_test", 0,
+ (test_callback_fn)udp_verbosity_test},
+ {"udp_quit_test", 0,
+ (test_callback_fn)udp_quit_test},
+ {"udp_flush_test", 0,
+ (test_callback_fn)udp_flush_test},
+ {"udp_incr_test", 0,
+ (test_callback_fn)udp_incr_test},
+ {"udp_decr_test", 0,
+ (test_callback_fn)udp_decr_test},
+ {"udp_version_test", 0,
+ (test_callback_fn)udp_version_test}
+ };
+ unsigned int x= 0;
+ for (x= 0; x < 500; x++)
+ {
+ current_op= mixed_io_ops[random() % 9];
+ test_truth(current_op.test_fn(memc) == TEST_SUCCESS);
+ }
+ return TEST_SUCCESS;
+}
+
+#if 0
+static test_return_t hash_sanity_test (memcached_st *memc)
+{
+ (void)memc;
+
+ assert(MEMCACHED_HASH_DEFAULT == MEMCACHED_HASH_DEFAULT);
+ assert(MEMCACHED_HASH_MD5 == MEMCACHED_HASH_MD5);
+ assert(MEMCACHED_HASH_CRC == MEMCACHED_HASH_CRC);
+ assert(MEMCACHED_HASH_FNV1_64 == MEMCACHED_HASH_FNV1_64);
+ assert(MEMCACHED_HASH_FNV1A_64 == MEMCACHED_HASH_FNV1A_64);
+ assert(MEMCACHED_HASH_FNV1_32 == MEMCACHED_HASH_FNV1_32);
+ assert(MEMCACHED_HASH_FNV1A_32 == MEMCACHED_HASH_FNV1A_32);
+#ifdef HAVE_HSIEH_HASH
+ assert(MEMCACHED_HASH_HSIEH == MEMCACHED_HASH_HSIEH);
+#endif
+ assert(MEMCACHED_HASH_MURMUR == MEMCACHED_HASH_MURMUR);
+ assert(MEMCACHED_HASH_JENKINS == MEMCACHED_HASH_JENKINS);
+ assert(MEMCACHED_HASH_MAX == MEMCACHED_HASH_MAX);
+
+ return TEST_SUCCESS;
+}
+#endif
+
+static test_return_t hsieh_avaibility_test (memcached_st *memc)
+{
+ memcached_return_t expected_rc= MEMCACHED_FAILURE;
+#ifdef HAVE_HSIEH_HASH
+ expected_rc= MEMCACHED_SUCCESS;
+#endif
+ memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH,
+ (uint64_t)MEMCACHED_HASH_HSIEH);
+ test_truth(rc == expected_rc);
+ return TEST_SUCCESS;
+}
+
+static test_return_t md5_run (memcached_st *memc __attribute__((unused)))
+{
+ uint32_t x;
+ const char **ptr;
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_MD5);
+ test_truth(md5_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t crc_run (memcached_st *memc __attribute__((unused)))
+{
+ uint32_t x;
+ const char **ptr;
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_CRC);
+ test_truth(crc_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t fnv1_64_run (memcached_st *memc __attribute__((unused)))
+{
+ uint32_t x;
+ const char **ptr;
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1_64);
+ test_truth(fnv1_64_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t fnv1a_64_run (memcached_st *memc __attribute__((unused)))
+{
+ uint32_t x;
+ const char **ptr;
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1A_64);
+ test_truth(fnv1a_64_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t fnv1_32_run (memcached_st *memc __attribute__((unused)))
+{
+ uint32_t x;
+ const char **ptr;
+
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1_32);
+ test_truth(fnv1_32_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t fnv1a_32_run (memcached_st *memc __attribute__((unused)))
+{
+ uint32_t x;
+ const char **ptr;
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1A_32);
+ test_truth(fnv1a_32_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t hsieh_run (memcached_st *memc __attribute__((unused)))
+{
+ uint32_t x;
+ const char **ptr;
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_HSIEH);
+ test_truth(hsieh_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t murmur_run (memcached_st *memc __attribute__((unused)))
+{
+#ifdef __sparc
+ return TEST_SKIPPED;
+#else
+ uint32_t x;
+ const char **ptr;
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_MURMUR);
+ test_truth(murmur_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+#endif
+}
+
+static test_return_t jenkins_run (memcached_st *memc __attribute__((unused)))
+{
+ uint32_t x;
+ const char **ptr;
+
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_JENKINS);
+ test_truth(jenkins_values[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
+
+static test_return_t ketama_compatibility_libmemcached(memcached_st *trash)
+{
+ memcached_return_t rc;
+ uint64_t value;
+ int x;
+ memcached_server_st *server_pool;
+ memcached_st *memc;
+
+ (void)trash;
+
+ memc= memcached_create(NULL);
+ test_truth(memc);
+
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
+ test_truth(rc == MEMCACHED_SUCCESS);
+
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
+ test_truth(value == 1);
+
+ test_truth(memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA) == MEMCACHED_SUCCESS);
+ test_truth(memcached_behavior_get_distribution(memc) == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA);
+
+
+ server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ memcached_server_push(memc, server_pool);
+
+ /* verify that the server list was parsed okay. */
+ test_truth(memcached_server_count(memc) == 8);
+ test_strcmp(server_pool[0].hostname, "10.0.1.1");
+ test_truth(server_pool[0].port == 11211);
+ test_truth(server_pool[0].weight == 600);
+ test_strcmp(server_pool[2].hostname, "10.0.1.3");
+ test_truth(server_pool[2].port == 11211);
+ test_truth(server_pool[2].weight == 200);
+ test_strcmp(server_pool[7].hostname, "10.0.1.8");
+ test_truth(server_pool[7].port == 11211);
+ test_truth(server_pool[7].weight == 100);
+
+ /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
+ * us test the boundary wraparound.
+ */
+ test_truth(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->continuum[0].index);
+
+ /* verify the standard ketama set. */
+ for (x= 0; x < 99; x++)
+ {
+ uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
+ char *hostname = memc->hosts[server_idx].hostname;
+
+ test_strcmp(hostname, ketama_test_cases[x].server);
+ }
+
+ memcached_server_list_free(server_pool);
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t ketama_compatibility_spymemcached(memcached_st *trash)
+{
+ memcached_return_t rc;
+ uint64_t value;
+ int x;
+ memcached_server_st *server_pool;
+ memcached_st *memc;
+
+ (void)trash;
+
+ memc= memcached_create(NULL);
+ test_truth(memc);
+
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
+ test_truth(rc == MEMCACHED_SUCCESS);
+
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
+ test_truth(value == 1);
+
+ test_truth(memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY) == MEMCACHED_SUCCESS);
+ test_truth(memcached_behavior_get_distribution(memc) == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY);
+
+ server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ memcached_server_push(memc, server_pool);
+
+ /* verify that the server list was parsed okay. */
+ test_truth(memcached_server_count(memc) == 8);
+ test_strcmp(server_pool[0].hostname, "10.0.1.1");
+ test_truth(server_pool[0].port == 11211);
+ test_truth(server_pool[0].weight == 600);
+ test_strcmp(server_pool[2].hostname, "10.0.1.3");
+ test_truth(server_pool[2].port == 11211);
+ test_truth(server_pool[2].weight == 200);
+ test_strcmp(server_pool[7].hostname, "10.0.1.8");
+ test_truth(server_pool[7].port == 11211);
+ test_truth(server_pool[7].weight == 100);
+
+ /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
+ * us test the boundary wraparound.
+ */
+ test_truth(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->continuum[0].index);
+
+ /* verify the standard ketama set. */
+ for (x= 0; x < 99; x++)
+ {
+ uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases_spy[x].key, strlen(ketama_test_cases_spy[x].key));
+ char *hostname = memc->hosts[server_idx].hostname;
+ test_strcmp(hostname, ketama_test_cases_spy[x].server);
+ }
+
+ memcached_server_list_free(server_pool);
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t regression_bug_434484(memcached_st *memc)
+{
+ test_return_t test_rc;
+ test_rc= pre_binary(memc);
+
+ if (test_rc != TEST_SUCCESS)
+ return test_rc;
+
+ memcached_return_t ret;
+ const char *key= "regression_bug_434484";
+ size_t keylen= strlen(key);
+
+ ret= memcached_append(memc, key, keylen, key, keylen, 0, 0);
+ test_truth(ret == MEMCACHED_NOTSTORED);
+
+ size_t size= 2048 * 1024;
+ void *data= calloc(1, size);
+ test_truth(data != NULL);
+ ret= memcached_set(memc, key, keylen, data, size, 0, 0);
+ test_truth(ret == MEMCACHED_E2BIG);
+ free(data);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t regression_bug_434843(memcached_st *memc)
+{
+ test_return_t test_rc;
+ test_rc= pre_binary(memc);
+
+ if (test_rc != TEST_SUCCESS)
+ return test_rc;
+
+ memcached_return_t rc;
+ unsigned int counter= 0;
+ memcached_execute_fn callbacks[1]= { [0]= &callback_counter };
+
+ /*
+ * I only want to hit only _one_ server so I know the number of requests I'm
+ * sending in the pipleine to the server. Let's try to do a multiget of
+ * 1024 (that should satisfy most users don't you think?). Future versions
+ * will include a mget_execute function call if you need a higher number.
+ */
+ uint32_t number_of_hosts= memcached_server_count(memc);
+ memc->number_of_hosts= 1;
+ const size_t max_keys= 1024;
+ char **keys= calloc(max_keys, sizeof(char*));
+ size_t *key_length=calloc(max_keys, sizeof(size_t));
+
+ for (int x= 0; x < (int)max_keys; ++x)
+ {
+ char k[251];
+ key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%u", x);
+ keys[x]= strdup(k);
+ test_truth(keys[x] != NULL);
+ }
+
+ /*
+ * Run two times.. the first time we should have 100% cache miss,
+ * and the second time we should have 100% cache hits
+ */
+ for (int y= 0; y < 2; ++y)
+ {
+ rc= memcached_mget(memc, (const char**)keys, key_length, max_keys);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
+ if (y == 0)
+ {
+ /* The first iteration should give me a 100% cache miss. verify that*/
+ test_truth(counter == 0);
+ char blob[1024]= { 0 };
+ for (int x= 0; x < (int)max_keys; ++x)
+ {
+ rc= memcached_add(memc, keys[x], key_length[x],
+ blob, sizeof(blob), 0, 0);
+ test_truth(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ }
+ }
+ else
+ {
+ /* Verify that we received all of the key/value pairs */
+ test_truth(counter == (unsigned int)max_keys);
+ }
+ }
+
+ /* Release allocated resources */
+ for (size_t x= 0; x < max_keys; ++x)
+ free(keys[x]);
+ free(keys);
+ free(key_length);
+
+ memc->number_of_hosts= number_of_hosts;
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t regression_bug_434843_buffered(memcached_st *memc)
+{
+ memcached_return_t rc;
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
+ test_truth(rc == MEMCACHED_SUCCESS);
+
+ return regression_bug_434843(memc);
+}
+
+static test_return_t regression_bug_421108(memcached_st *memc)
+{
+ memcached_return_t rc;
+ memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc);
+ test_truth(rc == MEMCACHED_SUCCESS);
+
+ char *bytes= memcached_stat_get_value(memc, memc_stat, "bytes", &rc);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ test_truth(bytes != NULL);
+ char *bytes_read= memcached_stat_get_value(memc, memc_stat,
+ "bytes_read", &rc);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ test_truth(bytes_read != NULL);
+
+ char *bytes_written= memcached_stat_get_value(memc, memc_stat,
+ "bytes_written", &rc);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ test_truth(bytes_written != NULL);
+
+ test_truth(strcmp(bytes, bytes_read) != 0);
+ test_truth(strcmp(bytes, bytes_written) != 0);
+
+ /* Release allocated resources */
+ free(bytes);
+ free(bytes_read);
+ free(bytes_written);
+ memcached_stat_free(NULL, memc_stat);
+
+ return TEST_SUCCESS;
+}
+
+/*
+ * The test case isn't obvious so I should probably document why
+ * it works the way it does. Bug 442914 was caused by a bug
+ * in the logic in memcached_purge (it did not handle the case
+ * where the number of bytes sent was equal to the watermark).
+ * In this test case, create messages so that we hit that case
+ * and then disable noreply mode and issue a new command to
+ * verify that it isn't stuck. If we change the format for the
+ * delete command or the watermarks, we need to update this
+ * test....
+ */
+static test_return_t regression_bug_442914(memcached_st *memc)
+{
+ memcached_return_t rc;
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
+
+ uint32_t number_of_hosts= memcached_server_count(memc);
+ memc->number_of_hosts= 1;
+
+ char k[250];
+ size_t len;
+
+ for (int x= 0; x < 250; ++x)
+ {
+ len= (size_t)snprintf(k, sizeof(k), "%0250u", x);
+ rc= memcached_delete(memc, k, len, 0);
+ test_truth(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ }
+
+ len= (size_t)snprintf(k, sizeof(k), "%037u", 251);
+ rc= memcached_delete(memc, k, len, 0);
+ test_truth(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ rc= memcached_delete(memc, k, len, 0);
+ test_truth(rc == MEMCACHED_NOTFOUND);
+
+ memc->number_of_hosts= number_of_hosts;
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t regression_bug_447342(memcached_st *memc)
+{
+ if (memcached_server_count(memc) < 3 || pre_replication(memc) != MEMCACHED_SUCCESS)
+ return TEST_SKIPPED;
+
+ memcached_return_t rc;
+
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2);
+ test_truth(rc == MEMCACHED_SUCCESS);
+
+ const size_t max_keys= 100;
+ char **keys= calloc(max_keys, sizeof(char*));
+ size_t *key_length=calloc(max_keys, sizeof(size_t));
+
+ for (int x= 0; x < (int)max_keys; ++x)
+ {
+ char k[251];
+ key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%u", x);
+ keys[x]= strdup(k);
+ test_truth(keys[x] != NULL);
+ rc= memcached_set(memc, k, key_length[x], k, key_length[x], 0, 0);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ }
+
+ /*
+ ** We are using the quiet commands to store the replicas, so we need
+ ** to ensure that all of them are processed before we can continue.
+ ** In the test we go directly from storing the object to trying to
+ ** receive the object from all of the different servers, so we
+ ** could end up in a race condition (the memcached server hasn't yet
+ ** processed the quiet command from the replication set when it process
+ ** the request from the other client (created by the clone)). As a
+ ** workaround for that we call memcached_quit to send the quit command
+ ** to the server and wait for the response ;-) If you use the test code
+ ** as an example for your own code, please note that you shouldn't need
+ ** to do this ;-)
+ */
+ memcached_quit(memc);
+
+ /* Verify that all messages are stored, and we didn't stuff too much
+ * into the servers
+ */
+ rc= memcached_mget(memc, (const char* const *)keys, key_length, max_keys);
+ test_truth(rc == MEMCACHED_SUCCESS);
+
+ unsigned int counter= 0;
+ memcached_execute_fn callbacks[1]= { [0]= &callback_counter };
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
+ /* Verify that we received all of the key/value pairs */
+ test_truth(counter == (unsigned int)max_keys);
+
+ memcached_quit(memc);
+ /*
+ * Don't do the following in your code. I am abusing the internal details
+ * within the library, and this is not a supported interface.
+ * This is to verify correct behavior in the library. Fake that two servers
+ * are dead..
+ */
+ in_port_t port0= memc->hosts[0].port;
+ in_port_t port2= memc->hosts[2].port;
+
+ memc->hosts[0].port= 0;
+ memc->hosts[2].port= 0;
+
+ rc= memcached_mget(memc, (const char* const *)keys, key_length, max_keys);
+ test_truth(rc == MEMCACHED_SUCCESS);
+
+ counter= 0;
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
+ test_truth(counter == (unsigned int)max_keys);
+
+ /* restore the memc handle */
+ memc->hosts[0].port= port0;
+ memc->hosts[2].port= port2;
+
+ memcached_quit(memc);
+
+ /* Remove half of the objects */
+ for (int x= 0; x < (int)max_keys; ++x)
+ {
+ if (x & 1)
+ {
+ rc= memcached_delete(memc, keys[x], key_length[x], 0);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ }
+ }
+
+ memcached_quit(memc);
+ memc->hosts[0].port= 0;
+ memc->hosts[2].port= 0;
+
+ /* now retry the command, this time we should have cache misses */
+ rc= memcached_mget(memc, (const char* const *)keys, key_length, max_keys);
+ test_truth(rc == MEMCACHED_SUCCESS);
+
+ counter= 0;
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
+ test_truth(counter == (unsigned int)(max_keys >> 1));
+
+ /* Release allocated resources */
+ for (size_t x= 0; x < max_keys; ++x)
+ free(keys[x]);
+ free(keys);
+ free(key_length);
+
+ /* restore the memc handle */
+ memc->hosts[0].port= port0;
+ memc->hosts[2].port= port2;
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t regression_bug_463297(memcached_st *memc)
+{
+ memcached_st *memc_clone= memcached_clone(NULL, memc);
+ test_truth(memc_clone != NULL);
+ test_truth(memcached_version(memc_clone) == MEMCACHED_SUCCESS);
+
+ if (memc_clone->hosts[0].major_version > 1 ||
+ (memc_clone->hosts[0].major_version == 1 &&
+ memc_clone->hosts[0].minor_version > 2))
+ {
+ /* Binary protocol doesn't support deferred delete */
+ memcached_st *bin_clone= memcached_clone(NULL, memc);
+ test_truth(bin_clone != NULL);
+ test_truth(memcached_behavior_set(bin_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1) == MEMCACHED_SUCCESS);
+ test_truth(memcached_delete(bin_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS);
+ memcached_free(bin_clone);
+
+ memcached_quit(memc_clone);
+
+ /* If we know the server version, deferred delete should fail
+ * with invalid arguments */
+ test_truth(memcached_delete(memc_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS);
+
+ /* If we don't know the server version, we should get a protocol error */
+ memcached_return_t rc= memcached_delete(memc, "foo", 3, 1);
+
+ /* but there is a bug in some of the memcached servers (1.4) that treats
+ * the counter as noreply so it doesn't send the proper error message
+ */
+ test_truth(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR);
+
+ /* And buffered mode should be disabled and we should get protocol error */
+ test_truth(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1) == MEMCACHED_SUCCESS);
+ rc= memcached_delete(memc, "foo", 3, 1);
+ test_truth(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR);
+
+ /* Same goes for noreply... */
+ test_truth(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1) == MEMCACHED_SUCCESS);
+ rc= memcached_delete(memc, "foo", 3, 1);
+ test_truth(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR);
+
+ /* but a normal request should go through (and be buffered) */
+ test_truth((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_BUFFERED);
+ test_truth(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS);
+
+ test_truth(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0) == MEMCACHED_SUCCESS);
+ /* unbuffered noreply should be success */
+ test_truth(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_SUCCESS);
+ /* unbuffered with reply should be not found... */
+ test_truth(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0) == MEMCACHED_SUCCESS);
+ test_truth(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_NOTFOUND);
+ }
+
+ memcached_free(memc_clone);
+ return TEST_SUCCESS;
+}
+
+
+/* Test memcached_server_get_last_disconnect
+ * For a working server set, shall be NULL
+ * For a set of non existing server, shall not be NULL
+ */
+static test_return_t test_get_last_disconnect(memcached_st *memc)
+{
+ memcached_return_t rc;
+ memcached_server_st *disconnected_server;
+
+ /* With the working set of server */
+ const char *key= "marmotte";
+ const char *value= "milka";
+
+ rc= memcached_set(memc, key, strlen(key),
+ value, strlen(value),
+ (time_t)0, (uint32_t)0);
+ test_truth(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+
+ disconnected_server = memcached_server_get_last_disconnect(memc);
+ test_truth(disconnected_server == NULL);
+
+ /* With a non existing server */
+ memcached_st *mine;
+ memcached_server_st *servers;
+
+ const char *server_list= "localhost:9";
+
+ servers= memcached_servers_parse(server_list);
+ test_truth(servers);
+ mine= memcached_create(NULL);
+ rc= memcached_server_push(mine, servers);
+ test_truth(rc == MEMCACHED_SUCCESS);
+ memcached_server_list_free(servers);
+ test_truth(mine);
+
+ rc= memcached_set(mine, key, strlen(key),
+ value, strlen(value),
+ (time_t)0, (uint32_t)0);
+ test_truth(rc != MEMCACHED_SUCCESS);
+
+ disconnected_server = memcached_server_get_last_disconnect(mine);
+ test_truth(disconnected_server != NULL);
+ test_truth(disconnected_server->port == 9);
+ test_truth(strncmp(disconnected_server->hostname,"localhost",9) == 0);
+
+ memcached_quit(mine);
+ memcached_free(mine);
+
+ return TEST_SUCCESS;
+}
+
+/*
+ * This test ensures that the failure counter isn't incremented during
+ * normal termination of the memcached instance.
+ */
+static test_return_t wrong_failure_counter_test(memcached_st *memc)
+{
+ memcached_return_t rc;
+
+ /* Set value to force connection to the server */
+ const char *key= "marmotte";
+ const char *value= "milka";
+
+ /*
+ * Please note that I'm abusing the internal structures in libmemcached
+ * in a non-portable way and you shouldn't be doing this. I'm only
+ * doing this in order to verify that the library works the way it should
+ */
+ uint32_t number_of_hosts= memcached_server_count(memc);
+ memc->number_of_hosts= 1;
+
+ /* Ensure that we are connected to the server by setting a value */
+ rc= memcached_set(memc, key, strlen(key),
+ value, strlen(value),
+ (time_t)0, (uint32_t)0);
+ test_truth(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+
+
+ /* The test is to see that the memcached_quit doesn't increase the
+ * the server failure conter, so let's ensure that it is zero
+ * before sending quit
+ */
+ memc->hosts[0].server_failure_counter= 0;
+
+ memcached_quit(memc);
+
+ /* Verify that it memcached_quit didn't increment the failure counter
+ * Please note that this isn't bullet proof, because an error could
+ * occur...
+ */
+ test_truth(memc->hosts[0].server_failure_counter == 0);
+
+ /* restore the instance */
+ memc->number_of_hosts= number_of_hosts;
+
+ return TEST_SUCCESS;
+}
+
+test_st udp_setup_server_tests[] ={
+ {"set_udp_behavior_test", 0, (test_callback_fn)set_udp_behavior_test},
+ {"add_tcp_server_udp_client_test", 0, (test_callback_fn)add_tcp_server_udp_client_test},
+ {"add_udp_server_tcp_client_test", 0, (test_callback_fn)add_udp_server_tcp_client_test},
+ {0, 0, 0}
+};
+
+test_st upd_io_tests[] ={
+ {"udp_set_test", 0, (test_callback_fn)udp_set_test},
+ {"udp_buffered_set_test", 0, (test_callback_fn)udp_buffered_set_test},
+ {"udp_set_too_big_test", 0, (test_callback_fn)udp_set_too_big_test},
+ {"udp_delete_test", 0, (test_callback_fn)udp_delete_test},
+ {"udp_buffered_delete_test", 0, (test_callback_fn)udp_buffered_delete_test},
+ {"udp_verbosity_test", 0, (test_callback_fn)udp_verbosity_test},
+ {"udp_quit_test", 0, (test_callback_fn)udp_quit_test},
+ {"udp_flush_test", 0, (test_callback_fn)udp_flush_test},
+ {"udp_incr_test", 0, (test_callback_fn)udp_incr_test},
+ {"udp_decr_test", 0, (test_callback_fn)udp_decr_test},
+ {"udp_stat_test", 0, (test_callback_fn)udp_stat_test},
+ {"udp_version_test", 0, (test_callback_fn)udp_version_test},
+ {"udp_get_test", 0, (test_callback_fn)udp_get_test},
+ {"udp_mixed_io_test", 0, (test_callback_fn)udp_mixed_io_test},
+ {0, 0, 0}
+};
+
+/* Clean the server before beginning testing */
+test_st tests[] ={
+ {"flush", 0, (test_callback_fn)flush_test },
+ {"init", 0, (test_callback_fn)init_test },
+ {"allocation", 0, (test_callback_fn)allocation_test },
+ {"server_list_null_test", 0, (test_callback_fn)server_list_null_test},
+ {"server_unsort", 0, (test_callback_fn)server_unsort_test},
+ {"server_sort", 0, (test_callback_fn)server_sort_test},
+ {"server_sort2", 0, (test_callback_fn)server_sort2_test},
+ {"clone_test", 0, (test_callback_fn)clone_test },
+ {"connection_test", 0, (test_callback_fn)connection_test},
+ {"callback_test", 0, (test_callback_fn)callback_test},
+ {"userdata_test", 0, (test_callback_fn)userdata_test},
+ {"error", 0, (test_callback_fn)error_test },
+ {"set", 0, (test_callback_fn)set_test },
+ {"set2", 0, (test_callback_fn)set_test2 },
+ {"set3", 0, (test_callback_fn)set_test3 },
+ {"dump", 1, (test_callback_fn)dump_test},
+ {"add", 1, (test_callback_fn)add_test },
+ {"replace", 1, (test_callback_fn)replace_test },
+ {"delete", 1, (test_callback_fn)delete_test },
+ {"get", 1, (test_callback_fn)get_test },
+ {"get2", 0, (test_callback_fn)get_test2 },
+ {"get3", 0, (test_callback_fn)get_test3 },
+ {"get4", 0, (test_callback_fn)get_test4 },
+ {"partial mget", 0, (test_callback_fn)get_test5 },
+ {"stats_servername", 0, (test_callback_fn)stats_servername_test },
+ {"increment", 0, (test_callback_fn)increment_test },
+ {"increment_with_initial", 1, (test_callback_fn)increment_with_initial_test },
+ {"decrement", 0, (test_callback_fn)decrement_test },
+ {"decrement_with_initial", 1, (test_callback_fn)decrement_with_initial_test },
+ {"increment_by_key", 0, (test_callback_fn)increment_by_key_test },
+ {"increment_with_initial_by_key", 1, (test_callback_fn)increment_with_initial_by_key_test },
+ {"decrement_by_key", 0, (test_callback_fn)decrement_by_key_test },
+ {"decrement_with_initial_by_key", 1, (test_callback_fn)decrement_with_initial_by_key_test },
+ {"quit", 0, (test_callback_fn)quit_test },
+ {"mget", 1, (test_callback_fn)mget_test },
+ {"mget_result", 1, (test_callback_fn)mget_result_test },
+ {"mget_result_alloc", 1, (test_callback_fn)mget_result_alloc_test },
+ {"mget_result_function", 1, (test_callback_fn)mget_result_function },
+ {"mget_execute", 1, (test_callback_fn)mget_execute },
+ {"mget_end", 0, (test_callback_fn)mget_end },
+ {"get_stats", 0, (test_callback_fn)get_stats },
+ {"add_host_test", 0, (test_callback_fn)add_host_test },
+ {"add_host_test_1", 0, (test_callback_fn)add_host_test1 },
+ {"get_stats_keys", 0, (test_callback_fn)get_stats_keys },
+ {"version_string_test", 0, (test_callback_fn)version_string_test},
+ {"bad_key", 1, (test_callback_fn)bad_key_test },
+ {"memcached_server_cursor", 1, (test_callback_fn)memcached_server_cursor_test },
+ {"read_through", 1, (test_callback_fn)read_through },
+ {"delete_through", 1, (test_callback_fn)delete_through },
+ {"noreply", 1, (test_callback_fn)noreply_test},
+ {"analyzer", 1, (test_callback_fn)analyzer_test},
+#ifdef HAVE_LIBMEMCACHEDUTIL
+ {"connectionpool", 1, (test_callback_fn)connection_pool_test },
+#endif
+ {"test_get_last_disconnect", 1, (test_callback_fn)test_get_last_disconnect},
+ {0, 0, 0}
+};
+
+test_st behavior_tests[] ={
+ {"behavior_test", 0, (test_callback_fn)behavior_test},
+ {0, 0, 0}
+};
+
+test_st async_tests[] ={
+ {"add", 1, (test_callback_fn)add_wrapper },
+ {0, 0, 0}
+};
+
+test_st string_tests[] ={
+ {"string static with null", 0, (test_callback_fn)string_static_null },
+ {"string alloc with null", 0, (test_callback_fn)string_alloc_null },
+ {"string alloc with 1K", 0, (test_callback_fn)string_alloc_with_size },
+ {"string alloc with malloc failure", 0, (test_callback_fn)string_alloc_with_size_toobig },
+ {"string append", 0, (test_callback_fn)string_alloc_append },
+ {"string append failure (too big)", 0, (test_callback_fn)string_alloc_append_toobig },
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st result_tests[] ={
+ {"result static", 0, (test_callback_fn)result_static},
+ {"result alloc", 0, (test_callback_fn)result_alloc},
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st version_1_2_3[] ={
+ {"append", 0, (test_callback_fn)append_test },
+ {"prepend", 0, (test_callback_fn)prepend_test },
+ {"cas", 0, (test_callback_fn)cas_test },
+ {"cas2", 0, (test_callback_fn)cas2_test },
+ {"append_binary", 0, (test_callback_fn)append_binary_test },
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st user_tests[] ={
+ {"user_supplied_bug1", 0, (test_callback_fn)user_supplied_bug1 },
+ {"user_supplied_bug2", 0, (test_callback_fn)user_supplied_bug2 },
+ {"user_supplied_bug3", 0, (test_callback_fn)user_supplied_bug3 },
+ {"user_supplied_bug4", 0, (test_callback_fn)user_supplied_bug4 },
+ {"user_supplied_bug5", 1, (test_callback_fn)user_supplied_bug5 },
+ {"user_supplied_bug6", 1, (test_callback_fn)user_supplied_bug6 },
+ {"user_supplied_bug7", 1, (test_callback_fn)user_supplied_bug7 },
+ {"user_supplied_bug8", 1, (test_callback_fn)user_supplied_bug8 },
+ {"user_supplied_bug9", 1, (test_callback_fn)user_supplied_bug9 },
+ {"user_supplied_bug10", 1, (test_callback_fn)user_supplied_bug10 },
+ {"user_supplied_bug11", 1, (test_callback_fn)user_supplied_bug11 },
+ {"user_supplied_bug12", 1, (test_callback_fn)user_supplied_bug12 },
+ {"user_supplied_bug13", 1, (test_callback_fn)user_supplied_bug13 },
+ {"user_supplied_bug14", 1, (test_callback_fn)user_supplied_bug14 },
+ {"user_supplied_bug15", 1, (test_callback_fn)user_supplied_bug15 },
+ {"user_supplied_bug16", 1, (test_callback_fn)user_supplied_bug16 },
+#ifndef __sun
+ /*
+ ** It seems to be something weird with the character sets..
+ ** value_fetch is unable to parse the value line (iscntrl "fails"), so I
+ ** guess I need to find out how this is supposed to work.. Perhaps I need
+ ** to run the test in a specific locale (I tried zh_CN.UTF-8 without success,
+ ** so just disable the code for now...).
+ */
+ {"user_supplied_bug17", 1, (test_callback_fn)user_supplied_bug17 },
+#endif
+ {"user_supplied_bug18", 1, (test_callback_fn)user_supplied_bug18 },
+ {"user_supplied_bug19", 1, (test_callback_fn)user_supplied_bug19 },
+ {"user_supplied_bug20", 1, (test_callback_fn)user_supplied_bug20 },
+ {"user_supplied_bug21", 1, (test_callback_fn)user_supplied_bug21 },
+ {"wrong_failure_counter_test", 1, (test_callback_fn)wrong_failure_counter_test},
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st replication_tests[]= {
+ {"set", 1, (test_callback_fn)replication_set_test },
+ {"get", 0, (test_callback_fn)replication_get_test },
+ {"mget", 0, (test_callback_fn)replication_mget_test },
+ {"delete", 0, (test_callback_fn)replication_delete_test },
+ {"rand_mget", 0, (test_callback_fn)replication_randomize_mget_test },
+ {0, 0, (test_callback_fn)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, (test_callback_fn)regression_bug_434484 },
+ {"lp:434843", 1, (test_callback_fn)regression_bug_434843 },
+ {"lp:434843 buffered", 1, (test_callback_fn)regression_bug_434843_buffered },
+ {"lp:421108", 1, (test_callback_fn)regression_bug_421108 },
+ {"lp:442914", 1, (test_callback_fn)regression_bug_442914 },
+ {"lp:447342", 1, (test_callback_fn)regression_bug_447342 },
+ {"lp:463297", 1, (test_callback_fn)regression_bug_463297 },
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st ketama_compatibility[]= {
+ {"libmemcached", 1, (test_callback_fn)ketama_compatibility_libmemcached },
+ {"spymemcached", 1, (test_callback_fn)ketama_compatibility_spymemcached },
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st generate_tests[] ={
+ {"generate_pairs", 1, (test_callback_fn)generate_pairs },
+ {"generate_data", 1, (test_callback_fn)generate_data },
+ {"get_read", 0, (test_callback_fn)get_read },
+ {"delete_generate", 0, (test_callback_fn)delete_generate },
+ {"generate_buffer_data", 1, (test_callback_fn)generate_buffer_data },
+ {"delete_buffer", 0, (test_callback_fn)delete_buffer_generate},
+ {"generate_data", 1, (test_callback_fn)generate_data },
+ {"mget_read", 0, (test_callback_fn)mget_read },
+ {"mget_read_result", 0, (test_callback_fn)mget_read_result },
+ {"mget_read_function", 0, (test_callback_fn)mget_read_function },
+ {"cleanup", 1, (test_callback_fn)cleanup_pairs },
+ {"generate_large_pairs", 1, (test_callback_fn)generate_large_pairs },
+ {"generate_data", 1, (test_callback_fn)generate_data },
+ {"generate_buffer_data", 1, (test_callback_fn)generate_buffer_data },
+ {"cleanup", 1, (test_callback_fn)cleanup_pairs },
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st consistent_tests[] ={
+ {"generate_pairs", 1, (test_callback_fn)generate_pairs },
+ {"generate_data", 1, (test_callback_fn)generate_data },
+ {"get_read", 0, (test_callback_fn)get_read_count },
+ {"cleanup", 1, (test_callback_fn)cleanup_pairs },
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st consistent_weighted_tests[] ={
+ {"generate_pairs", 1, (test_callback_fn)generate_pairs },
+ {"generate_data", 1, (test_callback_fn)generate_data_with_stats },
+ {"get_read", 0, (test_callback_fn)get_read_count },
+ {"cleanup", 1, (test_callback_fn)cleanup_pairs },
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st hsieh_availability[] ={
+ {"hsieh_avaibility_test", 0, (test_callback_fn)hsieh_avaibility_test},
+ {0, 0, (test_callback_fn)0}
+};
+
+#if 0
+test_st hash_sanity[] ={
+ {"hash sanity", 0, (test_callback_fn)hash_sanity_test},
+ {0, 0, (test_callback_fn)0}
+};
+#endif
+
+test_st ketama_auto_eject_hosts[] ={
+ {"auto_eject_hosts", 1, (test_callback_fn)auto_eject_hosts },
+ {"output_ketama_weighted_keys", 1, (test_callback_fn)output_ketama_weighted_keys },
+ {0, 0, (test_callback_fn)0}
+};
+
+test_st hash_tests[] ={
+ {"md5", 0, (test_callback_fn)md5_run },
+ {"crc", 0, (test_callback_fn)crc_run },
+ {"fnv1_64", 0, (test_callback_fn)fnv1_64_run },
+ {"fnv1a_64", 0, (test_callback_fn)fnv1a_64_run },
+ {"fnv1_32", 0, (test_callback_fn)fnv1_32_run },
+ {"fnv1a_32", 0, (test_callback_fn)fnv1a_32_run },
+ {"hsieh", 0, (test_callback_fn)hsieh_run },
+ {"murmur", 0, (test_callback_fn)murmur_run },
+ {"jenkis", 0, (test_callback_fn)jenkins_run },
+ {0, 0, (test_callback_fn)0}
+};
+
+collection_st collection[] ={
+#if 0
+ {"hash_sanity", 0, 0, hash_sanity},
+#endif
+ {"hsieh_availability", 0, 0, hsieh_availability},
+ {"udp_setup", (test_callback_fn)init_udp, 0, udp_setup_server_tests},
+ {"udp_io", (test_callback_fn)init_udp, 0, upd_io_tests},
+ {"udp_binary_io", (test_callback_fn)binary_init_udp, 0, upd_io_tests},
+ {"block", 0, 0, tests},
+ {"binary", (test_callback_fn)pre_binary, 0, tests},
+ {"nonblock", (test_callback_fn)pre_nonblock, 0, tests},
+ {"nodelay", (test_callback_fn)pre_nodelay, 0, tests},
+ {"settimer", (test_callback_fn)pre_settimer, 0, tests},
+ {"md5", (test_callback_fn)pre_md5, 0, tests},
+ {"crc", (test_callback_fn)pre_crc, 0, tests},
+ {"hsieh", (test_callback_fn)pre_hsieh, 0, tests},
+ {"jenkins", (test_callback_fn)pre_jenkins, 0, tests},
+ {"fnv1_64", (test_callback_fn)pre_hash_fnv1_64, 0, tests},
+ {"fnv1a_64", (test_callback_fn)pre_hash_fnv1a_64, 0, tests},
+ {"fnv1_32", (test_callback_fn)pre_hash_fnv1_32, 0, tests},
+ {"fnv1a_32", (test_callback_fn)pre_hash_fnv1a_32, 0, tests},
+ {"ketama", (test_callback_fn)pre_behavior_ketama, 0, tests},
+ {"ketama_auto_eject_hosts", (test_callback_fn)pre_behavior_ketama, 0, ketama_auto_eject_hosts},
+ {"unix_socket", (test_callback_fn)pre_unix_socket, 0, tests},
+ {"unix_socket_nodelay", (test_callback_fn)pre_nodelay, 0, tests},
+ {"poll_timeout", (test_callback_fn)poll_timeout, 0, tests},
+ {"gets", (test_callback_fn)enable_cas, 0, tests},
+ {"consistent_crc", (test_callback_fn)enable_consistent_crc, 0, tests},
+ {"consistent_hsieh", (test_callback_fn)enable_consistent_hsieh, 0, tests},
+#ifdef MEMCACHED_ENABLE_DEPRECATED
+ {"deprecated_memory_allocators", (test_callback_fn)deprecated_set_memory_alloc, 0, tests},
+#endif
+ {"memory_allocators", (test_callback_fn)set_memory_alloc, 0, tests},
+ {"prefix", (test_callback_fn)set_prefix, 0, tests},
+ {"version_1_2_3", (test_callback_fn)check_for_1_2_3, 0, version_1_2_3},
+ {"string", 0, 0, string_tests},
+ {"result", 0, 0, result_tests},
+ {"async", (test_callback_fn)pre_nonblock, 0, async_tests},
+ {"async_binary", (test_callback_fn)pre_nonblock_binary, 0, async_tests},
+ {"user", 0, 0, user_tests},
+ {"generate", 0, 0, generate_tests},
+ {"generate_hsieh", (test_callback_fn)pre_hsieh, 0, generate_tests},
+ {"generate_ketama", (test_callback_fn)pre_behavior_ketama, 0, generate_tests},
+ {"generate_hsieh_consistent", (test_callback_fn)enable_consistent_hsieh, 0, generate_tests},
+ {"generate_md5", (test_callback_fn)pre_md5, 0, generate_tests},
+ {"generate_murmur", (test_callback_fn)pre_murmur, 0, generate_tests},
+ {"generate_jenkins", (test_callback_fn)pre_jenkins, 0, generate_tests},
+ {"generate_nonblock", (test_callback_fn)pre_nonblock, 0, generate_tests},
+ {"consistent_not", 0, 0, consistent_tests},
+ {"consistent_ketama", (test_callback_fn)pre_behavior_ketama, 0, consistent_tests},
+ {"consistent_ketama_weighted", (test_callback_fn)pre_behavior_ketama_weighted, 0, consistent_weighted_tests},
+ {"ketama_compat", 0, 0, ketama_compatibility},
+ {"test_hashes", 0, 0, hash_tests},
+ {"replication", (test_callback_fn)pre_replication, 0, replication_tests},
+ {"replication_noblock", (test_callback_fn)pre_replication_noblock, 0, replication_tests},
+ {"regression", 0, 0, regression_tests},
+ {"behaviors", 0, 0, behavior_tests},
+ {0, 0, 0, 0}
+};
+
+#define SERVERS_TO_CREATE 5
+
+#include "libmemcached_world.h"
+