From: Brian Aker Date: Mon, 27 Feb 2012 23:13:08 +0000 (-0800) Subject: Update for logic for server_create. X-Git-Tag: 1.0.5~21 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=7773f76bd15be71f7d1a5579006b786584d3fe26;p=awesomized%2Flibmemcached Update for logic for server_create. --- diff --git a/libtest/blobslap_worker.cc b/libtest/blobslap_worker.cc index 5bf5f535..fe1cdce3 100644 --- a/libtest/blobslap_worker.cc +++ b/libtest/blobslap_worker.cc @@ -142,17 +142,17 @@ public: return true; } - bool build(int argc, const char *argv[]); + bool build(size_t argc, const char *argv[]); }; #include -bool BlobslapWorker::build(int argc, const char *argv[]) +bool BlobslapWorker::build(size_t argc, const char *argv[]) { std::stringstream arg_buffer; - for (int x= 1 ; x < argc ; x++) + for (size_t x= 0 ; x < argc ; x++) { add_option(argv[x]); } diff --git a/libtest/gearmand.cc b/libtest/gearmand.cc index dda38fbd..4a544f10 100644 --- a/libtest/gearmand.cc +++ b/libtest/gearmand.cc @@ -200,10 +200,10 @@ public: return true; } - bool build(int argc, const char *argv[]); + bool build(size_t argc, const char *argv[]); }; -bool Gearmand::build(int argc, const char *argv[]) +bool Gearmand::build(size_t argc, const char *argv[]) { std::stringstream arg_buffer; @@ -214,7 +214,7 @@ bool Gearmand::build(int argc, const char *argv[]) add_option("--listen=localhost"); - for (int x= 1 ; x < argc ; x++) + for (size_t x= 0 ; x < argc ; x++) { add_option(argv[x]); } diff --git a/libtest/memcached.cc b/libtest/memcached.cc index 7e396c30..271e2c3b 100644 --- a/libtest/memcached.cc +++ b/libtest/memcached.cc @@ -192,7 +192,7 @@ public: bool has_socket_file_option() const { - return true; + return has_socket(); } void socket_file_option(Application& app, const std::string& socket_arg) @@ -219,7 +219,7 @@ public: return true; } - bool build(int argc, const char *argv[]); + bool build(size_t argc, const char *argv[]); }; class MemcachedSaSL : public Memcached @@ -312,7 +312,7 @@ public: #include -bool Memcached::build(int argc, const char *argv[]) +bool Memcached::build(size_t argc, const char *argv[]) { std::stringstream arg_buffer; diff --git a/libtest/server.cc b/libtest/server.cc index c29d8c43..182e6f3e 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -70,7 +70,6 @@ std::ostream& operator<<(std::ostream& output, const Server &arg) output << " Exec:" << arg.running(); } - return output; // for multiple << operators } @@ -138,7 +137,7 @@ bool Server::start() fatal_message("has_pid() failed, programer error"); } - Application app(name(), is_libtool()); + Application app(executable(), is_libtool()); if (args(app) == false) { Error << "Could not build command()"; @@ -151,10 +150,11 @@ bool Server::start() Error << "Application::run() " << ret; return false; } + _running= app.print(); if (Application::SUCCESS != (ret= app.wait())) { - Error << "Application::wait() " << ret; + Error << "Application::wait() " << app.print() << " " << ret; return false; } @@ -332,9 +332,10 @@ bool Server::args(Application& app) app.add_option(daemon_file_option()); } - if (_is_socket and has_socket_file_option()) + if (has_socket_file_option()) { - if (not set_socket_file()) + Error << "adding socket option "; + if (set_socket_file() == false) { return false; } diff --git a/libtest/server.h b/libtest/server.h index 9c8f048b..b193fb8f 100644 --- a/libtest/server.h +++ b/libtest/server.h @@ -97,7 +97,7 @@ public: { if (arg.empty() == false) { - std::string buffer("--socket="); + std::string buffer("--pid-file="); buffer+= arg; app.add_option(buffer); } @@ -164,7 +164,7 @@ public: virtual pid_t get_pid(bool error_is_ok= false)= 0; - virtual bool build(int argc, const char *argv[])= 0; + virtual bool build(size_t argc, const char *argv[])= 0; void add_option(const std::string&); void add_option(const std::string&, const std::string&); diff --git a/libtest/unittest.cc b/libtest/unittest.cc index 484b4443..53fb605f 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -236,8 +236,7 @@ static test_return_t gearmand_cycle_test(void *object) test_skip(true, has_gearmand_binary()); #endif - const char *argv[1]= { "cycle_gearmand" }; - test_true(server_startup(*servers, "gearmand", get_free_port(), 1, argv)); + test_true(server_startup(*servers, "gearmand", get_free_port(), 0, NULL)); return TEST_SUCCESS; } @@ -250,8 +249,7 @@ static test_return_t memcached_cycle_test(void *object) if (MEMCACHED_BINARY and HAVE_LIBMEMCACHED) { test_true(has_memcached_binary()); - const char *argv[1]= { "cycle_memcached" }; - test_true(server_startup(*servers, "memcached", get_free_port(), 1, argv)); + test_true(server_startup(*servers, "memcached", get_free_port(), 0, NULL)); return TEST_SUCCESS; } @@ -269,8 +267,7 @@ static test_return_t memcached_socket_cycle_test(void *object) if (HAVE_LIBMEMCACHED) { test_true(has_memcached_binary()); - const char *argv[1]= { "cycle_memcached" }; - test_true(servers->start_socket_server("memcached", get_free_port(), 1, argv)); + test_true(servers->start_socket_server("memcached", get_free_port(), 0, NULL)); return TEST_SUCCESS; } @@ -294,8 +291,7 @@ static test_return_t memcached_sasl_test(void *object) if (HAVE_LIBMEMCACHED) { test_true(has_memcached_sasl_binary()); - const char *argv[1]= { "cycle_memcached_sasl" }; - test_true(server_startup(*servers, "memcached-sasl", get_free_port(), 1, argv)); + test_true(server_startup(*servers, "memcached-sasl", get_free_port(), 0, NULL)); return TEST_SUCCESS; } diff --git a/tests/libmemcached_world.h b/tests/libmemcached_world.h index 9f8b657a..18137986 100644 --- a/tests/libmemcached_world.h +++ b/tests/libmemcached_world.h @@ -78,17 +78,16 @@ static void *world_create(libtest::server_startup_st& servers, test_return_t& er { in_port_t port= libtest::get_free_port(); - const char *argv[1]= { "memcached" }; if (servers.sasl()) { - if (server_startup(servers, "memcached-sasl", port, 1, argv) == false) + if (server_startup(servers, "memcached-sasl", port, 0, NULL) == false) { fatal_message("Could not start memcached-sasl"); } } else { - if (server_startup(servers, "memcached", port, 1, argv) == false) + if (server_startup(servers, "memcached", port, 0, NULL) == false) { fatal_message("Could not start memcached"); } diff --git a/tests/memcapable.cc b/tests/memcapable.cc index 75b93995..ae50fefa 100644 --- a/tests/memcapable.cc +++ b/tests/memcapable.cc @@ -113,8 +113,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memcapable" }; - if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) + if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } diff --git a/tests/memcat.cc b/tests/memcat.cc index 23d59325..e51cdce1 100644 --- a/tests/memcat.cc +++ b/tests/memcat.cc @@ -50,16 +50,7 @@ using namespace libtest; #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif -static std::string executable; - -static test_return_t quiet_test(void *) -{ - const char *args[]= { "--quiet", 0 }; - - test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} +static std::string executable("clients/memcat"); static test_return_t help_test(void *) { @@ -122,7 +113,6 @@ static test_return_t NOT_FOUND_test(void *) } test_st memcat_tests[] ={ - {"--quiet", true, quiet_test }, {"--help", true, help_test }, {"cat(FOUND)", true, cat_test }, {"cat(NOT_FOUND)", true, NOT_FOUND_test }, @@ -142,8 +132,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memcat" }; - if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 0, NULL)) { error= TEST_FAILURE; } @@ -154,7 +143,6 @@ static void *world_create(server_startup_st& servers, test_return_t& error) void get_world(Framework *world) { - executable= "clients/memcat"; world->collections= collection; world->_create= world_create; } diff --git a/tests/memcp.cc b/tests/memcp.cc index 99f3e02d..eab8cfa5 100644 --- a/tests/memcp.cc +++ b/tests/memcp.cc @@ -50,16 +50,7 @@ using namespace libtest; #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif -static std::string executable; - -static test_return_t quiet_test(void *) -{ - const char *args[]= { "--quiet", 0 }; - - test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} +static std::string executable("./clients/memcp"); static test_return_t help_test(void *) { @@ -82,7 +73,6 @@ static test_return_t server_test(void *) } test_st memcp_tests[] ={ - {"--quiet", true, quiet_test }, {"--help", true, help_test }, {"--server_test", true, server_test }, {0, 0, 0} @@ -101,8 +91,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memcp" }; - if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) + if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } @@ -113,7 +102,6 @@ static void *world_create(server_startup_st& servers, test_return_t& error) void get_world(Framework *world) { - executable= "./clients/memcp"; world->collections= collection; world->_create= world_create; } diff --git a/tests/memdump.cc b/tests/memdump.cc index c1ff1940..4a308921 100644 --- a/tests/memdump.cc +++ b/tests/memdump.cc @@ -50,16 +50,7 @@ using namespace libtest; #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif -static std::string executable; - -static test_return_t quiet_test(void *) -{ - const char *args[]= { "--quiet", 0 }; - - test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} +static std::string executable("./clients/memdump"); static test_return_t help_test(void *) { @@ -108,7 +99,6 @@ static test_return_t FOUND_test(void *) } test_st memdump_tests[] ={ - {"--quiet", true, quiet_test }, {"--help", true, help_test }, {"--server", true, server_test }, {"FOUND", true, FOUND_test }, @@ -128,8 +118,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memdump" }; - if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) + if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } @@ -140,7 +129,6 @@ static void *world_create(server_startup_st& servers, test_return_t& error) void get_world(Framework *world) { - executable= "./clients/memdump"; world->collections= collection; world->_create= world_create; } diff --git a/tests/memerror.cc b/tests/memerror.cc index 00863475..914d2a03 100644 --- a/tests/memerror.cc +++ b/tests/memerror.cc @@ -50,7 +50,7 @@ using namespace libtest; #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif -static std::string executable; +static std::string executable("./clients/memerror"); static test_return_t help_TEST(void *) { @@ -119,7 +119,6 @@ static void *world_create(server_startup_st&, test_return_t&) void get_world(Framework *world) { - executable= "./clients/memerror"; world->collections= collection; world->_create= world_create; } diff --git a/tests/memexist.cc b/tests/memexist.cc index 6cc1f051..a0fec9e0 100644 --- a/tests/memexist.cc +++ b/tests/memexist.cc @@ -131,8 +131,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memexist" }; - if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) + if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } diff --git a/tests/memflush.cc b/tests/memflush.cc index d1184722..f14b5b72 100644 --- a/tests/memflush.cc +++ b/tests/memflush.cc @@ -101,8 +101,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memflush" }; - if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) + if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == 0) { error= TEST_FAILURE; } diff --git a/tests/memrm.cc b/tests/memrm.cc index e422a19d..8d6109c0 100644 --- a/tests/memrm.cc +++ b/tests/memrm.cc @@ -50,7 +50,7 @@ using namespace libtest; #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif -static std::string executable; +static std::string executable("./clients/memrm"); static test_return_t quiet_test(void *) { @@ -152,8 +152,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memrm" }; - if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) + if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } @@ -164,7 +163,6 @@ static void *world_create(server_startup_st& servers, test_return_t& error) void get_world(Framework *world) { - executable= "./clients/memrm"; world->collections= collection; world->_create= world_create; } diff --git a/tests/memstat.cc b/tests/memstat.cc index 6bb8c053..ae8679fb 100644 --- a/tests/memstat.cc +++ b/tests/memstat.cc @@ -113,8 +113,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memstat" }; - if (server_startup(servers, "memcached", libtest::default_port(), 1, argv) == false) + if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } diff --git a/tests/memtouch.cc b/tests/memtouch.cc index a09bd40a..df597e0f 100644 --- a/tests/memtouch.cc +++ b/tests/memtouch.cc @@ -128,8 +128,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) return NULL; } - const char *argv[1]= { "memtouch" }; - if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) + if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; }