From: Brian Aker Date: Thu, 18 Oct 2007 04:01:10 +0000 (-0700) Subject: Test from Cal (get to go along with his set) X-Git-Tag: 0_7~22 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=42b9680b5b30ed08c47dd7f56b57b714f25446cc;p=m6w6%2Flibmemcached Test from Cal (get to go along with his set) --- diff --git a/tests/test.c b/tests/test.c index 16afb65e..3a8c3657 100644 --- a/tests/test.c +++ b/tests/test.c @@ -511,7 +511,7 @@ void user_supplied_bug1(memcached_st *memc) unsigned int setter= 1; unsigned int x; - long total= 0; + unsigned long long total= 0; int size= 0; srand(time(NULL)); char key[10]; @@ -547,6 +547,56 @@ void user_supplied_bug1(memcached_st *memc) assert(rc == MEMCACHED_SUCCESS); } } + +/* Test case provided by Cal Haldenbrand */ +void user_supplied_bug2(memcached_st *memc) +{ + int errors; + unsigned int setter; + unsigned int x; + unsigned long long total; + + + setter= 1; + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, &setter); + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, &setter); +#ifdef NOT_YET + setter = 20 * 1024576; + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, &setter); + setter = 20 * 1024576; + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, &setter); + getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE); + getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE); +#endif + + for (x= 0, errors= 0, total= 0 ; total < 20 * 1024576 ; x++) + { + memcached_return rc; + char buffer[SMALL_STRING_LEN]; + uint16_t flags; + size_t val_len; + char *getval; + + snprintf(buffer, SMALL_STRING_LEN, "%u", x); + getval= memcached_get(memc, buffer, strlen(buffer), + &val_len, &flags, &rc); + if (rc != MEMCACHED_SUCCESS) + { + WATCHPOINT_ERROR(rc); + errors++; + if ( errors == 10 ) + { + fprintf(stderr, "last: %s: len %zu flags: %u\n", buffer, val_len, flags); + assert(0); + } + continue; + } + total+= val_len; + errors= 0; + free(getval); + } +} + void add_host_test1(memcached_st *memc) { unsigned int x; @@ -648,6 +698,7 @@ int main(int argc, char *argv[]) test_st user_tests[] ={ {"user_supplied_bug1", 0, user_supplied_bug1 }, + {"user_supplied_bug2", 0, user_supplied_bug1 }, {0, 0, 0} };