From: Tomek Mrugalski Date: Mon, 11 Aug 2014 20:37:29 +0000 (+0200) Subject: [3508] Changes after review X-Git-Tag: trac3482_base~46^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f46c74ffa0ea1197e1fa62cb2f6580931be35f3;p=thirdparty%2Fkea.git [3508] Changes after review - Daemon::getVersion() added - exists => exits in docs - fixed comment in dhcp_test_lib.sh.in --- diff --git a/doc/guide/ddns.xml b/doc/guide/ddns.xml index 854220b5fd..d88257ea25 100644 --- a/doc/guide/ddns.xml +++ b/doc/guide/ddns.xml @@ -82,13 +82,13 @@ - -v - prints out Kea version and exists. + -v - prints out Kea version and exits. -V - prints out Kea extended version with - additional parameters and exists. + additional parameters and exits. diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index 0eb240a0b5..3263aa73b6 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -46,13 +46,13 @@ - -v - prints out Kea version and exists. + -v - prints out Kea version and exits. -V - prints out Kea extended version with - additional parameters and exists. + additional parameters and exits. diff --git a/doc/guide/dhcp6-srv.xml b/doc/guide/dhcp6-srv.xml index 6a0afb82d9..361b8f4181 100644 --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@ -44,13 +44,13 @@ - -v - prints out Kea version and exists. + -v - prints out Kea version and exits. -V - prints out Kea extended version with - additional parameters and exists. + additional parameters and exits. diff --git a/src/bin/d2/d_controller.cc b/src/bin/d2/d_controller.cc index 6e409c9c72..29e3e288df 100644 --- a/src/bin/d2/d_controller.cc +++ b/src/bin/d2/d_controller.cc @@ -124,20 +124,6 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) { LOG_INFO(dctl_logger, DHCP_DDNS_SHUTDOWN); } -void -DControllerBase::printVersion(bool extended) const { - std::cout << VERSION << std::endl; - if (extended) { - std::cout << EXTENDED_VERSION << std::endl; - - // @todo print more details (is it Botan or OpenSSL build, - // with or without MySQL/Postgres? What compilation options were - // used? etc) - } - - exit(EXIT_SUCCESS); -} - void DControllerBase::parseArgs(int argc, char* argv[]) { @@ -156,12 +142,14 @@ DControllerBase::parseArgs(int argc, char* argv[]) break; case 'v': - printVersion(false); // print just Kea version and exit - break; // break not really needed, print_version never returns + // Print just Kea version and exit + std::cout << getVersion(false) << std::endl; + exit(EXIT_SUCCESS); case 'V': - printVersion(true); // print extended Kea version and exit - break; // break not really needed, print_version never returns + // Print extended Kea version and exit + std::cout << getVersion(true) << std::endl; + exit(EXIT_SUCCESS); case 'c': // config file name @@ -448,3 +436,19 @@ dhcp::Daemon::loggerInit(const char* log_name, bool verbose) { } }; // namespace isc + +std::string +isc::dhcp::Daemon::getVersion(bool extended) { + std::stringstream tmp; + + tmp << VERSION; + if (extended) { + tmp << std::endl << EXTENDED_VERSION; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + return (tmp.str()); +} diff --git a/src/bin/d2/d_controller.h b/src/bin/d2/d_controller.h index 3ba5280814..c1e35c9e0d 100644 --- a/src/bin/d2/d_controller.h +++ b/src/bin/d2/d_controller.h @@ -457,12 +457,6 @@ protected: /// This is intended to be used for specific usage violation messages. void usage(const std::string& text); - /// @brief Prints version number to stdout and exit. - /// - /// Note: This method never returns, it terminates the process. - /// @param extended print additional information? - void printVersion(bool extended) const; - private: /// @brief Name of the service under control. /// This name is used as the configuration module name and appears in log diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 7f711a19b0..d72f7e0fc3 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -2032,5 +2032,21 @@ Dhcpv4Srv::d2ClientErrorHandler(const CfgMgr::instance().getD2ClientMgr().suspendUpdates(); } +std::string +Daemon::getVersion(bool extended) { + std::stringstream tmp; + + tmp << VERSION; + if (extended) { + tmp << endl << EXTENDED_VERSION; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + return (tmp.str()); +} + } // namespace dhcp } // namespace isc diff --git a/src/bin/dhcp4/main.cc b/src/bin/dhcp4/main.cc index e290f68c84..56d9c1c7d5 100644 --- a/src/bin/dhcp4/main.cc +++ b/src/bin/dhcp4/main.cc @@ -60,24 +60,6 @@ usage() { } } // end of anonymous namespace -/// @brief Prints Kea version on stdout and exits. -/// -/// Note: This function never returns. It terminates the process. -/// @param extended print additional information? -void -printVersion(bool extended) { - cout << VERSION << endl; - if (extended) { - cout << EXTENDED_VERSION << endl; - - // @todo print more details (is it Botan or OpenSSL build, - // with or without MySQL/Postgres? What compilation options were - // used? etc) - } - - exit(EXIT_SUCCESS); -} - int main(int argc, char* argv[]) { int ch; @@ -95,12 +77,12 @@ main(int argc, char* argv[]) { break; case 'v': - printVersion(false); // print just Kea version and exit - break; // break not really needed, print_version never returns + cout << Daemon::getVersion(false) << endl; + return (EXIT_SUCCESS); case 'V': - printVersion(true); // print extended Kea version and exit - break; // break not really needed, print_version never returns + cout << Daemon::getVersion(false) << endl; + return (EXIT_SUCCESS); case 'p': try { diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 098293b8b7..a84cb35e01 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -2692,5 +2692,21 @@ Dhcpv6Srv::d2ClientErrorHandler(const CfgMgr::instance().getD2ClientMgr().suspendUpdates(); } +std::string +Daemon::getVersion(bool extended) { + std::stringstream tmp; + + tmp << VERSION; + if (extended) { + tmp << endl << EXTENDED_VERSION; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + return (tmp.str()); +} + }; }; diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc index 6407061ae4..ca86f6812e 100644 --- a/src/bin/dhcp6/main.cc +++ b/src/bin/dhcp6/main.cc @@ -60,24 +60,6 @@ usage() { } } // end of anonymous namespace -/// @brief Prints Kea version on stdout and exits. -/// -/// Note: This function never returns. It terminates the process. -/// @param extended print additional information? -void -printVersion(bool extended) { - cout << VERSION << endl; - if (extended) { - cout << EXTENDED_VERSION << endl; - - // @todo print more details (is it Botan or OpenSSL build, - // with or without MySQL/Postgres? What compilation options were - // used? etc) - } - - exit(EXIT_SUCCESS); -} - int main(int argc, char* argv[]) { int ch; @@ -95,12 +77,12 @@ main(int argc, char* argv[]) { break; case 'v': - printVersion(false); // print just Kea version and exit - break; // break not really needed, print_version never returns + cout << Daemon::getVersion(false) << endl; + return (EXIT_SUCCESS); case 'V': - printVersion(true); // print extended Kea version and exit - break; // break not really needed, print_version never returns + cout << Daemon::getVersion(true) << endl; + return (EXIT_SUCCESS); case 'p': // port number try { diff --git a/src/lib/dhcpsrv/daemon.h b/src/lib/dhcpsrv/daemon.h index af518b5a44..c9939a77b2 100644 --- a/src/lib/dhcpsrv/daemon.h +++ b/src/lib/dhcpsrv/daemon.h @@ -151,6 +151,17 @@ public: return (verbose_); } + /// @brief returns Kea version on stdout and exits. + /// + /// With extended == false, this method returns a simple string + /// containing version number. With extended == true, it returns + /// also additional information about sources. It is expected to + /// return extra information about dependencies and used DB backends. + /// + /// @param extended print additional information? + /// @return text string + static std::string getVersion(bool extended); + protected: /// @brief Invokes handler for the next received signal. diff --git a/src/lib/dhcpsrv/tests/daemon_unittest.cc b/src/lib/dhcpsrv/tests/daemon_unittest.cc index 7e805e5b7a..572812d3f1 100644 --- a/src/lib/dhcpsrv/tests/daemon_unittest.cc +++ b/src/lib/dhcpsrv/tests/daemon_unittest.cc @@ -23,8 +23,17 @@ using namespace isc; using namespace isc::dhcp; using namespace isc::data; +std::string isc::dhcp::Daemon::getVersion(bool extended) { + if (extended) { + return (std::string("EXTENDED")); + } else { + return (std::string("BASIC")); + } +} + namespace { + // Very simple test. Checks whether Daemon can be instantiated and its // default parameters are sane TEST(DaemonTest, constructor) { diff --git a/src/lib/testutils/dhcp_test_lib.sh.in b/src/lib/testutils/dhcp_test_lib.sh.in index 39ef7ff774..b63f7d48b5 100644 --- a/src/lib/testutils/dhcp_test_lib.sh.in +++ b/src/lib/testutils/dhcp_test_lib.sh.in @@ -402,7 +402,7 @@ must be a number" kill -${sig} ${_GET_PIDS} } -# This test verifies that DHCPv4 server is reporting its version properly. +# This test verifies that the binary is reporting its version properly. version_test() { test_name=${1} # Test name