From: Brian Aker Date: Fri, 9 Nov 2007 08:57:23 +0000 (-0800) Subject: Merged in new generate tests. X-Git-Tag: 0.10~24 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c119fcae0b2be6b079fa20a661146b108755399c;p=m6w6%2Flibmemcached Merged in new generate tests. --- c119fcae0b2be6b079fa20a661146b108755399c diff --cc tests/function.c index 72694b40,fb21db56..16c75073 --- a/tests/function.c +++ b/tests/function.c @@@ -15,7 -17,12 +17,12 @@@ #include "test.h" + #define GLOBAL_COUNT 100000 + static pairs_st *global_pairs; + static char *global_keys[GLOBAL_COUNT]; + static size_t global_keys_length[GLOBAL_COUNT]; + -void init_test(memcached_st *not_used) +uint8_t init_test(memcached_st *not_used) { memcached_st memc; @@@ -466,14 -433,10 +473,12 @@@ uint8_t mget_result_test(memcached_st * memcached_result_length(results))); } - WATCHPOINT; memcached_result_free(&results_obj); - WATCHPOINT; + + return 0; } -void mget_result_alloc_test(memcached_st *memc) +uint8_t mget_result_alloc_test(memcached_st *memc) { memcached_return rc; char *keys[]= {"fudge", "son", "food"}; @@@ -978,11 -909,98 +983,110 @@@ uint8_t string_alloc_append_toobig(memc rc= memcached_string_append(string, buffer, INT64_MAX); assert(rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE); memcached_string_free(string); + + return 0; } -void generate_data(memcached_st *memc) ++uint8_t generate_data(memcached_st *memc) + { + unsigned long long x; + global_pairs= pairs_generate(GLOBAL_COUNT); + execute_set(memc, global_pairs, GLOBAL_COUNT); + + for (x= 0; x < GLOBAL_COUNT; x++) + { + global_keys[x]= global_pairs[x].key; + global_keys_length[x]= global_pairs[x].key_length; + } ++ ++ return 0; + } + -void get_read(memcached_st *memc) ++uint8_t get_read(memcached_st *memc) + { + unsigned int x; + memcached_return rc; + + { + char *return_value; + size_t return_value_length; + uint16_t flags; + + for (x= 0; x < GLOBAL_COUNT; x++) + { + return_value= memcached_get(memc, global_keys[x], global_keys_length[x], + &return_value_length, &flags, &rc); + /* + assert(return_value); + assert(rc == MEMCACHED_SUCCESS); + */ + if (rc == MEMCACHED_SUCCESS && return_value) + free(return_value); + } + } ++ ++ return 0; + } + -void mget_read(memcached_st *memc) ++uint8_t mget_read(memcached_st *memc) + { + memcached_return rc; + + rc= memcached_mget(memc, global_keys, global_keys_length, GLOBAL_COUNT); + assert(rc == MEMCACHED_SUCCESS); + /* Turn this into a help function */ + { + char return_key[MEMCACHED_MAX_KEY]; + size_t return_key_length; + char *return_value; + size_t return_value_length; + uint16_t flags; + + while ((return_value= memcached_fetch(memc, return_key, &return_key_length, + &return_value_length, &flags, &rc))) + { + assert(return_value); + assert(rc == MEMCACHED_SUCCESS); + free(return_value); + } + } ++ ++ return 0; + } + -void mget_read_result(memcached_st *memc) ++uint8_t mget_read_result(memcached_st *memc) + { + memcached_return rc; + + rc= memcached_mget(memc, global_keys, global_keys_length, GLOBAL_COUNT); + assert(rc == MEMCACHED_SUCCESS); + /* Turn this into a help function */ + { + memcached_result_st results_obj; + memcached_result_st *results; + + results= memcached_result_create(memc, &results_obj); + + while ((results= memcached_fetch_result(memc, &results_obj, &rc))) + { + assert(results); + assert(rc == MEMCACHED_SUCCESS); + } + + memcached_result_free(&results_obj); + } ++ ++ return 0; + } + -void free_data(memcached_st *memc) ++uint8_t free_data(memcached_st *memc) + { + pairs_free(global_pairs); ++ ++ return 0; + } + -void add_host_test1(memcached_st *memc) +uint8_t add_host_test1(memcached_st *memc) { unsigned int x; memcached_return rc;