From: Brian Aker Date: Thu, 10 Feb 2011 22:05:26 +0000 (-0800) Subject: Updating test case such that we output version information and correctly set X-Git-Tag: 0.51~45^2~6 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2842294a80328b5729cde780f0b6e6a3c9863e7d;p=awesomized%2Flibmemcached Updating test case such that we output version information and correctly set it to zero in cases where we fail at retrieving it. --- diff --git a/libmemcached/util/version.c b/libmemcached/util/version.c index 7c936c71..bf9d0c6c 100644 --- a/libmemcached/util/version.c +++ b/libmemcached/util/version.c @@ -47,10 +47,12 @@ bool libmemcached_util_version_check(memcached_st *memc, uint8_t micro_version) { memcached_server_fn callbacks[1]; - memcached_version(memc); + memcached_return_t rc= memcached_version(memc); + + if (rc != MEMCACHED_SUCCESS) + return false; struct local_context check= { .major_version= major_version, .minor_version= minor_version, .micro_version= micro_version, .truth= true }; - memcached_version(memc); callbacks[0]= check_server_version; memcached_server_cursor(memc, callbacks, (void *)&check, 1); diff --git a/libmemcached/version.c b/libmemcached/version.c index 54545cb9..dde59066 100644 --- a/libmemcached/version.c +++ b/libmemcached/version.c @@ -48,6 +48,7 @@ static inline memcached_return_t memcached_version_textual(memcached_st *ptr) rrc= memcached_do(instance, command, send_length, true); if (rrc != MEMCACHED_SUCCESS) { + instance->major_version= instance->minor_version= instance->micro_version= 0; rc= MEMCACHED_SOME_ERRORS; continue; } @@ -55,6 +56,7 @@ static inline memcached_return_t memcached_version_textual(memcached_st *ptr) rrc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); if (rrc != MEMCACHED_SUCCESS) { + instance->major_version= instance->minor_version= instance->micro_version= 0; rc= MEMCACHED_SOME_ERRORS; continue; } @@ -64,12 +66,33 @@ static inline memcached_return_t memcached_version_textual(memcached_st *ptr) response_ptr++; instance->major_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10); + if (errno == ERANGE) + { + instance->major_version= instance->minor_version= instance->micro_version= 0; + rc= MEMCACHED_SOME_ERRORS; + continue; + } + response_ptr= index(response_ptr, '.'); response_ptr++; + instance->minor_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10); + if (errno == ERANGE) + { + instance->major_version= instance->minor_version= instance->micro_version= 0; + rc= MEMCACHED_SOME_ERRORS; + continue; + } + response_ptr= index(response_ptr, '.'); response_ptr++; instance->micro_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10); + if (errno == ERANGE) + { + instance->major_version= instance->minor_version= instance->micro_version= 0; + rc= MEMCACHED_SOME_ERRORS; + continue; + } } return rc; diff --git a/tests/mem_functions.c b/tests/mem_functions.c index 38a3b0fa..27cac75e 100644 --- a/tests/mem_functions.c +++ b/tests/mem_functions.c @@ -4439,6 +4439,8 @@ static test_return_t util_version_test(memcached_st *memc) // if (! if_successful) { + fprintf(stderr, "\n----------------------------------------------------------------------\n"); + fprintf(stderr, "\nDumping Server Information\n"); memcached_server_fn callbacks[1]; memcached_version(memc); @@ -4446,6 +4448,7 @@ static test_return_t util_version_test(memcached_st *memc) callbacks[0]= dump_server_information; memcached_server_cursor(memc, callbacks, (void *)stderr, 1); + fprintf(stderr, "\n----------------------------------------------------------------------\n"); } test_true(if_successful == false);