From 96df5d641071fe6509d5ed2f8153e2b5dcb5a8bd Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Tue, 30 Nov 2021 10:08:59 +0100 Subject: [PATCH] Shell fixes (#1056) * broken test * don't expand filenames into options * fix for ./test_env.sh -h => ./test_env.sh: line 15: usage: command not found --- scripts/func_tests/tests_base.sh | 2 +- .../func_tests/tests_post-install_7_plugin.sh | 2 +- scripts/test_env.sh | 18 ++++++++---------- scripts/test_wizard_upgrade.sh | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/scripts/func_tests/tests_base.sh b/scripts/func_tests/tests_base.sh index f6cf6f71e..f87923917 100755 --- a/scripts/func_tests/tests_base.sh +++ b/scripts/func_tests/tests_base.sh @@ -34,7 +34,7 @@ function wait_for_service { while ! nc -z localhost 6060; do sleep 0.5 ((count ++)) - if [[ count == 21 ]]; then + if [[ $count == 21 ]]; then fail "$@" fi done diff --git a/scripts/func_tests/tests_post-install_7_plugin.sh b/scripts/func_tests/tests_post-install_7_plugin.sh index 4f0398a95..96c830e07 100755 --- a/scripts/func_tests/tests_post-install_7_plugin.sh +++ b/scripts/func_tests/tests_post-install_7_plugin.sh @@ -40,7 +40,7 @@ function setup_tests() { while ! nc -z localhost 9999; do sleep 0.5 ((count ++)) - if [[ count == 41 ]]; then + if [[ $count == 41 ]]; then fail "mock server not up after 20s" fi done diff --git a/scripts/test_env.sh b/scripts/test_env.sh index 07a5740e0..5d545322c 100755 --- a/scripts/test_env.sh +++ b/scripts/test_env.sh @@ -2,6 +2,14 @@ BASE="./tests" +usage() { + echo "Usage:" + echo " ./wizard.sh -h Display this help message." + echo " ./test_env.sh -d ./tests Create test environment in './tests' folder" + exit 0 +} + + while [[ $# -gt 0 ]] do key="${1}" @@ -111,14 +119,4 @@ main() { } - -usage() { - echo "Usage:" - echo " ./wizard.sh -h Display this help message." - echo " ./env_test.sh -d ./tests Create test environment in './tests' folder" - exit 0 -} - - - main diff --git a/scripts/test_wizard_upgrade.sh b/scripts/test_wizard_upgrade.sh index 73d386420..5f513c733 100755 --- a/scripts/test_wizard_upgrade.sh +++ b/scripts/test_wizard_upgrade.sh @@ -140,7 +140,7 @@ function down rm -rf cs-firewall-bouncer-* rm -f crowdsec-release.tgz rm -f cs-firewall-bouncer.tgz - rm *.md5 + rm -- *.md5 } function assert_equal