X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=test%2Ftestlib.sh.in;h=ec8f400f5365d47dd31e8bc1a60369cb1931e4b8;hb=743d3cefc244e669c9265da8355e8722d990fc8e;hp=185aec0b135531d3d94370ebcbc879bc78729adb;hpb=046a10d692d1ac22de4daf783ee4fe025c4eb6ec;p=tinc diff --git a/test/testlib.sh.in b/test/testlib.sh.in index 185aec0b..ec8f400f 100644 --- a/test/testlib.sh.in +++ b/test/testlib.sh.in @@ -19,10 +19,15 @@ realdir() { tincd_path=$(realdir "../src/tincd@EXEEXT@") tinc_path=$(realdir "../src/tinc@EXEEXT@") +# shellcheck disable=SC2034 SPTPS_TEST=$(realdir "../src/sptps_test@EXEEXT@") +# shellcheck disable=SC2034 SPTPS_KEYPAIR=$(realdir "../src/sptps_keypair@EXEEXT@") # Exit status list +# shellcheck disable=SC2034 +EXIT_FAILURE=1 +# shellcheck disable=SC2034 EXIT_SKIP_TEST=77 # The list of the environment variables that tinc injects into the scripts it calls. @@ -60,8 +65,10 @@ is_busybox() { # busybox timeout returns 128 + signal number (which is TERM by default) if is_busybox; then + # shellcheck disable=SC2034 EXIT_TIMEOUT=$((128 + 15)) else + # shellcheck disable=SC2034 EXIT_TIMEOUT=124 fi @@ -93,6 +100,19 @@ must_fail() { fi } +# Executes whatever is passed to it, checking that the resulting exit code is equal to the first argument. +expect_code() { + expected=$1 + shift + + code=0 + "$@" || code=$? + + if [ $code != "$expected" ]; then + bail "wrong exit code $code, expected $expected" + fi +} + # Runs its arguments with timeout(1) or gtimeout(1) if either are installed. # Usage: try_limit_time 10 command --with --args if type timeout >/dev/null; then @@ -327,6 +347,11 @@ cleanup() { ( set +ex + if command -v cleanup_hook 2>/dev/null; then + echo >&2 "Cleanup hook found, calling..." + cleanup_hook + fi + stop_all_tincs # Ask nicely, then kill anything that's left.