#include "tests/ketama.h"
#include "tests/namespace.h"
#include "tests/parser.h"
+#include "tests/callbacks.h"
#include "tests/pool.h"
#include "tests/print.h"
#include "tests/replication.h"
return TEST_SUCCESS;
}
-static memcached_return_t delete_trigger(memcached_st *,
- const char *key,
- size_t key_length)
-{
- assert(key);
- assert(key_length);
-
- return MEMCACHED_SUCCESS;
-}
-
-static test_return_t delete_through(memcached_st *memc)
-{
- memcached_trigger_delete_key_fn callback;
-
- callback= (memcached_trigger_delete_key_fn)delete_trigger;
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_callback_set(memc, MEMCACHED_CALLBACK_DELETE_TRIGGER, *(void**)&callback));
-
- return TEST_SUCCESS;
-}
-
static test_return_t get_test(memcached_st *memc)
{
memcached_return_t rc;
/* Make sure be default none exists */
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
test_null(value);
- test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc));
+ test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
/* Test a clean set */
test_compare(MEMCACHED_SUCCESS,
memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, NULL));
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
- test_false(value);
- test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc));
+ test_null(value);
+ test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
/* Now setup for main test */
test_compare(MEMCACHED_SUCCESS,
memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, NULL));
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
- test_false(value);
- test_true(rc == MEMCACHED_FAILURE);
- test_true(value == NULL);
+ test_null(value);
+ test_compare(MEMCACHED_SUCCESS, rc);
/* Test a long key for failure */
/* TODO, extend test to determine based on setting, what result should be */
const char *key= "mine";
char *value;
- /* Make sure be default none exists */
+ // Make sure we default to a null namespace
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
test_null(value);
- test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc));
+ test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
/* Test a clean set */
test_compare(MEMCACHED_SUCCESS,
static test_return_t connection_pool3_test(memcached_st *memc)
{
+#ifdef __APPLE__
+ return TEST_SKIPPED;
+#endif
+
memcached_pool_st* pool= memcached_pool_create(memc, 1, 1);
test_true(pool);
memcached_return_t rc;
memcached_st *pop_memc;
+ // We do a hard loop, and try N times
int counter= 5;
do
{
struct timespec relative_time= { 0, 0 };
pop_memc= memcached_pool_fetch(pool, &relative_time, &rc);
+ if (memcached_success(rc))
+ {
+ break;
+ }
+
if (memcached_failed(rc))
{
test_null(pop_memc);
+ test_true(rc != MEMCACHED_TIMEOUT); // As long as relative_time is zero, MEMCACHED_TIMEOUT is invalid
}
- } while (rc == MEMCACHED_TIMEOUT and --counter);
+ } while (--counter);
if (memcached_failed(rc)) // Cleanup thread since we will exit once we test.
{
{"bad_key", true, (test_callback_fn*)bad_key_test },
{"memcached_server_cursor", true, (test_callback_fn*)memcached_server_cursor_test },
{"read_through", true, (test_callback_fn*)read_through },
- {"delete_through", true, (test_callback_fn*)delete_through },
+ {"delete_through", true, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER },
{"noreply", true, (test_callback_fn*)noreply_test},
{"analyzer", true, (test_callback_fn*)analyzer_test},
{"memcached_pool_st", true, (test_callback_fn*)connection_pool_test },
{"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test},
{"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test},
{"MEMCACHED_BEHAVIOR_POLL_TIMEOUT", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test},
+ {"MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY", false, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY},
{0, 0, 0}
};