-/* libMemcached Functions Test
- * Copyright (C) 2006-2009 Brian Aker
- * All rights reserved.
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2006-2009 Brian Aker 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.
*
- * Use and distribution licensed under the BSD license. See
- * the COPYING file in the parent directory for full text.
*/
+
/*
Sample test application.
*/
#define SMALL_STRING_LEN 1024
#include <libtest/test.h>
+#include "tests/deprecated.h"
#include "tests/parser.h"
+#include "tests/pool.h"
#include "tests/string.h"
#include "tests/replication.h"
#include "tests/basic.h"
return TEST_SUCCESS;
}
-static test_return_t server_list_null_test(memcached_st *ptr)
-{
- memcached_server_st *server_list;
- memcached_return_t rc;
- (void)ptr;
-
- server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, NULL);
- test_true(server_list == NULL);
-
- server_list= memcached_server_list_append_with_weight(NULL, "localhost", 0, 0, NULL);
- test_true(server_list == NULL);
-
- server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, &rc);
- test_true(server_list == NULL);
-
- return TEST_SUCCESS;
-}
-
#define TEST_PORT_COUNT 7
in_port_t test_ports[TEST_PORT_COUNT];
static test_return_t memcached_server_remove_test(memcached_st *ptr)
{
- memcached_return_t rc;
- memcached_st local_memc;
- memcached_st *memc;
- memcached_server_st *servers;
- memcached_server_fn callbacks[1];
-
- const char *server_string= "localhost:4444, localhost:4445, localhost:4446, localhost:4447, localhost, memcache1.memcache.bk.sapo.pt:11211, memcache1.memcache.bk.sapo.pt:11212, memcache1.memcache.bk.sapo.pt:11213, memcache1.memcache.bk.sapo.pt:11214, memcache2.memcache.bk.sapo.pt:11211, memcache2.memcache.bk.sapo.pt:11212, memcache2.memcache.bk.sapo.pt:11213, memcache2.memcache.bk.sapo.pt:11214";
+ const char *server_string= "--server=localhost:4444 --server=localhost:4445 --server=localhost:4446 --server=localhost:4447 --server=localhost --server=memcache1.memcache.bk.sapo.pt:11211 --server=memcache1.memcache.bk.sapo.pt:11212 --server=memcache1.memcache.bk.sapo.pt:11213 --server=memcache1.memcache.bk.sapo.pt:11214 --server=memcache2.memcache.bk.sapo.pt:11211 --server=memcache2.memcache.bk.sapo.pt:11212 --server=memcache2.memcache.bk.sapo.pt:11213 --server=memcache2.memcache.bk.sapo.pt:11214";
(void)ptr;
- memc= memcached_create(&local_memc);
-
- servers= memcached_servers_parse(server_string);
- assert(servers);
-
- rc= memcached_server_push(memc, servers);
- memcached_server_list_free(servers);
+ memcached_st *memc= memcached(server_string, strlen(server_string));
+ test_true(memc);
+ memcached_server_fn callbacks[1];
callbacks[0]= server_print_callback;
memcached_server_cursor(memc, callbacks, NULL, 1);
uint32_t x= *((uint32_t *)(context));
(void)ptr;
- assert(test_ports[x] == server->port);
+ if (! (test_ports[x] == server->port))
+ {
+ fprintf(stderr, "%lu -> %lu\n", (unsigned long)test_ports[x], (unsigned long)server->port);
+ return MEMCACHED_FAILURE;
+ }
+
*((uint32_t *)(context))= ++x;
return MEMCACHED_SUCCESS;
{ // Test all of the flags
test_true(memc_clone->flags.no_block == memc->flags.no_block);
test_true(memc_clone->flags.tcp_nodelay == memc->flags.tcp_nodelay);
- test_true(memc_clone->flags.reuse_memory == memc->flags.reuse_memory);
- test_true(memc_clone->flags.use_cache_lookups == memc->flags.use_cache_lookups);
test_true(memc_clone->flags.support_cas == memc->flags.support_cas);
test_true(memc_clone->flags.buffer_requests == memc->flags.buffer_requests);
test_true(memc_clone->flags.use_sort_hosts == memc->flags.use_sort_hosts);
uint32_t count = memcached_server_count(memc);
// Do not do this in your code, it is not supported.
- memc->servers[1].state.is_dead= true;
+ memc->servers[1].options.is_dead= true;
memc->state.is_time_for_rebuild= true;
uint32_t new_count= memcached_server_count(memc);
return TEST_SUCCESS;
}
-// Look for memory leak
-static test_return_t regression_bug_728286(memcached_st *unused)
-{
- (void)unused;
- memcached_server_st *servers = memcached_servers_parse("1.2.3.4:99");
- assert(servers);
- memcached_server_free(servers);
-
- return TEST_SUCCESS;
-}
-
static test_return_t regression_bug_581030(memcached_st *unused)
{
(void)unused;
{"delete_through", 1, (test_callback_fn)delete_through },
{"noreply", 1, (test_callback_fn)noreply_test},
{"analyzer", 1, (test_callback_fn)analyzer_test},
-#ifdef HAVE_LIBMEMCACHEDUTIL
{"connectionpool", 1, (test_callback_fn)connection_pool_test },
+ {"memcached_pool_test", 1, (test_callback_fn)memcached_pool_test },
{"ping", 1, (test_callback_fn)ping_test },
-#endif
{"test_get_last_disconnect", 1, (test_callback_fn)test_get_last_disconnect},
{"verbosity", 1, (test_callback_fn)test_verbosity},
{"test_server_failure", 1, (test_callback_fn)test_server_failure},
{"hash", 0, (test_callback_fn)parser_hash_test },
{"libmemcached_check_configuration", 0, (test_callback_fn)libmemcached_check_configuration_test },
{"libmemcached_check_configuration_with_filename", 0, (test_callback_fn)libmemcached_check_configuration_with_filename_test },
- {"memcached_parse_configure_file", 0, (test_callback_fn)memcached_parse_configure_file_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 },
{0, 0, 0, 0}
};
-#define SERVERS_TO_CREATE 5
-
#include "libmemcached_world.h"
void get_world(world_st *world)