]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[gitlab9] kea-admin now reports its version.
authorTomek Mrugalski <tomasz@isc.org>
Fri, 6 Jul 2018 17:21:46 +0000 (19:21 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Wed, 8 Aug 2018 11:28:24 +0000 (13:28 +0200)
src/bin/admin/kea-admin.in
src/bin/admin/tests/memfile_tests.sh.in

index 885d1a4765a6930a7f1bf4fd3c98e29bb7e31a5d..024455ac36679379c4caed5fc3cd23bf1fc8aab6 100644 (file)
@@ -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}"
index f00e2d95cc39f74832dc9183b5084db231dd49b2..7050106091af388aeeea4c2207771b020f34708a 100644 (file)
@@ -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