#include "tests/deprecated.h"
#include "tests/parser.h"
#include "tests/pool.h"
+#include "tests/namespace.h"
#include "tests/string.h"
#include "tests/replication.h"
#include "tests/basic.h"
test_true(memc_clone->flags.verify_key == memc->flags.verify_key);
test_true(memc_clone->ketama.weighted == memc->ketama.weighted);
test_true(memc_clone->flags.binary_protocol == memc->flags.binary_protocol);
- test_true(memc_clone->flags.hash_with_prefix_key == memc->flags.hash_with_prefix_key);
+ test_true(memc_clone->flags.hash_with_namespace == memc->flags.hash_with_namespace);
test_true(memc_clone->flags.no_reply == memc->flags.no_reply);
test_true(memc_clone->flags.use_udp == memc->flags.use_udp);
test_true(memc_clone->flags.auto_eject_hosts == memc->flags.auto_eject_hosts);
static test_return_t get_test4(memcached_st *memc)
{
- memcached_return_t rc;
const char *key= "foo";
- char *value;
size_t value_length= 8191;
- char *string;
- size_t string_length;
- uint32_t flags;
- uint32_t x;
- value = (char*)malloc(value_length);
+ char *value= (char*)malloc(value_length);
test_true(value);
- for (x= 0; x < value_length; x++)
+ for (uint32_t x= 0; x < value_length; x++)
+ {
value[x] = (char) (x % 127);
+ }
- rc= memcached_set(memc, key, strlen(key),
- value, value_length,
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ memcached_return_t rc= memcached_set(memc, key, strlen(key),
+ value, value_length,
+ (time_t)0, (uint32_t)0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
- for (x= 0; x < 10; x++)
+ for (uint32_t x= 0; x < 10; x++)
{
- string= memcached_get(memc, key, strlen(key),
- &string_length, &flags, &rc);
+ uint32_t flags;
+ size_t string_length;
+ char *string= memcached_get(memc, key, strlen(key),
+ &string_length, &flags, &rc);
test_compare(MEMCACHED_SUCCESS, rc);
test_true(string);
{
test_true(return_value);
test_compare(MEMCACHED_SUCCESS, rc);
- if (not memc->prefix_key)
+ if (not memc->_namespace)
{
test_compare(return_key_length, return_value_length);
test_memcmp(return_value, return_key, return_value_length);
From Andrei on IRC
*/
-static test_return_t user_supplied_bug19(memcached_st *not_used)
+static test_return_t user_supplied_bug19(memcached_st *)
{
- memcached_st *memc;
- const memcached_server_st *server;
memcached_return_t res;
- (void)not_used;
+ memcached_st *memc= memcached(test_literal_param("--server=localhost:11311/?100 --server=localhost:11312/?100"));
- memc= memcached_create(NULL);
- memcached_server_add_with_weight(memc, "localhost", 11311, 100);
- memcached_server_add_with_weight(memc, "localhost", 11312, 100);
-
- server= memcached_server_by_key(memc, "a", 1, &res);
+ const memcached_server_st *server= memcached_server_by_key(memc, "a", 1, &res);
+ test_true(server);
memcached_free(memc);
memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, long_key));
/* Test for a bad prefix, but with a short key */
- test_compare_got(MEMCACHED_SUCCESS,
+ test_compare_got(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) ? MEMCACHED_INVALID_ARGUMENTS : MEMCACHED_SUCCESS,
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, 1),
memcached_strerror(NULL, rc));
- if (not memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
- {
- strncpy(long_key, "dog cat", sizeof(long_key));
- test_compare(MEMCACHED_BAD_KEY_PROVIDED,
- memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, long_key));
- }
+ test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) ? MEMCACHED_SUCCESS : MEMCACHED_BAD_KEY_PROVIDED,
+ memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, "dog cat"));
}
return TEST_SUCCESS;
memcached_server_instance_by_position(memc, 0);
if ((instance->major_version >= 1 && (instance->minor_version == 2 && instance->micro_version >= 4))
- || instance->minor_version > 2)
+ or instance->minor_version > 2)
{
return TEST_SUCCESS;
}
static test_return_t pre_unix_socket(memcached_st *memc)
{
- memcached_return_t rc;
struct stat buf;
memcached_servers_reset(memc);
+ const char *socket_file= default_socket();
- if (stat("/tmp/memcached.socket", &buf))
- return TEST_SKIPPED;
+ test_skip(0, stat(socket_file, &buf));
- rc= memcached_server_add_unix_socket_with_weight(memc, "/tmp/memcached.socket", 0);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_server_add_unix_socket_with_weight(memc, socket_file, 0));
- return ( rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_FAILURE );
+ return TEST_SUCCESS;
}
static test_return_t pre_nodelay(memcached_st *memc)
We are testing the error condition when we connect to a server via memcached_get()
but find that the server is not available.
*/
-static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc)
+static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *)
{
- (void)memc;
- memcached_st *tl_memc_h;
-
const char *key= "MemcachedLives";
size_t len;
uint32_t flags;
memcached_return rc;
- char *value;
// Create a handle.
- tl_memc_h= memcached_create(NULL);
- memcached_server_st *servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
- test_true(servers);
- memcached_server_push(tl_memc_h, servers);
- memcached_server_list_free(servers);
+ memcached_st *tl_memc_h= memcached(test_literal_param("--server=localhost:9898 --server=localhost:9899")); // This server should not exist
// See if memcached is reachable.
- value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc);
+ char *value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc);
test_false(value);
test_compare(0, len);
static test_return_t test_server_failure(memcached_st *memc)
{
+ if (memcached_server_count(memc) < 2)
+ return TEST_SKIPPED;
+
memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0);
memcached_st *local_memc= memcached_create(NULL);
static test_return_t test_cull_servers(memcached_st *memc)
{
- uint32_t count = memcached_server_count(memc);
+ uint32_t count= memcached_server_count(memc);
+
+ if (count < 2)
+ {
+ return TEST_SKIPPED;
+ }
// Do not do this in your code, it is not supported.
memc->servers[1].options.is_dead= true;
{"libmemcached_check_configuration_with_filename", 0, (test_callback_fn*)libmemcached_check_configuration_with_filename_test },
{"number_options", 0, (test_callback_fn*)parser_number_options_test },
{"randomly generated options", 0, (test_callback_fn*)random_statement_build_test },
- {"prefix_key", 0, (test_callback_fn*)parser_key_prefix_test },
+ {"namespace", 0, (test_callback_fn*)parser_key_prefix_test },
{"server", 0, (test_callback_fn*)server_test },
{"bad server strings", 0, (test_callback_fn*)servers_bad_test },
{"server with weights", 0, (test_callback_fn*)server_with_weight_test },
{"parsing servername, port, and weight", 0, (test_callback_fn*)test_hostname_port_weight },
+ {"--socket=", 0, (test_callback_fn*)test_parse_socket },
+ {"--namespace=", 0, (test_callback_fn*)test_namespace_keyword },
{0, 0, (test_callback_fn*)0}
};
};
test_st namespace_tests[] ={
- {"basic tests", 0, (test_callback_fn*)selection_of_namespace_tests },
-#if 0
- {"increment", 0, (test_callback_fn*)memcached_increment_namespace },
-#endif
+ {"basic tests", true, (test_callback_fn*)selection_of_namespace_tests },
+ {"increment", true, (test_callback_fn*)memcached_increment_namespace },
{0, 0, (test_callback_fn*)0}
};
{"namespace", (test_callback_fn*)set_namespace, 0, tests},
{"namespace(BINARY)", (test_callback_fn*)set_namespace_and_binary, 0, tests},
{"specific namespace", 0, 0, namespace_tests},
+ {"specific namespace(BINARY)", (test_callback_fn*)pre_binary, 0, namespace_tests},
{"sasl_auth", (test_callback_fn*)pre_sasl, 0, sasl_auth_tests },
{"sasl", (test_callback_fn*)pre_sasl, 0, tests },
{"version_1_2_3", (test_callback_fn*)check_for_1_2_3, 0, version_1_2_3},
{"string", 0, 0, string_tests},
{"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},
+ {"async(BINARY)", (test_callback_fn*)pre_nonblock_binary, 0, async_tests},
{"Cal Haldenbrand's tests", 0, 0, haldenbrand_tests},
{"user", 0, 0, user_tests},
{"generate", 0, 0, generate_tests},