1
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
* Copyright (C) 2011 Data Differential, http://datadifferential.com/
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
14
* * Redistributions in binary form must reproduce the above
15
* copyright notice, this list of conditions and the following disclaimer
16
* in the documentation and/or other materials provided with the
19
* * The names of its contributors may not be used to endorse or
20
* promote products derived from this software without specific prior
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
Test that we are cycling the servers we are creating during testing.
43
#include <libtest/test.hpp>
45
#include <libmemcached/memcached.h>
46
#include <libmemcached/is.h>
47
#include <libmemcached/util.h>
52
#include <libtest/server.h>
54
using namespace libtest;
56
#ifndef __INTEL_COMPILER
57
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
60
static test_return_t alive(memcached_st *memc)
63
test_true(memcached_is_allocated(memc));
64
for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
66
memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x);
69
test_true(libmemcached_util_ping(memcached_server_name(instance),
70
memcached_server_port(instance), NULL));
76
static test_return_t valid(memcached_st *memc)
79
test_true(memcached_is_allocated(memc));
81
for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
83
memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x);
86
pid_t pid= libmemcached_util_getpid(memcached_server_name(instance),
87
memcached_server_port(instance), NULL);
94
static test_return_t kill_test(memcached_st *)
96
static struct timespec global_sleep_value= { 2, 0 };
101
nanosleep(&global_sleep_value, NULL);
107
test_st ping_tests[] ={
108
{"alive", true, (test_callback_fn*)alive },
112
test_st getpid_tests[] ={
113
{"valid", true, (test_callback_fn*)valid },
117
test_st kill_tests[] ={
118
{"kill", true, (test_callback_fn*)kill_test },
122
collection_st collection[] ={
123
{"libmemcached_util_ping()", 0, 0, ping_tests},
124
{"libmemcached_util_getpid()", 0, 0, getpid_tests},
125
{"kill", 0, 0, kill_tests},
130
#include "tests/libmemcached_world.h"
132
void get_world(Framework *world)
134
world->collections= collection;
136
world->_create= (test_callback_create_fn*)world_create;
137
world->_destroy= (test_callback_destroy_fn*)world_destroy;
139
world->item.set_startup((test_callback_fn*)world_test_startup);
140
world->item.set_pre((test_callback_fn*)world_pre_run);
141
world->item.set_post((test_callback_fn*)world_post_run);
143
world->set_on_error((test_callback_error_fn*)world_on_error);
145
world->collection_startup= (test_callback_fn*)world_container_startup;
146
world->collection_shutdown= (test_callback_fn*)world_container_shutdown;
148
world->set_runner(&defualt_libmemcached_runner);