From: Brian Aker Date: Mon, 20 Feb 2012 09:41:05 +0000 (-0800) Subject: Free port logic X-Git-Tag: 1.0.7~17^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=1d6aaf09ebb2aafad07307f736d7bab6fdb79d2c;hp=da8731f513af0fcd2011e244a065f164241bced3;p=awesomized%2Flibmemcached Free port logic --- diff --git a/libtest/fatal.cc b/libtest/fatal.cc new file mode 100644 index 00000000..36683a48 --- /dev/null +++ b/libtest/fatal.cc @@ -0,0 +1,68 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest + * + * Copyright (C) 2012 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +namespace libtest { + +fatal::fatal(const char *file, int line, const char *func, const char *format, ...) : + std::runtime_error(func) + { + va_list args; + va_start(args, format); + char last_error[BUFSIZ]; + (void)vsnprintf(last_error, sizeof(last_error), format, args); + va_end(args); + + snprintf(_error_message, sizeof(_error_message), "%s:%d FATAL:%s (%s)", file, int(line), last_error, func); + } + +static bool _disabled= false; +static uint32_t _counter= 0; + +bool fatal::is_disabled() +{ + return _disabled; +} + +bool fatal::disable() +{ + _disabled= true; +} + +bool fatal::enable() +{ + _disabled= false; +} + +uint32_t fatal::disabled_counter() +{ + return _counter; +} + +void fatal::increment_disabled_counter() +{ + _counter++; +} + +} // namespace libtest + diff --git a/libtest/fatal.hpp b/libtest/fatal.hpp new file mode 100644 index 00000000..b64b3606 --- /dev/null +++ b/libtest/fatal.hpp @@ -0,0 +1,58 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest + * + * Copyright (C) 2012 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#pragma once + +#include + +#ifndef __PRETTY_FUNCTION__ +#define __PRETTY_FUNCTION__ __func__ +#endif + +#define LIBYATL_DEFAULT_PARAM __FILE__, __LINE__, __PRETTY_FUNCTION__ + +namespace libtest { + +class fatal : std::runtime_error +{ +public: + fatal(const char *file, int line, const char *func, const char *format, ...); + + const char* what() const throw() + { + return _error_message; + } + + // The following are just for unittesting the exception class + static bool is_disabled(); + static bool disable(); + static bool enable(); + static uint32_t disabled_counter(); + static void increment_disabled_counter(); + +private: + char _error_message[BUFSIZ]; +}; + + +} // namespace libtest + +#define fatal_message(__mesg) libtest::fatal(LIBYATL_DEFAULT_PARAM, __mesg) diff --git a/libtest/include.am b/libtest/include.am index 0ad8da4f..257b1f7f 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -67,6 +67,7 @@ noinst_HEADERS+= \ libtest/dream.h \ libtest/error.h \ libtest/failed.h \ + libtest/fatal.hpp \ libtest/framework.h \ libtest/gearmand.h \ libtest/get.h \ @@ -99,6 +100,7 @@ libtest_libtest_la_SOURCES= \ libtest/cmdline.cc \ libtest/core.cc \ libtest/dream.cc \ + libtest/fatal.cc \ libtest/framework.cc \ libtest/has.cc \ libtest/http.cc \ diff --git a/libtest/port.cc b/libtest/port.cc index c1f2f945..b6820335 100644 --- a/libtest/port.cc +++ b/libtest/port.cc @@ -45,66 +45,78 @@ using namespace libtest; +struct socket_st { + std::vector fd; + + ~socket_st() + { + for(std::vector::iterator iter= fd.begin(); iter != fd.end(); iter++) + { + close(*iter); + } + } +}; + +static socket_st all_socket_fd; + static in_port_t global_port= 0; -static in_port_t global_max_port= 0; namespace libtest { in_port_t default_port() { - return global_port; -} - -void set_default_port(in_port_t port) -{ - global_port= port; -} - -in_port_t max_port() -{ - return global_max_port; -} - -void set_max_port(in_port_t port) -{ - if (port > global_max_port) + if (global_port == 0) { - global_max_port= port; + global_port= get_free_port(); } - global_max_port= port; + return global_port; } in_port_t get_free_port() { in_port_t ret_port= in_port_t(0); - int sd; - if ((sd= socket(AF_INET, SOCK_STREAM, 0)) != -1) + + int retries= 1024; + + while (retries--) { - int optval= 1; - if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) != -1) + int sd; + if ((sd= socket(AF_INET, SOCK_STREAM, 0)) != -1) { - struct sockaddr_in sin; - sin.sin_port= 0; - sin.sin_addr.s_addr= 0; - sin.sin_addr.s_addr= INADDR_ANY; - sin.sin_family= AF_INET; - - if (bind(sd, (struct sockaddr *)&sin,sizeof(struct sockaddr_in) ) != -1) + int optval= 1; + if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) != -1) { - socklen_t addrlen= sizeof(sin); + struct sockaddr_in sin; + sin.sin_port= 0; + sin.sin_addr.s_addr= 0; + sin.sin_addr.s_addr= INADDR_ANY; + sin.sin_family= AF_INET; - if (listen(sd, 100) != -1) + if (bind(sd, (struct sockaddr *)&sin,sizeof(struct sockaddr_in) ) != -1) { + socklen_t addrlen= sizeof(sin); + if (getsockname(sd, (struct sockaddr *)&sin, &addrlen) != -1) { ret_port= sin.sin_port; } } } + + all_socket_fd.fd.push_back(sd); + } + + if (ret_port > 1024) + { + break; } + } - close(sd); + // We handle the case where if we max out retries, we still abort. + if (ret_port <= 1024) + { + throw fatal_message("No port could be found"); } return ret_port; diff --git a/libtest/port.h b/libtest/port.h index d6fbcb25..a7accaec 100644 --- a/libtest/port.h +++ b/libtest/port.h @@ -31,15 +31,6 @@ namespace libtest { LIBTEST_API in_port_t default_port(); -LIBTEST_API -void set_default_port(in_port_t port); - -LIBTEST_API -in_port_t max_port(); - -LIBTEST_API -void set_max_port(in_port_t port); - LIBTEST_API in_port_t get_free_port(); diff --git a/libtest/server_container.cc b/libtest/server_container.cc index 2c31796f..528fcd1f 100644 --- a/libtest/server_container.cc +++ b/libtest/server_container.cc @@ -146,23 +146,6 @@ bool server_startup(server_startup_st& construct, const std::string& server_type Outn(); (void)try_port; - set_max_port(try_port); - - // Look to see if we are being provided ports to use - { - char variable_buffer[1024]; - snprintf(variable_buffer, sizeof(variable_buffer), "LIBTEST_PORT_%lu", (unsigned long)construct.count()); - - char *var; - if ((var= getenv(variable_buffer))) - { - in_port_t tmp= in_port_t(atoi(var)); - - if (tmp > 0) - try_port= tmp; - } - } - libtest::Server *server= NULL; if (0) { } @@ -249,12 +232,6 @@ bool server_startup(server_startup_st& construct, const std::string& server_type construct.push_server(server); - if (default_port() == 0) - { - assert(server->has_port()); - set_default_port(server->port()); - } - Outn(); return true; diff --git a/libtest/test.cc b/libtest/test.cc index 52dd03e7..92c1226b 100644 --- a/libtest/test.cc +++ b/libtest/test.cc @@ -188,257 +188,286 @@ int main(int argc, char *argv[]) } int exit_code; - do { - exit_code= EXIT_SUCCESS; - Framework *world= new Framework(); - if (world == NULL) - { - Error << "Failed to create Framework()"; - return EXIT_FAILURE; - } - - assert(sigignore(SIGPIPE) == 0); - - libtest::SignalThread signal; - if (not signal.setup()) - { - Error << "Failed to setup signals"; - return EXIT_FAILURE; - } - - Stats stats; - - get_world(world); - - test_return_t error; - void *creators_ptr= world->create(error); + try { + do { + exit_code= EXIT_SUCCESS; + Framework *world= new Framework(); - switch (error) - { - case TEST_SUCCESS: - break; - - case TEST_SKIPPED: - Out << "SKIP " << argv[0]; - delete world; - return EXIT_SUCCESS; - - case TEST_FATAL: - case TEST_FAILURE: - case TEST_MEMORY_ALLOCATION_FAILURE: - delete world; - return EXIT_FAILURE; - } - - if (getenv("TEST_COLLECTION")) - { - if (strlen(getenv("TEST_COLLECTION"))) + if (world == NULL) { - collection_to_run= getenv("TEST_COLLECTION"); + Error << "Failed to create Framework()"; + return EXIT_FAILURE; } - } - - if (collection_to_run.empty() == false) - { - Out << "Only testing " << collection_to_run; - } - char *wildcard= NULL; - if (argc == 3) - { - wildcard= argv[2]; - } - - for (collection_st *next= world->collections; next and next->name and (not signal.is_shutdown()); next++) - { - bool failed= false; - bool skipped= false; + assert(sigignore(SIGPIPE) == 0); - if (collection_to_run.empty() == false and fnmatch(collection_to_run.c_str(), next->name, 0)) + libtest::SignalThread signal; + if (not signal.setup()) { - continue; + Error << "Failed to setup signals"; + return EXIT_FAILURE; } - stats.collection_total++; + Stats stats; - test_return_t collection_rc= world->startup(creators_ptr); + get_world(world); - if (collection_rc == TEST_SUCCESS and next->pre) - { - collection_rc= world->runner()->pre(next->pre, creators_ptr); - } + test_return_t error; + void *creators_ptr= world->create(error); - switch (collection_rc) + switch (error) { case TEST_SUCCESS: break; + case TEST_SKIPPED: + Out << "SKIP " << argv[0]; + delete world; + return EXIT_SUCCESS; + case TEST_FATAL: case TEST_FAILURE: - Out << next->name << " [ failed ]"; - failed= true; - signal.set_shutdown(SHUTDOWN_GRACEFUL); - goto cleanup; + case TEST_MEMORY_ALLOCATION_FAILURE: + delete world; + return EXIT_FAILURE; + } - case TEST_SKIPPED: - Out << next->name << " [ skipping ]"; - skipped= true; - goto cleanup; + if (getenv("TEST_COLLECTION")) + { + if (strlen(getenv("TEST_COLLECTION"))) + { + collection_to_run= getenv("TEST_COLLECTION"); + } + } - case TEST_MEMORY_ALLOCATION_FAILURE: - test_assert(0, "Allocation failure, or unknown return"); + if (collection_to_run.empty() == false) + { + Out << "Only testing " << collection_to_run; } - Out << "Collection: " << next->name; + char *wildcard= NULL; + if (argc == 3) + { + wildcard= argv[2]; + } - for (test_st *run= next->tests; run->name; run++) + for (collection_st *next= world->collections; next and next->name and (not signal.is_shutdown()); next++) { - struct timeval start_time, end_time; - long int load_time= 0; + bool failed= false; + bool skipped= false; - if (wildcard && fnmatch(wildcard, run->name, 0)) + if (collection_to_run.empty() == false and fnmatch(collection_to_run.c_str(), next->name, 0)) { continue; } - test_return_t return_code; - try { - if (test_success(return_code= world->item.startup(creators_ptr))) + stats.collection_total++; + + test_return_t collection_rc= world->startup(creators_ptr); + + if (collection_rc == TEST_SUCCESS and next->pre) + { + collection_rc= world->runner()->pre(next->pre, creators_ptr); + } + + switch (collection_rc) + { + case TEST_SUCCESS: + break; + + case TEST_FATAL: + case TEST_FAILURE: + Out << next->name << " [ failed ]"; + failed= true; + signal.set_shutdown(SHUTDOWN_GRACEFUL); + goto cleanup; + + case TEST_SKIPPED: + Out << next->name << " [ skipping ]"; + skipped= true; + goto cleanup; + + case TEST_MEMORY_ALLOCATION_FAILURE: + test_assert(0, "Allocation failure, or unknown return"); + } + + Out << "Collection: " << next->name; + + for (test_st *run= next->tests; run->name; run++) + { + struct timeval start_time, end_time; + long int load_time= 0; + + if (wildcard && fnmatch(wildcard, run->name, 0)) { - if (test_success(return_code= world->item.flush(creators_ptr, run))) + continue; + } + + test_return_t return_code; + try { + if (test_success(return_code= world->item.startup(creators_ptr))) { - // @note pre will fail is SKIPPED is returned - if (test_success(return_code= world->item.pre(creators_ptr))) + if (test_success(return_code= world->item.flush(creators_ptr, run))) { - { // Runner Code - gettimeofday(&start_time, NULL); - assert(world->runner()); - assert(run->test_fn); - return_code= world->runner()->run(run->test_fn, creators_ptr); - gettimeofday(&end_time, NULL); - load_time= timedif(end_time, start_time); + // @note pre will fail is SKIPPED is returned + if (test_success(return_code= world->item.pre(creators_ptr))) + { + { // Runner Code + gettimeofday(&start_time, NULL); + assert(world->runner()); + assert(run->test_fn); + try + { + return_code= world->runner()->run(run->test_fn, creators_ptr); + } + // Special case where check for the testing of the exception + // system. + catch (libtest::fatal &e) + { + if (fatal::is_disabled()) + { + fatal::increment_disabled_counter(); + return_code= TEST_SUCCESS; + } + else + { + throw; + } + } + + gettimeofday(&end_time, NULL); + load_time= timedif(end_time, start_time); + } } - } - // @todo do something if post fails - (void)world->item.post(creators_ptr); + // @todo do something if post fails + (void)world->item.post(creators_ptr); + } + else if (return_code == TEST_SKIPPED) + { } + else if (return_code == TEST_FAILURE) + { + Error << " item.flush(failure)"; + signal.set_shutdown(SHUTDOWN_GRACEFUL); + } } else if (return_code == TEST_SKIPPED) { } else if (return_code == TEST_FAILURE) { - Error << " item.flush(failure)"; + Error << " item.startup(failure)"; signal.set_shutdown(SHUTDOWN_GRACEFUL); } } - else if (return_code == TEST_SKIPPED) - { } - else if (return_code == TEST_FAILURE) + + catch (std::exception &e) + { + Error << "Exception was thrown: " << e.what(); + return_code= TEST_FAILURE; + } + catch (...) { - Error << " item.startup(failure)"; + Error << "Unknown exception occurred"; + return_code= TEST_FAILURE; + } + + stats.total++; + + switch (return_code) + { + case TEST_SUCCESS: + Out << "\tTesting " << run->name << "\t\t\t\t\t" << load_time / 1000 << "." << load_time % 1000 << "[ " << test_strerror(return_code) << " ]"; + stats.success++; + break; + + case TEST_FATAL: + case TEST_FAILURE: + stats.failed++; + failed= true; + Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]"; + break; + + case TEST_SKIPPED: + stats.skipped++; + skipped= true; + Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]"; + break; + + case TEST_MEMORY_ALLOCATION_FAILURE: + test_assert(0, "Memory Allocation Error"); + } + + if (test_failed(world->on_error(return_code, creators_ptr))) + { + Error << "Failed while running on_error()"; signal.set_shutdown(SHUTDOWN_GRACEFUL); + break; } } - catch (std::exception &e) - { - Error << "Exception was thrown: " << e.what(); - return_code= TEST_FAILURE; - } - catch (...) + (void) world->runner()->post(next->post, creators_ptr); + +cleanup: + if (failed == false and skipped == false) { - Error << "Unknown exception occurred"; - return_code= TEST_FAILURE; + stats.collection_success++; } - stats.total++; - - switch (return_code) + if (failed) { - case TEST_SUCCESS: - Out << "\tTesting " << run->name << "\t\t\t\t\t" << load_time / 1000 << "." << load_time % 1000 << "[ " << test_strerror(return_code) << " ]"; - stats.success++; - break; - - case TEST_FATAL: - case TEST_FAILURE: - stats.failed++; - failed= true; - Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]"; - break; - - case TEST_SKIPPED: - stats.skipped++; - skipped= true; - Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]"; - break; - - case TEST_MEMORY_ALLOCATION_FAILURE: - test_assert(0, "Memory Allocation Error"); + stats.collection_failed++; } - if (test_failed(world->on_error(return_code, creators_ptr))) + if (skipped) { - Error << "Failed while running on_error()"; - signal.set_shutdown(SHUTDOWN_GRACEFUL); - break; + stats.collection_skipped++; } - } - (void) world->runner()->post(next->post, creators_ptr); + world->shutdown(creators_ptr); + Outn(); + } -cleanup: - if (failed == false and skipped == false) + if (not signal.is_shutdown()) { - stats.collection_success++; + signal.set_shutdown(SHUTDOWN_GRACEFUL); } - if (failed) + shutdown_t status= signal.get_shutdown(); + if (status == SHUTDOWN_FORCED) { - stats.collection_failed++; + Out << "Tests were aborted."; + exit_code= EXIT_FAILURE; } - - if (skipped) + else if (stats.collection_failed) { - stats.collection_skipped++; + Out << "Some test failed."; + exit_code= EXIT_FAILURE; + } + else if (stats.collection_skipped and stats.collection_failed and stats.collection_success) + { + Out << "Some tests were skipped."; + } + else if (stats.collection_success and stats.collection_failed == 0) + { + Out << "All tests completed successfully."; } - world->shutdown(creators_ptr); - Outn(); - } - - if (not signal.is_shutdown()) - { - signal.set_shutdown(SHUTDOWN_GRACEFUL); - } - - shutdown_t status= signal.get_shutdown(); - if (status == SHUTDOWN_FORCED) - { - Out << "Tests were aborted."; - exit_code= EXIT_FAILURE; - } - else if (stats.collection_failed) - { - Out << "Some test failed."; - exit_code= EXIT_FAILURE; - } - else if (stats.collection_skipped and stats.collection_failed and stats.collection_success) - { - Out << "Some tests were skipped."; - } - else if (stats.collection_success and stats.collection_failed == 0) - { - Out << "All tests completed successfully."; - } - - stats_print(&stats); + stats_print(&stats); - delete world; + delete world; - Outn(); // Generate a blank to break up the messages if make check/test has been run - } while (exit_code == EXIT_SUCCESS and opt_repeat); + Outn(); // Generate a blank to break up the messages if make check/test has been run + } while (exit_code == EXIT_SUCCESS and opt_repeat); + } + catch (libtest::fatal& e) + { + std::cerr << e.what() << std::endl; + } + catch (...) + { + std::cerr << "Unknown exception halted execution" << std::endl; + } return exit_code; } diff --git a/libtest/test.hpp b/libtest/test.hpp index b86bc68e..b77cd214 100644 --- a/libtest/test.hpp +++ b/libtest/test.hpp @@ -33,6 +33,7 @@ #include #include +#include #include #include diff --git a/libtest/unittest.cc b/libtest/unittest.cc index 21dcbc74..484b4443 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -510,6 +510,36 @@ static test_return_t get_free_port_TEST(void *) { in_port_t ret_port; test_true_hint((ret_port= get_free_port()), ret_port); + test_true(get_free_port() != default_port()); + test_true(get_free_port() != get_free_port()); + + return TEST_SUCCESS; +} + +static uint32_t fatal_calls= 0; + +static test_return_t fatal_TEST(void *) +{ + test_compare(fatal_calls++, fatal::disabled_counter()); + throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "Testing va_args based fatal(): %d", 10); + + return TEST_SUCCESS; +} + +static test_return_t fatal_message_TEST(void *) +{ + test_compare(fatal_calls++, fatal::disabled_counter()); + throw fatal_message("Fatal test"); + + return TEST_SUCCESS; +} + +static test_return_t default_port_TEST(void *) +{ + in_port_t ret_port= default_port(); + test_compare(ret_port, libtest::default_port()); + test_compare(ret_port, libtest::default_port()); + return TEST_SUCCESS; } @@ -599,6 +629,13 @@ test_st cmdline_tests[] ={ test_st get_free_port_TESTS[] ={ {"get_free_port()", 0, get_free_port_TEST }, + {"default_port()", 0, default_port_TEST }, + {0, 0, 0} +}; + +test_st fatal_message_TESTS[] ={ + {"libtest::fatal", 0, fatal_TEST }, + {"fatal_message()", 0, fatal_message_TEST }, {0, 0, 0} }; @@ -619,6 +656,18 @@ static test_return_t check_for_curl(void *) return TEST_SUCCESS; } +static test_return_t disable_fatal_exception(void *) +{ + fatal::disable(); + return TEST_SUCCESS; +} + +static test_return_t enable_fatal_exception(void *) +{ + fatal::disable(); + return TEST_SUCCESS; +} + test_st http_tests[] ={ {"GET", 0, GET_TEST }, {"POST", 0, POST_TEST }, @@ -637,7 +686,8 @@ collection_st collection[] ={ {"cmdline", 0, 0, cmdline_tests}, {"application", 0, 0, application_tests}, {"http", check_for_curl, 0, http_tests}, - {"get_free_port()", 0, 0, get_free_port_TESTS}, + {"get_free_port()", 0, 0, get_free_port_TESTS }, + {"fatal", disable_fatal_exception, enable_fatal_exception, fatal_message_TESTS }, {0, 0, 0, 0} }; diff --git a/tests/failure.cc b/tests/failure.cc index 1348e50c..699ef46c 100644 --- a/tests/failure.cc +++ b/tests/failure.cc @@ -76,9 +76,8 @@ static test_return_t add_shutdown_servers(memcached_st *memc) while (memcached_server_count(memc) < 2) { const char *argv[1]= { "add_shutdown_server" }; - in_port_t port= max_port() +1; - test_true(global_framework->servers().start_socket_server("memcached", port, 1, argv)); - test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "localhost", port)); + test_true(global_framework->servers().start_socket_server("memcached", libtest::default_port(), 1, argv)); + test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "localhost", libtest::default_port())); } // Disable a single server, just the first diff --git a/tests/memcapable.cc b/tests/memcapable.cc index 048333ee..75b93995 100644 --- a/tests/memcapable.cc +++ b/tests/memcapable.cc @@ -114,7 +114,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memcapable" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } diff --git a/tests/memcat.cc b/tests/memcat.cc index bb496a1e..23d59325 100644 --- a/tests/memcat.cc +++ b/tests/memcat.cc @@ -143,7 +143,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memcat" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } diff --git a/tests/memcp.cc b/tests/memcp.cc index 7ce19101..99f3e02d 100644 --- a/tests/memcp.cc +++ b/tests/memcp.cc @@ -102,7 +102,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memcp" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } diff --git a/tests/memdump.cc b/tests/memdump.cc index 80a3fe6b..c1ff1940 100644 --- a/tests/memdump.cc +++ b/tests/memdump.cc @@ -129,7 +129,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memdump" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } diff --git a/tests/memexist.cc b/tests/memexist.cc index 091a8bbe..ed2546d3 100644 --- a/tests/memexist.cc +++ b/tests/memexist.cc @@ -141,7 +141,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memexist" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } diff --git a/tests/memflush.cc b/tests/memflush.cc index 5339f4e2..d1184722 100644 --- a/tests/memflush.cc +++ b/tests/memflush.cc @@ -102,7 +102,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memflush" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } diff --git a/tests/memrm.cc b/tests/memrm.cc index 23003bee..8ca4445e 100644 --- a/tests/memrm.cc +++ b/tests/memrm.cc @@ -140,7 +140,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memrm" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } diff --git a/tests/memslap.cc b/tests/memslap.cc index 55c89111..6f990af4 100644 --- a/tests/memslap.cc +++ b/tests/memslap.cc @@ -174,7 +174,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memslap" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } diff --git a/tests/memstat.cc b/tests/memstat.cc index c99836ac..2ffb26bd 100644 --- a/tests/memstat.cc +++ b/tests/memstat.cc @@ -73,7 +73,7 @@ static test_return_t help_test(void *) static test_return_t binary_TEST(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port())); const char *args[]= { "--quiet", buffer, " --binary ", 0 }; test_true(exec_cmdline(executable, args)); @@ -83,7 +83,7 @@ static test_return_t binary_TEST(void *) static test_return_t server_version_TEST(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port())); const char *args[]= { "--quiet", buffer, " --server-version", 0 }; test_true(exec_cmdline(executable, args)); @@ -93,7 +93,7 @@ static test_return_t server_version_TEST(void *) static test_return_t binary_server_version_TEST(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port())); const char *args[]= { "--quiet", buffer, " --binary --server-version", 0 }; test_true(exec_cmdline(executable, args)); @@ -123,7 +123,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memstat" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (server_startup(servers, "memcached", libtest::default_port(), 1, argv) == false) { error= TEST_FAILURE; } diff --git a/tests/memtouch.cc b/tests/memtouch.cc index 0b28cbc7..6813eb8d 100644 --- a/tests/memtouch.cc +++ b/tests/memtouch.cc @@ -135,7 +135,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } const char *argv[1]= { "memtouch" }; - if (not server_startup(servers, "memcached", libtest::get_free_port(), 1, argv)) + if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; }