#define test_array_length util_array_length
namespace libtest {
-typedef std::vector<char*> vchar_t;
+typedef std::vector<char> vchar_t;
+typedef std::vector<char*> vchar_ptr_t;
}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include <tests/libmemcached-1.0/fetch_all_results.h>
+
+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;
+}
+
+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);
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+test_return_t fetch_all_results(memcached_st *, unsigned int&, memcached_return_t&);
+test_return_t fetch_all_results(memcached_st *, unsigned int&);
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include "tests/libmemcached-1.0/haldenbrand.h"
+#include "tests/libmemcached-1.0/fetch_all_results.h"
+
+/* Test case provided by Cal Haldenbrand */
+#define HALDENBRAND_KEY_COUNT 3000U // * 1024576
+#define HALDENBRAND_FLAG_KEY 99 // * 1024576
+
+test_return_t haldenbrand_TEST1(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 */
+test_return_t haldenbrand_TEST2(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 */
+test_return_t haldenbrand_TEST3(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 (libtest::vchar_ptr_t::iterator iter= keys.begin();
+ iter != keys.end();
+ iter++)
+ {
+ ::free(*iter);
+ }
+
+
+ return TEST_SUCCESS;
+}
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+test_return_t haldenbrand_TEST1(memcached_st *);
+test_return_t haldenbrand_TEST2(memcached_st *);
+test_return_t haldenbrand_TEST3(memcached_st *);
tests/ketama_test_cases.h \
tests/ketama_test_cases_spy.h \
tests/libmemcached-1.0/dump.h \
+ tests/libmemcached-1.0/fetch_all_results.h \
+ tests/libmemcached-1.0/haldenbrand.h \
tests/libmemcached-1.0/stat.h \
tests/namespace.h \
tests/parser.h \
tests/libmemcached-1.0/basic.cc \
tests/libmemcached-1.0/callbacks.cc \
tests/libmemcached-1.0/debug.cc \
+ tests/libmemcached-1.0/fetch_all_results.cc \
+ tests/libmemcached-1.0/haldenbrand.cc \
tests/libmemcached-1.0/deprecated.cc \
tests/libmemcached-1.0/dump.cc \
tests/libmemcached-1.0/error_conditions.cc \
#include "tests/namespace.h"
#include "tests/parser.h"
#include "tests/libmemcached-1.0/dump.h"
+#include "tests/libmemcached-1.0/fetch_all_results.h"
+#include "tests/libmemcached-1.0/haldenbrand.h"
#include "tests/libmemcached-1.0/stat.h"
#include "tests/touch.h"
#include "tests/callbacks.h"
#define SERVERS_TO_CREATE 5
static uint32_t global_count= GLOBAL2_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++)
{
- char uuid_string[37];
+ 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, uuid_string);
- uuid_string[36]= 0;
- _keys[x]= strdup(uuid_string);
- _lengths[x]= 36;
+ uuid_unparse(out, &key_buffer[0]);
+ _keys[x]= strdup(&key_buffer[0]);
}
else // We just use a number and pad the string if UUID is not available
{
- memset(uuid_string, 'x', sizeof(uuid_string));
- int key_length= snprintf(uuid_string, sizeof(uuid_string), "%u", uint32_t(x));
- (void)key_length;
- _keys[x]= strdup(uuid_string);
- _lengths[x]= 36;
+ 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_t::iterator iter= _keys.begin();
+ for (libtest::vchar_ptr_t::iterator iter= _keys.begin();
iter != _keys.end();
iter++)
{
}
}
- libtest::vchar_t::iterator begin()
+ libtest::vchar_ptr_t::iterator begin()
{
return _keys.begin();
}
- libtest::vchar_t::iterator end()
+ libtest::vchar_ptr_t::iterator end()
{
return _keys.end();
}
return _lengths;
}
- libtest::vchar_t& keys()
+ libtest::vchar_ptr_t& keys()
{
return _keys;
}
}
private:
- libtest::vchar_t _keys;
+ libtest::vchar_ptr_t _keys;
std::vector<size_t> _lengths;
};
{
keys_st keys(200);
- for (libtest::vchar_t::iterator iter= keys.begin();
+ for (libtest::vchar_ptr_t::iterator iter= keys.begin();
iter != keys.end();
iter++)
{
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;
}
-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);
}
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},
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include <libmemcached-1.0/memcached.h>
+#include <libmemcached/util.h>
+
+using namespace libtest;
+
+static test_return_t memcached_fetch_execute_MEMCACHED_SUCCESS_TEST(memcached_st *memc)
+{
+ (void)memc;
+ return TEST_SUCCESS;
+}
+
+static test_return_t memcached_fetch_execute_MEMCACHED_NOTFOUND_TEST(memcached_st *memc)
+{
+ (void)memc;
+ return TEST_SUCCESS;
+}
+
+test_st memcached_fetch_execute_TESTS[] ={
+ {"memcached_fetch_execute(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_fetch_execute_MEMCACHED_SUCCESS_TEST },
+ {"memcached_fetch_execute(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_fetch_execute_MEMCACHED_NOTFOUND_TEST },
+ { 0, 0, (test_callback_fn*)0 }
+};
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+extern test_st *memcached_fetch_execute_TESTS;