From: Tomas Krizek Date: Fri, 1 Feb 2019 12:13:26 +0000 (+0100) Subject: meson: tests/config - use script to prepare workdir X-Git-Tag: v4.0.0~24^2~199 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=89e414eee6335592c2edcc093cfbff676b45c6a4;p=thirdparty%2Fknot-resolver.git meson: tests/config - use script to prepare workdir --- diff --git a/scripts/test-config.sh b/scripts/test-config.sh new file mode 100755 index 000000000..1774e1443 --- /dev/null +++ b/scripts/test-config.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Utility script used by meson to run config tests post installation +set -o nounset -o errexit + +# if anything fails during test setup, use exit code 77 to mark it as skipped +function skip { + exit 77 +} +trap skip ERR + +TEST_DIR="$(dirname ${TEST_FILE})" +TMP_RUNDIR="$(mktemp -d)" + +function finish { + rm -rf "${TMP_RUNDIR}" +} +trap finish EXIT + +cp -a "${TEST_DIR}/"* "${TMP_RUNDIR}/" +cd "${TMP_RUNDIR}" + +test -x "${KRESD_EXEC}" || (echo "${KRESD_EXEC} not executable!"; exit 77) +trap ERR # get actual kresd error code from now on + +${KRESD_EXEC} "$@" diff --git a/tests/config/meson.build b/tests/config/meson.build index 8b2fc1a92..4d6193d53 100644 --- a/tests/config/meson.build +++ b/tests/config/meson.build @@ -24,29 +24,8 @@ config_tests += [ if get_option('daemon') + run_configtest = find_program('../../scripts/test-config.sh') foreach config_test : config_tests - conftest_dir = join_paths(meson.current_build_dir(), config_test[0]) - - testdir_clean = custom_target( - 'config.' + config_test[0] + ': clean testdir', - command: [ - 'rm', '-r', '-f', conftest_dir, - ], - output: config_test[0] + '.rm', - build_by_default: false, - ) - - testdir_create = custom_target( - 'config.' + config_test[0] + ': create testdir', - command: [ - 'mkdir', conftest_dir, - ], - depends: testdir_clean, - output: config_test[0], - build_always_stale: true, # make sure to always recreate dir - build_by_default: false, - ) - # kresd arguments conftest_args = [ '-c', files('test.cfg'), @@ -61,16 +40,18 @@ if get_option('daemon') test( 'config.' + config_test[0], - kresd, + run_configtest, args: conftest_args, env: [ 'KRESD_NO_LISTEN=1', 'SOURCE_PATH=@0@'.format(meson.current_source_dir()), 'TEST_FILE=@0@/@1@'.format(meson.source_root(), config_test[1][0]), + 'KRESD_EXEC=@0@'.format(kresd_install_path), + ], + suite: [ + 'postinstall', + 'config', ], - suite: 'config', - workdir: join_paths(meson.current_build_dir(), config_test[0]), - depends: testdir_create, should_fail: conftest_should_fail, ) endforeach diff --git a/tests/config/runtest.sh b/tests/config/runtest.sh deleted file mode 100755 index 11d9b460b..000000000 --- a/tests/config/runtest.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -e -export SOURCE_PATH="$(cd "$(dirname "$0")" && pwd -P)" -export TEST_FILE="${2}" -TEST_DIR="$(dirname $TEST_FILE)" -export TMP_RUNDIR="$(mktemp -d)" -export KRESD_NO_LISTEN=1 -function finish { - rm -rf "${TMP_RUNDIR}" -} -trap finish EXIT - - -echo "# $(basename ${TEST_FILE})" -cp -a "${TEST_DIR}/"* "${TMP_RUNDIR}/" -CMDLINE_ARGS="$(cat "${TEST_FILE%.test.lua}.args" 2>/dev/null || echo "")" -EXPECTED_RETURNCODE="$(cat "${TEST_FILE%.test.lua}.returncode" 2>/dev/null || echo 0)" -set +e -${DEBUGGER} ${1} -f 1 -c ${SOURCE_PATH}/test.cfg $CMDLINE_ARGS "${TMP_RUNDIR}" -RETCODE="$?" -if [ "$RETCODE" -ne "$EXPECTED_RETURNCODE" ]; then - echo "Expected return code '$EXPECTED_RETURNCODE' got '$RETCODE'." -fi -test "$RETCODE" -eq "$EXPECTED_RETURNCODE"