X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Funittest.cc;h=c0381f4d66155f65b39f5b22b5f1b993289e67d1;hb=25efe3485198149616820ab4e52d2f18f0abe5a7;hp=ff73aa40c251756c5cc69bcbd380dc2c55d2097f;hpb=9ba1b97bd2990ff7d8a83c03efc5e73c0e4d6e8a;p=m6w6%2Flibmemcached diff --git a/libtest/unittest.cc b/libtest/unittest.cc index ff73aa40..c0381f4d 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -51,6 +51,8 @@ using namespace libtest; +static std::string testing_service; + static test_return_t LIBTOOL_COMMAND_test(void *) { test_true(getenv("LIBTOOL_COMMAND")); @@ -325,39 +327,37 @@ static test_return_t test_skip_false_TEST(void *object) return TEST_SUCCESS; } -static test_return_t memcached_cycle_test(void *object) +static test_return_t server_startup_TEST(void *object) { server_startup_st *servers= (server_startup_st*)object; test_true(servers); - if (MEMCACHED_BINARY and HAVE_LIBMEMCACHED) - { - test_true(has_memcached()); - test_true(server_startup(*servers, "memcached", get_free_port(), 0, NULL)); + test_true(servers->start_server(testing_service, get_free_port(), 0, NULL, true)); - return TEST_SUCCESS; - } + test_true(servers->last()); + pid_t last_pid= servers->last()->pid(); - return TEST_SKIPPED; + test_compare(servers->last()->pid(), last_pid); + test_true(last_pid > 1); + test_compare(kill(last_pid, 0), 0); + + test_true(servers->shutdown()); +#if 0 + test_compare(servers->last()->pid(), -1); + test_compare(kill(last_pid, 0), -1); +#endif + + return TEST_SUCCESS; } -static test_return_t memcached_socket_cycle_test(void *object) +static test_return_t socket_server_startup_TEST(void *object) { server_startup_st *servers= (server_startup_st*)object; test_true(servers); - if (MEMCACHED_BINARY) - { - if (HAVE_LIBMEMCACHED) - { - test_true(has_memcached()); - test_true(servers->start_socket_server("memcached", get_free_port(), 0, NULL)); + test_true(servers->start_socket_server(testing_service, get_free_port(), 0, NULL, true)); - return TEST_SUCCESS; - } - } - - return TEST_SKIPPED; + return TEST_SUCCESS; } static test_return_t memcached_sasl_test(void *object) @@ -806,18 +806,23 @@ test_st gearmand_tests[] ={ {0, 0, 0} }; -static test_return_t check_for_libmemcached(void *) +static test_return_t check_for_libmemcached(void* object) { test_skip(true, HAVE_LIBMEMCACHED); test_skip(true, has_memcached()); + + server_startup_st *servers= (server_startup_st*)object; + test_true(servers); + servers->clear(); + + testing_service= "memcached"; + return TEST_SUCCESS; } -test_st memcached_tests[] ={ - {"memcached startup-shutdown", 0, memcached_cycle_test }, - {"memcached-light startup-shutdown", 0, memcached_light_cycle_TEST }, - {"memcached(socket file) startup-shutdown", 0, memcached_socket_cycle_test }, - {"memcached_sasl() startup-shutdown", 0, memcached_sasl_test }, +test_st memcached_TESTS[] ={ + {"memcached startup-shutdown", 0, server_startup_TEST }, + {"memcached(socket file) startup-shutdown", 0, socket_server_startup_TEST }, {"_compare(memcached_return_t)", 0, _compare_memcached_return_t_test }, {0, 0, 0} }; @@ -963,7 +968,7 @@ collection_st collection[] ={ {"directories", 0, 0, directories_tests}, {"comparison", 0, 0, comparison_tests}, {"gearmand", check_for_gearman, 0, gearmand_tests}, - {"memcached", check_for_libmemcached, 0, memcached_tests}, + {"memcached", check_for_libmemcached, 0, memcached_TESTS }, {"drizzled", check_for_drizzle, 0, drizzled_tests}, {"cmdline", 0, 0, cmdline_tests}, {"application", 0, 0, application_tests},