From 137a6414386ce392447905dab6d11d629a1b381b Mon Sep 17 00:00:00 2001 From: Date: Thu, 8 Nov 2007 20:10:42 -0800 Subject: [PATCH] More tests. --- tests/Makefile.am | 2 +- tests/function.c | 107 +++++++++++++++++++++++++++++++++++++++++++++- tests/output.res | 106 --------------------------------------------- 3 files changed, 106 insertions(+), 109 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 903eb0ca..dc84803e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,7 +18,7 @@ LIBS = noinst_HEADERS = test.h noinst_PROGRAMS = testapp -testapp_SOURCES = test.c function.c +testapp_SOURCES = test.c function.c ../src/generator.c ../src/execute.c testapp_LDADD = $(LDADDS) record: diff --git a/tests/function.c b/tests/function.c index bbefafc7..fb21db56 100644 --- a/tests/function.c +++ b/tests/function.c @@ -12,9 +12,16 @@ #include #include #include "../lib/common.h" +#include "../src/generator.h" +#include "../src/execute.h" #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) { memcached_st memc; @@ -426,9 +433,7 @@ void mget_result_test(memcached_st *memc) memcached_result_length(results))); } - WATCHPOINT; memcached_result_free(&results_obj); - WATCHPOINT; } void mget_result_alloc_test(memcached_st *memc) @@ -906,6 +911,95 @@ void string_alloc_append_toobig(memcached_st *memc) memcached_string_free(string); } +void 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; + } +} + +void 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); + } + } +} + +void 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); + } + } +} + +void 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); + } +} + +void free_data(memcached_st *memc) +{ + pairs_free(global_pairs); +} + void add_host_test1(memcached_st *memc) { unsigned int x; @@ -1079,6 +1173,14 @@ test_st user_tests[] ={ {0, 0, 0} }; +test_st generate_tests[] ={ + {"generate_data", 0, generate_data }, + {"get_read", 0, get_read }, + {"mget_read", 0, mget_read }, + {"mget_read_result", 0, mget_read_result }, + {0, 0, 0} +}; + collection_st collection[] ={ {"block", 0, 0, tests}, @@ -1096,6 +1198,7 @@ collection_st collection[] ={ {"string", 0, 0, string_tests}, {"result", 0, 0, result_tests}, {"user", 0, 0, user_tests}, + {"generate", 0, 0, generate_tests}, {0, 0, 0, 0} }; diff --git a/tests/output.res b/tests/output.res index f9dcc0fc..c7b64b5c 100644 --- a/tests/output.res +++ b/tests/output.res @@ -1167,109 +1167,3 @@ Found key bytes_read Found key bytes_written Found key limit_maxbytes Found key threads -Error 0 -> SUCCESS -Error 1 -> FAILURE -Error 2 -> HOSTNAME LOOKUP FAILURE -Error 3 -> CONNECTION FAILURE -Error 4 -> CONNECTION BIND FAILURE -Error 5 -> WRITE FAILURE -Error 6 -> READ FAILURE -Error 7 -> UNKNOWN READ FAILURE -Error 8 -> PROTOCOL ERROR -Error 9 -> CLIENT ERROR -Error 10 -> SERVER ERROR -Error 11 -> CONNECTION SOCKET CREATE FAILURE -Error 12 -> CONNECTION DATA EXISTS -Error 13 -> CONNECTION DATA DOES NOT EXIST -Error 14 -> NOT STORED -Error 15 -> STORED -Error 16 -> NOT FOUND -Error 17 -> MEMORY ALLOCATION FAILURE -Error 18 -> PARTIAL READ -Error 19 -> SOME ERRORS WERE REPORTED -Error 20 -> NO SERVERS DEFINED -Error 21 -> SERVER END -Error 22 -> SERVER DELETE -Error 23 -> SERVER VALUE -Error 24 -> STAT VALUE -Error 25 -> SYSTEM ERROR -Error 26 -> COULD NOT OPEN UNIX SOCKET -Error 27 -> ACTION NOT SUPPORTED -Found key pid -Found key uptime -Found key time -Found key version -Found key pointer_size -Found key rusage_user -Found key rusage_system -Found key rusage_user_seconds -Found key rusage_user_microseconds -Found key rusage_system_seconds -Found key rusage_system_microseconds -Found key curr_items -Found key total_items -Found key bytes -Found key curr_connections -Found key total_connections -Found key connection_structures -Found key cmd_get -Found key cmd_set -Found key get_hits -Found key get_misses -Found key evictions -Found key bytes_read -Found key bytes_written -Found key limit_maxbytes -Found key threads -Found key pid -Found key uptime -Found key time -Found key version -Found key pointer_size -Found key rusage_user -Found key rusage_system -Found key rusage_user_seconds -Found key rusage_user_microseconds -Found key rusage_system_seconds -Found key rusage_system_microseconds -Found key curr_items -Found key total_items -Found key bytes -Found key curr_connections -Found key total_connections -Found key connection_structures -Found key cmd_get -Found key cmd_set -Found key get_hits -Found key get_misses -Found key evictions -Found key bytes_read -Found key bytes_written -Found key limit_maxbytes -Found key threads -Found key pid -Found key uptime -Found key time -Found key version -Found key pointer_size -Found key rusage_user -Found key rusage_system -Found key rusage_user_seconds -Found key rusage_user_microseconds -Found key rusage_system_seconds -Found key rusage_system_microseconds -Found key curr_items -Found key total_items -Found key bytes -Found key curr_connections -Found key total_connections -Found key connection_structures -Found key cmd_get -Found key cmd_set -Found key get_hits -Found key get_misses -Found key evictions -Found key bytes_read -Found key bytes_written -Found key limit_maxbytes -Found key threads -- 2.30.2