From: Tomek Mrugalski Date: Fri, 6 Jul 2018 17:27:55 +0000 (+0200) Subject: [gitlab9] Keactrl now returns its version. X-Git-Tag: gitlab29-base~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20e5a32c1f249413d4ba980aa61f7811bdaa4003;p=thirdparty%2Fkea.git [gitlab9] Keactrl now returns its version. --- diff --git a/src/bin/keactrl/keactrl.in b/src/bin/keactrl/keactrl.in index 3510282e9f..f5fa27e0ed 100644 --- a/src/bin/keactrl/keactrl.in +++ b/src/bin/keactrl/keactrl.in @@ -10,6 +10,8 @@ # This script is used to run Kea from installation directory, # as well as for running tests. +VERSION=@PACKAGE_VERSION@ + ### Logging functions ### # Logs message at the error level. @@ -280,6 +282,13 @@ if [ -z ${command} ]; then usage exit 1 fi + +# Check if this is a simple question about version. +if test "${command}" = "-v" || test "${command}" = "--version" ; then + echo "${VERSION}" + exit 0 +fi + is_in_list "${command}" "start stop reload status" if [ ${_inlist} -eq 0 ]; then log_error "invalid command: ${command}" diff --git a/src/bin/keactrl/tests/keactrl_tests.sh.in b/src/bin/keactrl/tests/keactrl_tests.sh.in index e9e349b57e..64b2c18312 100644 --- a/src/bin/keactrl/tests/keactrl_tests.sh.in +++ b/src/bin/keactrl/tests/keactrl_tests.sh.in @@ -1083,6 +1083,32 @@ status_no_config_test() { test_finish 0 } +# This test checks version reported by kea-admin. It has nothing to do +# with memfile, but that is the only test file that is always ran, +# so decided to put the generic test here. +version_test() { + test_start "version" + + # This is what we expect to get. + EXPECTED_VERSION=@PACKAGE_VERSION@ + + # Let's use short version: -v + reported_version=$(${keactrl} -v) + + assert_str_eq ${EXPECTED_VERSION} ${reported_version} \ + "Expected keactrl -v to report %s, but it reported %s" + + # Let's try the long version: --version + reported_version=$(${keactrl} --version) + + assert_str_eq ${EXPECTED_VERSION} ${reported_version} \ + "Expected keactrl -v to report %s, but it reported %s" + + test_finish 0 +} + + +version_test start_all_servers_no_verbose_test start_all_servers_verbose_test start_v4_server_test