#define TEST_PORT_COUNT 7
in_port_t test_ports[TEST_PORT_COUNT];
-static memcached_return_t server_display_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context)
+static memcached_return_t server_display_function(const memcached_st *ptr __attribute__((unused)),
+ memcached_server_st *server, void *context)
{
/* Do Nothing */
size_t bigger= *((size_t *)(context));
return TEST_SUCCESS;
}
-static memcached_return_t server_display_unsort_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context)
+static memcached_return_t server_display_unsort_function(const memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context)
{
/* Do Nothing */
uint32_t x= *((uint32_t *)(context));
memc_clone= memcached_clone(NULL, memc);
test_true(memc_clone);
- test_true(memc_clone->call_free == memc->call_free);
- test_true(memc_clone->call_malloc == memc->call_malloc);
- test_true(memc_clone->call_realloc == memc->call_realloc);
- test_true(memc_clone->call_calloc == memc->call_calloc);
+ { // Test allocators
+ test_true(memc_clone->allocators.free == memc->allocators.free);
+ test_true(memc_clone->allocators.malloc == memc->allocators.malloc);
+ test_true(memc_clone->allocators.realloc == memc->allocators.realloc);
+ test_true(memc_clone->allocators.calloc == memc->allocators.calloc);
+ }
+
test_true(memc_clone->connect_timeout == memc->connect_timeout);
test_true(memc_clone->delete_trigger == memc->delete_trigger);
test_true(memc_clone->distribution == memc->distribution);
4269430871U, 610793021U, 527273862U, 1437122909U,
2300930706U, 2943759320U, 674306647U, 2400528935U,
54481931U, 4186304426U, 1741088401U, 2979625118U,
- 4159057246U, 3425930182U, 2593724503U};
+ 4159057246U, 3425930182U, 2593724503U, 1868899624U};
// You have updated the memcache_error messages but not updated docs/tests.
- test_true(MEMCACHED_MAXIMUM_RETURN == 39);
+ test_true(MEMCACHED_MAXIMUM_RETURN == 40);
for (rc= MEMCACHED_SUCCESS; rc < MEMCACHED_MAXIMUM_RETURN; rc++)
{
uint32_t hash_val;
const char *msg= memcached_strerror(memc, rc);
hash_val= memcached_generate_hash_value(msg, strlen(msg),
MEMCACHED_HASH_JENKINS);
+ if (values[rc] != hash_val)
+ {
+ fprintf(stderr, "\n\nYou have updated memcached_return_t without updating the error_test\n");
+ fprintf(stderr, "%u, %s, (%u)\n\n", (uint32_t)rc, memcached_strerror(memc, rc), hash_val);
+ }
test_true(values[rc] == hash_val);
}
results= memcached_fetch_result(memc, &results_obj, &rc);
test_true(results);
- test_true(results->cas);
+ test_true(results->item_cas);
test_true(rc == MEMCACHED_SUCCESS);
test_true(memcached_result_cas(results));
return TEST_SUCCESS;
}
-static memcached_return_t server_function(memcached_st *ptr __attribute__((unused)),
+static memcached_return_t server_function(const memcached_st *ptr __attribute__((unused)),
memcached_server_st *server __attribute__((unused)),
void *context __attribute__((unused)))
{
}
/* Count the results */
-static memcached_return_t callback_counter(memcached_st *ptr __attribute__((unused)),
+static memcached_return_t callback_counter(const memcached_st *ptr __attribute__((unused)),
memcached_result_st *result __attribute__((unused)),
void *context)
{
static test_return_t get_stats(memcached_st *memc)
{
- unsigned int x;
char **stat_list;
char **ptr;
memcached_return_t rc;
test_true(rc == MEMCACHED_SUCCESS);
test_true(memc_stat);
- for (x= 0; x < memcached_server_count(memc); x++)
+ for (uint32_t x= 0; x < memcached_server_count(memc); x++)
{
stat_list= memcached_stat_get_keys(memc, memc_stat+x, &rc);
test_true(rc == MEMCACHED_SUCCESS);
}
-static void my_free(memcached_st *ptr __attribute__((unused)), void *mem)
+static void my_free(const memcached_st *ptr __attribute__((unused)), void *mem, void *context)
{
+ (void) context;
#ifdef HARD_MALLOC_TESTS
void *real_ptr= (mem == NULL) ? mem : (void*)((caddr_t)mem - 8);
free(real_ptr);
}
-static void *my_malloc(memcached_st *ptr __attribute__((unused)), const size_t size)
+static void *my_malloc(const memcached_st *ptr __attribute__((unused)), const size_t size, void *context)
{
+ (void)context;
#ifdef HARD_MALLOC_TESTS
void *ret= malloc(size + 8);
if (ret != NULL)
}
-static void *my_realloc(memcached_st *ptr __attribute__((unused)), void *mem, const size_t size)
+static void *my_realloc(const memcached_st *ptr __attribute__((unused)), void *mem, const size_t size, void *context)
{
+ (void)context;
#ifdef HARD_MALLOC_TESTS
void *real_ptr= (mem == NULL) ? NULL : (void*)((caddr_t)mem - 8);
void *nmem= realloc(real_ptr, size + 8);
}
-static void *my_calloc(memcached_st *ptr __attribute__((unused)), size_t nelem, const size_t size)
+static void *my_calloc(const memcached_st *ptr __attribute__((unused)), size_t nelem, const size_t size, void *context)
{
+ (void)context;
#ifdef HARD_MALLOC_TESTS
void *mem= my_malloc(ptr, nelem * size);
if (mem)
{
memcached_return_t rc;
rc= memcached_set_memory_allocators(memc, NULL, my_free,
- my_realloc, my_calloc);
+ my_realloc, my_calloc, NULL);
test_true(rc == MEMCACHED_FAILURE);
rc= memcached_set_memory_allocators(memc, my_malloc, my_free,
- my_realloc, my_calloc);
+ my_realloc, my_calloc, NULL);
memcached_malloc_fn mem_malloc;
memcached_free_fn mem_free;
}
/* Count the objects */
-static memcached_return_t callback_dump_counter(memcached_st *ptr __attribute__((unused)),
- const char *key __attribute__((unused)),
- size_t key_length __attribute__((unused)),
- void *context)
+static memcached_return_t callback_dump_counter(const memcached_st *ptr __attribute__((unused)),
+ const char *key __attribute__((unused)),
+ size_t key_length __attribute__((unused)),
+ void *context)
{
size_t *counter= (size_t *)context;
expected_rc= MEMCACHED_SUCCESS;
#endif
memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH,
- (uint64_t)MEMCACHED_HASH_HSIEH);
+ (uint64_t)MEMCACHED_HASH_HSIEH);
test_true(rc == expected_rc);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t one_at_a_time_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_DEFAULT);
+ test_true(one_at_a_time_values[x] == hash_val);
+ }
+
return TEST_SUCCESS;
}
};
test_st hash_tests[] ={
+ {"one_at_a_time_run", 0, (test_callback_fn)one_at_a_time_run },
{"md5", 0, (test_callback_fn)md5_run },
{"crc", 0, (test_callback_fn)crc_run },
{"fnv1_64", 0, (test_callback_fn)fnv1_64_run },