#include <libtest/server.h>
#include "clients/generator.h"
-#include "clients/execute.h"
#define SMALL_STRING_LEN 1024
#include "tests/ketama.h"
#include "tests/namespace.h"
#include "tests/parser.h"
+#include "tests/libmemcached-1.0/callback_counter.h"
#include "tests/libmemcached-1.0/dump.h"
+#include "tests/libmemcached-1.0/fetch_all_results.h"
+#include "tests/libmemcached-1.0/generate.h"
+#include "tests/libmemcached-1.0/haldenbrand.h"
#include "tests/libmemcached-1.0/stat.h"
#include "tests/touch.h"
#include "tests/callbacks.h"
#include "tests/hash_results.h"
-#define GLOBAL_COUNT 10000
-#define GLOBAL2_COUNT 100
-#define SERVERS_TO_CREATE 5
-static uint32_t global_count= GLOBAL2_COUNT;
+#include "tests/libmemcached-1.0/servers_to_create.h"
-static pairs_st *global_pairs;
-static const char *global_keys[GLOBAL_COUNT];
-static size_t global_keys_length[GLOBAL_COUNT];
+#define UUID_STRING_MAXLENGTH 36
+
+struct keys_st {
+public:
+ keys_st(size_t arg)
+ {
+ init(arg, UUID_STRING_MAXLENGTH);
+ }
+
+ keys_st(size_t arg, size_t padding)
+ {
+ init(arg, padding);
+ }
+
+ void init(size_t arg, size_t padding)
+ {
+ _lengths.resize(arg);
+ _keys.resize(arg);
+
+ for (size_t x= 0; x < _keys.size(); x++)
+ {
+ libtest::vchar_t key_buffer;
+ key_buffer.resize(padding +1);
+ memset(&key_buffer[0], 'x', padding);
+
+ if (HAVE_LIBUUID)
+ {
+ uuid_t out;
+ uuid_generate(out);
+
+ uuid_unparse(out, &key_buffer[0]);
+ _keys[x]= strdup(&key_buffer[0]);
+ (_keys[x])[UUID_STRING_MAXLENGTH]= 'x';
+ }
+ else // We just use a number and pad the string if UUID is not available
+ {
+ char int_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
+ int key_length= snprintf(int_buffer, sizeof(int_buffer), "%u", uint32_t(x));
+ memcpy(&key_buffer[0], int_buffer, key_length);
+ _keys[x]= strdup(&key_buffer[0]);
+ }
+ _lengths[x]= padding;
+ }
+ }
+
+ ~keys_st()
+ {
+ for (libtest::vchar_ptr_t::iterator iter= _keys.begin();
+ iter != _keys.end();
+ iter++)
+ {
+ ::free(*iter);
+ }
+ }
+
+ libtest::vchar_ptr_t::iterator begin()
+ {
+ return _keys.begin();
+ }
+
+ libtest::vchar_ptr_t::iterator end()
+ {
+ return _keys.end();
+ }
+
+ size_t size() const
+ {
+ return _keys.size();
+ }
+
+ std::vector<size_t>& lengths()
+ {
+ return _lengths;
+ }
+
+ libtest::vchar_ptr_t& keys()
+ {
+ return _keys;
+ }
+
+ size_t* lengths_ptr()
+ {
+ return &_lengths[0];
+ }
+
+ char** keys_ptr()
+ {
+ return &_keys[0];
+ }
+
+ char* key_at(size_t arg)
+ {
+ return _keys[arg];
+ }
+
+ size_t length_at(size_t arg)
+ {
+ return _lengths[arg];
+ }
+
+private:
+ libtest::vchar_ptr_t _keys;
+ std::vector<size_t> _lengths;
+};
/**
@note This should be testing to see if the server really supports the binary protocol.
static test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc)
{
- test_skip(true, HAVE_LIBUUID);
-
- std::vector<size_t> key_lengths;
- key_lengths.resize(200);
- std::vector<char *> keys;
- keys.resize(key_lengths.size());
+ keys_st keys(200);
- for (size_t x= 0; x < keys.size(); x++)
- {
- if (HAVE_LIBUUID)
- {
- uuid_t out;
- uuid_generate(out);
- char uuid_string[37];
-
- uuid_unparse(out, uuid_string);
- uuid_string[36]= 0;
- keys[x]= strdup(uuid_string);
- key_lengths[x]= 36;
- }
- }
-
- for (libtest::vchar_t::iterator iter= keys.begin();
+ for (libtest::vchar_ptr_t::iterator iter= keys.begin();
iter != keys.end();
iter++)
{
if (random() %2)
{
test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, &keys[0], &key_lengths[0], keys.size()));
+ memcached_mget(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size()));
memcached_result_st *results= memcached_result_create(memc, NULL);
test_true(results);
size_t value_length;
uint32_t flags;
memcached_return_t rc;
- char *out_value= memcached_get(memc, keys[which_key], 36,
+ char *out_value= memcached_get(memc, keys.key_at(which_key), keys.length_at(which_key),
&value_length, &flags, &rc);
test_compare(MEMCACHED_SUCCESS, rc);
test_null(out_value);
}
}
- for (libtest::vchar_t::iterator iter= keys.begin();
- iter != keys.end();
- iter++)
- {
- free(*iter);
- }
-
return TEST_SUCCESS;
}
test_compare(MEMCACHED_SUCCESS,
memcached_callback_set(memc_clone, MEMCACHED_CALLBACK_NAMESPACE, NULL));
- std::vector <char> longkey;
+ libtest::vchar_t longkey;
{
- std::vector<char>::iterator it= longkey.begin();
+ libtest::vchar_t::iterator it= longkey.begin();
longkey.insert(it, MEMCACHED_MAX_KEY, 'a');
}
{
size_t value_length= 8191;
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(value_length);
for (uint32_t x= 0; x < value_length; x++)
{
{
size_t value_length= 8191;
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(value_length);
for (uint32_t x= 0; x < value_length; x++)
{
{
size_t value_length= 8191;
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(value_length);
for (uint32_t x= 0; x < value_length; x++)
{
return TEST_SUCCESS;
}
-/* Count the results */
-static memcached_return_t callback_counter(const memcached_st*, memcached_result_st*, void *context)
-{
- size_t *counter= (size_t *)context;
-
- *counter= *counter + 1;
-
- return MEMCACHED_SUCCESS;
-}
-
static test_return_t mget_result_function(memcached_st *memc)
{
const char *keys[]= {"fudge", "son", "food"};
memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL");
test_true(memc);
- size_t max_keys= 20480;
-
-
- char **keys= static_cast<char **>(calloc(max_keys, sizeof(char*)));
- size_t *key_length=static_cast<size_t *>(calloc(max_keys, sizeof(size_t)));
+ keys_st keys(20480);
/* First add all of the items.. */
char blob[1024] = {0};
- for (size_t x= 0; x < max_keys; ++x)
+ for (size_t x= 0; x < keys.size(); ++x)
{
- char k[251];
-
- key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%lu", (unsigned long)x);
- keys[x]= strdup(k);
- test_true(keys[x] != NULL);
uint64_t query_id= memcached_query_id(memc);
- memcached_return_t rc= memcached_add(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
- test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc));
+ memcached_return_t rc= memcached_add(memc,
+ keys.key_at(x), keys.length_at(x),
+ blob, sizeof(blob),
+ 0, 0);
+ test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED,
+ memcached_strerror(NULL, rc));
test_compare(query_id +1, memcached_query_id(memc));
}
size_t counter= 0;
memcached_execute_fn callbacks[]= { &callback_counter };
test_compare(MEMCACHED_SUCCESS,
- memcached_mget_execute(memc, (const char**)keys, key_length,
- max_keys, callbacks, &counter, 1));
+ memcached_mget_execute(memc,
+ keys.keys_ptr(), keys.lengths_ptr(),
+ keys.size(), callbacks, &counter, 1));
{
uint64_t query_id= memcached_query_id(memc);
test_compare(query_id, memcached_query_id(memc));
/* Verify that we got all of the items */
- test_true(counter == max_keys);
- }
-
- /* Release all allocated resources */
- for (size_t x= 0; x < max_keys; ++x)
- {
- free(keys[x]);
+ test_compare(keys.size(), counter);
}
- free(keys);
- free(key_length);
memcached_free(memc);
}
#define REGRESSION_BINARY_VS_BLOCK_COUNT 20480
+static pairs_st *global_pairs;
static test_return_t key_setup(memcached_st *memc)
{
return TEST_SUCCESS;
}
-static test_return_t key_teardown(memcached_st *memc)
+static test_return_t key_teardown(memcached_st *)
{
- (void)memc;
pairs_free(global_pairs);
return TEST_SUCCESS;
return TEST_SUCCESS;
}
-static test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned, memcached_return_t& rc)
-{
- keys_returned= 0;
-
- memcached_result_st* result= NULL;
- while ((result= memcached_fetch_result(memc, result, &rc)))
- {
- test_compare(MEMCACHED_SUCCESS, rc);
- keys_returned+= 1;
- }
- memcached_result_free(result);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned)
-{
- memcached_return_t rc;
- return fetch_all_results(memc, keys_returned, rc);
-}
-
-/* Test case provided by Cal Haldenbrand */
-#define HALDENBRAND_KEY_COUNT 3000U // * 1024576
-#define HALDENBRAND_FLAG_KEY 99 // * 1024576
-static test_return_t user_supplied_bug1(memcached_st *memc)
-{
- /* We just keep looking at the same values over and over */
- srandom(10);
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
-
-
- /* add key */
- unsigned long long total= 0;
- for (uint32_t x= 0 ; total < 20 * 1024576 ; x++ )
- {
- uint32_t size= (uint32_t)(rand() % ( 5 * 1024 ) ) + 400;
- char randomstuff[6 * 1024];
- memset(randomstuff, 0, 6 * 1024);
- test_true(size < 6 * 1024); /* Being safe here */
-
- for (uint32_t j= 0 ; j < size ;j++)
- {
- randomstuff[j] = (signed char) ((rand() % 26) + 97);
- }
-
- total+= size;
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(key, sizeof(key), "%u", x);
- test_compare(MEMCACHED_SUCCESS,
- memcached_set(memc, key, key_length,
- randomstuff, strlen(randomstuff),
- time_t(0), HALDENBRAND_FLAG_KEY));
- }
- test_true(total > HALDENBRAND_KEY_COUNT);
-
- return TEST_SUCCESS;
-}
-
-/* Test case provided by Cal Haldenbrand */
-static test_return_t user_supplied_bug2(memcached_st *memc)
-{
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
-
-#ifdef NOT_YET
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576));
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576));
- getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE);
- getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
-
- for (x= 0, errors= 0; total < 20 * 1024576 ; x++)
-#endif
-
- size_t total_value_length= 0;
- for (uint32_t x= 0, errors= 0; total_value_length < 24576 ; x++)
- {
- uint32_t flags= 0;
- size_t val_len= 0;
-
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(key, sizeof(key), "%u", x);
-
- memcached_return_t rc;
- char *getval= memcached_get(memc, key, key_length, &val_len, &flags, &rc);
- if (memcached_failed(rc))
- {
- if (rc == MEMCACHED_NOTFOUND)
- {
- errors++;
- }
- else
- {
- test_true(rc);
- }
-
- continue;
- }
- test_compare(uint32_t(HALDENBRAND_FLAG_KEY), flags);
- test_true(getval);
-
- total_value_length+= val_len;
- errors= 0;
- ::free(getval);
- }
-
- return TEST_SUCCESS;
-}
-
-/* Do a large mget() over all the keys we think exist */
-static test_return_t user_supplied_bug3(memcached_st *memc)
-{
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
-
-#ifdef NOT_YET
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576);
- getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE);
- getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
-#endif
-
- std::vector<size_t> key_lengths;
- key_lengths.resize(HALDENBRAND_KEY_COUNT);
- std::vector<char *> keys;
- keys.resize(key_lengths.size());
- for (uint32_t x= 0; x < key_lengths.size(); x++)
- {
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(key, sizeof(key), "%u", x);
- test_true(key_length > 0 and key_length < MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1);
- keys[x]= strdup(key);
- key_lengths[x]= key_length;
- }
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, &keys[0], &key_lengths[0], key_lengths.size()));
-
- unsigned int keys_returned;
- test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned));
- test_compare(HALDENBRAND_KEY_COUNT, keys_returned);
-
- for (std::vector<char *>::iterator iter= keys.begin();
- iter != keys.end();
- iter++)
- {
- ::free(*iter);
- }
-
- return TEST_SUCCESS;
-}
-
/* Make sure we behave properly if server list has no values */
static test_return_t user_supplied_bug4(memcached_st *memc)
{
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, uint64_t(0));
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(value_length);
for (uint32_t x= 0; x < value_length; x++)
{
test_compare(-1, int32_t(memcached_behavior_get(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT)));
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(512);
for (unsigned int x= 0; x < 512; x++)
{
static test_return_t user_supplied_bug13(memcached_st *memc)
{
char key[] = "key34567890";
- memcached_return_t rc;
- size_t overflowSize;
char commandFirst[]= "set key34567890 0 0 ";
char commandLast[] = " \r\n"; /* first line of command sent to server */
size_t commandLength;
- size_t testSize;
commandLength = strlen(commandFirst) + strlen(commandLast) + 4; /* 4 is number of characters in size, probably 8196 */
- overflowSize = MEMCACHED_MAX_BUFFER - commandLength;
+ size_t overflowSize = MEMCACHED_MAX_BUFFER - commandLength;
- for (testSize= overflowSize - 1; testSize < overflowSize + 1; testSize++)
+ for (size_t testSize= overflowSize - 1; testSize < overflowSize + 1; testSize++)
{
char *overflow= new (std::nothrow) char[testSize];
test_true(overflow);
memset(overflow, 'x', testSize);
- rc= memcached_set(memc, key, strlen(key),
- overflow, testSize, 0, 0);
- test_compare(MEMCACHED_SUCCESS, rc);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc, key, strlen(key),
+ overflow, testSize, 0, 0));
delete [] overflow;
}
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true);
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(18000);
for (size_t x= 0; x < 18000; x++)
{
&length, &flags, &rc);
test_compare(MEMCACHED_SUCCESS, rc);
- test_true(value == NULL);
+ test_null(value);
test_zero(length);
test_zero(flags);
}
/* empty the cache to ensure misses (hence non-responses) */
test_compare(MEMCACHED_SUCCESS, memcached_flush(memc_clone, 0));
- std::vector<size_t> key_lengths;
- key_lengths.resize(key_count);
- std::vector<char *> keys;
- keys.resize(key_lengths.size());
- for (unsigned int x= 0; x < key_lengths.size(); x++)
- {
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(key, sizeof(key), "%u", x);
- test_true(key_length > 0 and key_length < MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1);
- keys[x]= strdup(key);
- key_lengths[x]= key_length;
- }
+ keys_st keys(key_count);
oldalarm= signal(SIGALRM, fail);
alarm(5);
test_compare_got(MEMCACHED_SUCCESS,
- memcached_mget(memc_clone, &keys[0], &key_lengths[0], key_count), memcached_last_error_message(memc_clone));
+ memcached_mget(memc_clone, keys.keys_ptr(), keys.lengths_ptr(), keys.size()),
+ memcached_last_error_message(memc_clone));
alarm(0);
signal(SIGALRM, oldalarm);
test_false(return_key[0]);
test_false(return_value);
- for (std::vector<char *>::iterator iter= keys.begin();
- iter != keys.end();
- iter++)
- {
- free(*iter);
- }
-
memcached_free(memc_clone);
return TEST_SUCCESS;
return TEST_SUCCESS;
}
-static test_return_t cleanup_pairs(memcached_st *memc)
-{
- (void)memc;
- pairs_free(global_pairs);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t generate_pairs(memcached_st *)
-{
- global_pairs= pairs_generate(GLOBAL_COUNT, 400);
- global_count= GLOBAL_COUNT;
-
- for (size_t x= 0; x < global_count; x++)
- {
- global_keys[x]= global_pairs[x].key;
- global_keys_length[x]= global_pairs[x].key_length;
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t generate_large_pairs(memcached_st *)
-{
- global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10);
- global_count= GLOBAL2_COUNT;
-
- for (size_t x= 0; x < global_count; x++)
- {
- global_keys[x]= global_pairs[x].key;
- global_keys_length[x]= global_pairs[x].key_length;
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t generate_data(memcached_st *memc)
-{
- unsigned int check_execute= execute_set(memc, global_pairs, global_count);
-
- test_compare_warn_hint(global_count, check_execute, "Possible false, positive, memcached may have ejected key/value based on memory needs");
-
- return TEST_SUCCESS;
-}
-
-static test_return_t generate_data_with_stats(memcached_st *memc)
-{
- unsigned int check_execute= execute_set(memc, global_pairs, global_count);
-
- test_compare(check_execute, global_count);
-
- // @todo hosts used size stats
- memcached_return_t rc;
- memcached_stat_st *stat_p= memcached_stat(memc, NULL, &rc);
- test_true(stat_p);
-
- for (uint32_t host_index= 0; host_index < SERVERS_TO_CREATE; host_index++)
- {
- /* This test was changes so that "make test" would work properlly */
- if (DEBUG)
- {
- memcached_server_instance_st instance=
- memcached_server_instance_by_position(memc, host_index);
-
- printf("\nserver %u|%s|%u bytes: %llu\n", host_index, instance->hostname, instance->port, (unsigned long long)(stat_p + host_index)->bytes);
- }
- test_true((unsigned long long)(stat_p + host_index)->bytes);
- }
-
- memcached_stat_free(NULL, stat_p);
-
- return TEST_SUCCESS;
-}
-static test_return_t generate_buffer_data(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
- generate_data(memc);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t get_read_count(memcached_st *memc)
-{
- memcached_st *memc_clone= memcached_clone(NULL, memc);
- test_true(memc_clone);
-
- memcached_server_add_with_weight(memc_clone, "localhost", 6666, 0);
-
- {
- char *return_value;
- size_t return_value_length;
- uint32_t flags;
- uint32_t count;
-
- for (size_t x= count= 0; x < global_count; x++)
- {
- memcached_return_t rc;
- return_value= memcached_get(memc_clone, global_keys[x], global_keys_length[x],
- &return_value_length, &flags, &rc);
- if (rc == MEMCACHED_SUCCESS)
- {
- count++;
- if (return_value)
- {
- free(return_value);
- }
- }
- }
- }
-
- memcached_free(memc_clone);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t get_read(memcached_st *memc)
-{
- size_t keys_returned= 0;
- for (size_t x= 0; x < global_count; x++)
- {
- size_t return_value_length;
- uint32_t flags;
- memcached_return_t rc;
- char *return_value= memcached_get(memc, global_keys[x], global_keys_length[x],
- &return_value_length, &flags, &rc);
- /*
- test_true(return_value);
- test_compare(MEMCACHED_SUCCESS, rc);
- */
- if (rc == MEMCACHED_SUCCESS && return_value)
- {
- keys_returned++;
- free(return_value);
- }
- }
- test_compare_warn_hint(global_count, keys_returned, "Possible false, positive, memcached may have ejected key/value based on memory needs");
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- // Go fetch the keys and test to see if all of them were returned
- {
- unsigned int keys_returned;
- test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned));
- test_true(keys_returned > 0);
- test_compare_warn_hint(global_count, keys_returned, "Possible false, positive, memcached may have ejected key/value based on memory needs");
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- /* Turn this into a help function */
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
- test_true(results);
-
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
- {
- if (rc == MEMCACHED_IN_PROGRESS)
- {
- continue;
- }
-
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(&results_obj);
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read_internal_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
- {
- memcached_result_st *results= NULL;
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, results, &rc)))
- {
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(results);
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read_partial_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- // We will scan for just one key
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
-
- memcached_return_t rc;
- results= memcached_fetch_result(memc, results, &rc);
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- memcached_result_free(&results_obj);
- }
-
- // We already have a read happening, lets start up another one.
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
- test_true(results);
- test_false(memcached_is_allocated(results));
-
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
- {
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(&results_obj);
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read_function(memcached_st *memc)
-{
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- memcached_execute_fn callbacks[]= { &callback_counter };
- size_t counter= 0;
- test_compare(MEMCACHED_SUCCESS,
- memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t delete_generate(memcached_st *memc)
-{
- size_t total= 0;
- for (size_t x= 0; x < global_count; x++)
- {
- if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0)))
- {
- total++;
- }
- }
- test_compare_warn_hint(global_count, total, "Possible false, positive, memcached may have ejected key/value based on memory needs");
-
- return TEST_SUCCESS;
-}
-
-static test_return_t delete_buffer_generate(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
-
- size_t total= 0;
- for (size_t x= 0; x < global_count; x++)
- {
- if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0)))
- {
- total++;
- }
- }
- test_compare_warn_hint(global_count, total, "Possible false, positive, memcached may have ejected key/value based on memory needs");
-
- return TEST_SUCCESS;
-}
static test_return_t add_host_test1(memcached_st *memc)
{
void *test_ptr= NULL;
void *cb_ptr= NULL;
{
- memcached_malloc_fn malloc_cb=
- (memcached_malloc_fn)my_malloc;
+ memcached_malloc_fn malloc_cb= (memcached_malloc_fn)my_malloc;
cb_ptr= *(void **)&malloc_cb;
memcached_return_t rc;
test_true(count);
break;
}
- test_true_got(ret == MEMCACHED_SUCCESS or ret == MEMCACHED_BUFFERED, memcached_strerror(NULL, ret));
+ test_true_got(ret == MEMCACHED_SUCCESS or ret == MEMCACHED_BUFFERED,
+ memcached_strerror(NULL, ret));
}
/*
{0, 0, (test_callback_fn*)0}
};
-test_st haldenbrand_tests[] ={
- {"memcached_set", false, (test_callback_fn*)user_supplied_bug1 },
- {"memcached_get()", false, (test_callback_fn*)user_supplied_bug2 },
- {"memcached_mget()", false, (test_callback_fn*)user_supplied_bug3 },
+test_st haldenbrand_TESTS[] ={
+ {"memcached_set", false, (test_callback_fn*)haldenbrand_TEST1 },
+ {"memcached_get()", false, (test_callback_fn*)haldenbrand_TEST2 },
+ {"memcached_mget()", false, (test_callback_fn*)haldenbrand_TEST3 },
{0, 0, (test_callback_fn*)0}
};
{"result", 0, 0, result_tests},
{"async", (test_callback_fn*)pre_nonblock, 0, async_tests},
{"async(BINARY)", (test_callback_fn*)pre_nonblock_binary, 0, async_tests},
- {"Cal Haldenbrand's tests", 0, 0, haldenbrand_tests},
+ {"Cal Haldenbrand's tests", 0, 0, haldenbrand_TESTS},
{"user written tests", 0, 0, user_tests},
{"generate", 0, 0, generate_tests},
{"generate_hsieh", (test_callback_fn*)pre_hsieh, 0, generate_tests},