1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 * Cycle the Gearmand server
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 using namespace libtest
;
46 #include <libmemcached/memcached.h>
48 static test_return_t
server_startup_single_TEST(void *obj
)
50 server_startup_st
*servers
= (server_startup_st
*)obj
;
51 test_compare(true, server_startup(*servers
, "memcached", libtest::get_free_port(), 0, NULL
, false));
52 test_compare(true, servers
->shutdown());
58 static test_return_t
server_startup_multiple_TEST(void *obj
)
60 server_startup_st
*servers
= (server_startup_st
*)obj
;
61 for (size_t x
= 0; x
< 10; x
++)
63 test_compare(true, server_startup(*servers
, "memcached", libtest::get_free_port(), 0, NULL
, false));
65 test_compare(true, servers
->shutdown());
70 static test_return_t
shutdown_and_remove_TEST(void *obj
)
72 server_startup_st
*servers
= (server_startup_st
*)obj
;
78 test_st server_startup_TESTS
[] ={
79 {"server_startup(1)", false, (test_callback_fn
*)server_startup_single_TEST
},
80 {"server_startup(10)", false, (test_callback_fn
*)server_startup_multiple_TEST
},
81 {"shutdown_and_remove()", false, (test_callback_fn
*)shutdown_and_remove_TEST
},
82 {"server_startup(10)", false, (test_callback_fn
*)server_startup_multiple_TEST
},
87 static test_return_t
collection_INIT(void *object
)
89 server_startup_st
*servers
= (server_startup_st
*)object
;
90 test_zero(servers
->count());
91 test_compare(true, server_startup(*servers
, "memcached", libtest::default_port(), 0, NULL
));
97 static test_return_t
validate_sanity_INIT(void *object
)
99 server_startup_st
*servers
= (server_startup_st
*)object
;
101 test_zero(servers
->count());
106 static test_return_t
collection_FINAL(void *object
)
108 server_startup_st
*servers
= (server_startup_st
*)object
;
114 collection_st collection
[] ={
115 {"server_startup()", validate_sanity_INIT
, collection_FINAL
, server_startup_TESTS
},
119 static void *world_create(server_startup_st
& servers
, test_return_t
& error
)
121 if (libtest::has_memcached() == false)
130 void get_world(libtest::Framework
* world
)
132 world
->collections(collection
);
133 world
->create(world_create
);