X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fmem_functions.c;h=14550dcbf8e7445814779939aaae1a63ed28b114;hb=a6d18834a85d2a65caae820ee426169af5aff800;hp=dbf50797a48d8dff6c265e94b940aa1e327e1949;hpb=addf09c6f6cf93f980f3de9cf649258c965b2934;p=m6w6%2Flibmemcached diff --git a/tests/mem_functions.c b/tests/mem_functions.c index dbf50797..14550dcb 100644 --- a/tests/mem_functions.c +++ b/tests/mem_functions.c @@ -230,10 +230,13 @@ static test_return_t clone_test(memcached_st *memc) 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); @@ -329,16 +332,21 @@ static test_return_t error_test(memcached_st *memc) 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); } @@ -470,7 +478,7 @@ static test_return_t cas2_test(memcached_st *memc) 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)); @@ -1693,7 +1701,6 @@ static test_return_t version_string_test(memcached_st *memc __attribute__((unuse static test_return_t get_stats(memcached_st *memc) { - unsigned int x; char **stat_list; char **ptr; memcached_return_t rc; @@ -1705,7 +1712,7 @@ static test_return_t get_stats(memcached_st *memc) 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); @@ -3616,8 +3623,9 @@ static test_return_t pre_replication_noblock(memcached_st *memc) } -static void my_free(const 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); @@ -3627,8 +3635,9 @@ static void my_free(const memcached_st *ptr __attribute__((unused)), void *mem) } -static void *my_malloc(const 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) @@ -3648,8 +3657,9 @@ static void *my_malloc(const memcached_st *ptr __attribute__((unused)), const si } -static void *my_realloc(const 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); @@ -3667,8 +3677,9 @@ static void *my_realloc(const memcached_st *ptr __attribute__((unused)), void *m } -static void *my_calloc(const 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) @@ -3806,11 +3817,11 @@ static test_return_t set_memory_alloc(memcached_st *memc) { 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;