From: Tomek Mrugalski Date: Tue, 14 Aug 2018 15:29:56 +0000 (+0200) Subject: [gitlab1] shell tests for kea-netconf implemented. X-Git-Tag: gitlab29-base~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3427d99ef66f721b6f928cc6d86323f5f512b7f3;p=thirdparty%2Fkea.git [gitlab1] shell tests for kea-netconf implemented. --- diff --git a/src/bin/netconf/tests/netconf_tests.sh.in b/src/bin/netconf/tests/netconf_tests.sh.in new file mode 100644 index 0000000000..f7ab35bb04 --- /dev/null +++ b/src/bin/netconf/tests/netconf_tests.sh.in @@ -0,0 +1,80 @@ +# Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Path to the temporary configuration file. +CFG_FILE=@abs_top_builddir@/src/bin/netconf/tests/test_config.json +# Path to the Kea log file. +LOG_FILE=@abs_top_builddir@/src/bin/netconf/tests/test.log +# Path to the Kea lease file. +# Expected version +EXPECTED_VERSION="@PACKAGE_VERSION@" + +# Kea-netconf configuration to be stored in the configuration file. +CONFIG="{ + \"Netconf\": + { + // some configuration will be stored here eventually. + }, + + \"Logging\": + { + \"loggers\": [ + { + \"name\": \"kea-netconf\", + \"output_options\": [ + { + \"output\": \"$LOG_FILE\" + } + ], + \"severity\": \"INFO\" + } + ] + } +}" + +# Set the location of the executable. +bin="kea-netconf" +bin_path=@abs_top_builddir@/src/bin/netconf + +# Import common test library. +. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh + +# This test verifies that help can be printed out. +usage_test() { + local TESTNAME="${1}" + local PARAMS="${2}" + local EXP_CODE="${3}" + + # Log the start of the test and print test name. + test_start $TESTNAME + # Remove dangling Kea instances and remove log files. + cleanup + + # Create correct configuration file. + create_config "${CONFIG}" + + # Check it + printf "Running command %s.\n" "\"${bin_path}/${bin} -t ${CFG_FILE}\"" + ${bin_path}/${bin} ${PARAMS} + exit_code=$? + if [ ${exit_code} -ne $EXP_CODE ]; then + printf "ERROR: expected exit code ${EXP_CODE}, got ${exit_code}\n" + clean_exit 1 + fi + test_finish 0 +} + + +version_test "netconf.version" +usage_test "netconf.invalid-param" "-f" 1 +usage_test "netconf.dash-h" "-h" 1 +usage_test "netconf.dash-v" "-v" 0 + +# The following tests are currently disabled. Once we have a parser that is +# able to understand logger configuration, those tests (imported from DHCPv4) +# should work. +#shutdown_test "netconf.sigterm_test" 15 +#shutdown_test "netconf.sigint_test" 2