From 71008a1ad52babfe8582ab4ea88fe9a683bcfcad Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Fri, 6 Jul 2018 19:21:46 +0200 Subject: [PATCH] [gitlab9] kea-admin now reports its version. --- src/bin/admin/kea-admin.in | 11 ++++++- src/bin/admin/tests/memfile_tests.sh.in | 38 +++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/bin/admin/kea-admin.in b/src/bin/admin/kea-admin.in index 885d1a4765..024455ac36 100644 --- a/src/bin/admin/kea-admin.in +++ b/src/bin/admin/kea-admin.in @@ -18,6 +18,7 @@ prefix=@prefix@ SCRIPTS_DIR_DEFAULT=@datarootdir@/@PACKAGE@/scripts scripts_dir=${SCRIPTS_DIR_DEFAULT} +VERSION=@PACKAGE_VERSION@ # These are the default parameters. They will likely not work in any # specific deployment. @@ -41,7 +42,7 @@ fi # Prints out usage version. usage() { - printf "kea-admin @PACKAGE_VERSION@\n" + printf "kea-admin $VERSION\n" printf "\n" printf "This is a kea-admin script that conducts administrative tasks on\n" printf "the Kea installation.\n" @@ -65,6 +66,7 @@ usage() { printf " -p or --password pass - specifies a password when connecting to a database\n" printf " -n or --name database - specifies a database name to connect to\n" printf " -d or --directory - path to upgrade scripts (default: ${SCRIPTS_DIR_DEFAULT})\n" + printf " -v - print kea-admin version and quit.\n" printf "\n" printf " Parameters specific to lease-dump:\n" printf " -4 to dump IPv4 leases to file\n" @@ -537,6 +539,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}" "lease-init lease-version lease-upgrade lease-dump" if [ ${_inlist} -eq 0 ]; then log_error "invalid command: ${command}" diff --git a/src/bin/admin/tests/memfile_tests.sh.in b/src/bin/admin/tests/memfile_tests.sh.in index f00e2d95cc..7050106091 100644 --- a/src/bin/admin/tests/memfile_tests.sh.in +++ b/src/bin/admin/tests/memfile_tests.sh.in @@ -9,9 +9,12 @@ # Include common test library. . @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh +# Set location of the kea-admin. +keaadmin=@abs_top_builddir@/src/bin/admin/kea-admin + memfile_init_test() { test_start "memfile.init" - + # @todo: Implement this (ticket #3601) test_finish 0 @@ -19,7 +22,7 @@ memfile_init_test() { memfile_version_test() { test_start "memfile.version" - + # @todo: Implement this (ticket #3601) test_finish 0 @@ -27,12 +30,41 @@ memfile_version_test() { memfile_upgrade_test() { test_start "memfile.upgrade" - + # @todo: Implement this (ticket #3601) 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=$(${keaadmin} -v) + + assert_str_eq ${EXPECTED_VERSION} ${reported_version} \ + "Expected kea-admin -v to report %s, but it reported %s" + + # Let's try the long version: --version + reported_version=$(${keaadmin} --version) + + assert_str_eq ${EXPECTED_VERSION} ${reported_version} \ + "Expected kea-admin -v to report %s, but it reported %s" + + # This is a test whether the reviewer pays any attention. If you miss this + # nonsense, you owe me a beer. If you spot it, it's the other way around. + test_finish 0 +} + + +version_test + memfile_init_test memfile_version_test memfile_upgrade_test -- 2.47.2