diff options
Diffstat (limited to 'ctdb/tests/UNIT/shellcheck')
-rwxr-xr-x | ctdb/tests/UNIT/shellcheck/base_scripts.sh | 12 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/shellcheck/ctdb_helpers.sh | 9 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/shellcheck/event_scripts.sh | 7 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/shellcheck/functions.sh | 7 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/shellcheck/init_script.sh | 19 | ||||
-rw-r--r-- | ctdb/tests/UNIT/shellcheck/scripts/local.sh | 33 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/shellcheck/tests.sh | 31 | ||||
-rwxr-xr-x | ctdb/tests/UNIT/shellcheck/tools.sh | 9 |
8 files changed, 127 insertions, 0 deletions
diff --git a/ctdb/tests/UNIT/shellcheck/base_scripts.sh b/ctdb/tests/UNIT/shellcheck/base_scripts.sh new file mode 100755 index 0000000..cbb8502 --- /dev/null +++ b/ctdb/tests/UNIT/shellcheck/base_scripts.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "base scripts" + +shellcheck_test \ + "${CTDB_SCRIPTS_BASE}/ctdb-crash-cleanup.sh" \ + "${CTDB_SCRIPTS_BASE}/debug-hung-script.sh" \ + "${CTDB_SCRIPTS_BASE}/debug_locks.sh" \ + "${CTDB_SCRIPTS_BASE}/nfs-linux-kernel-callout" \ + "${CTDB_SCRIPTS_BASE}/statd-callout" diff --git a/ctdb/tests/UNIT/shellcheck/ctdb_helpers.sh b/ctdb/tests/UNIT/shellcheck/ctdb_helpers.sh new file mode 100755 index 0000000..f6c7e31 --- /dev/null +++ b/ctdb/tests/UNIT/shellcheck/ctdb_helpers.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "ctdb helpers" + +shellcheck_test \ + "${CTDB_SCRIPTS_TOOLS_HELPER_DIR}/ctdb_lvs" \ + "${CTDB_SCRIPTS_TOOLS_HELPER_DIR}/ctdb_natgw" diff --git a/ctdb/tests/UNIT/shellcheck/event_scripts.sh b/ctdb/tests/UNIT/shellcheck/event_scripts.sh new file mode 100755 index 0000000..dfb5ede --- /dev/null +++ b/ctdb/tests/UNIT/shellcheck/event_scripts.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "event scripts" + +shellcheck_test "${CTDB_SCRIPTS_DATA_DIR}/events/"*/[0-9][0-9].* diff --git a/ctdb/tests/UNIT/shellcheck/functions.sh b/ctdb/tests/UNIT/shellcheck/functions.sh new file mode 100755 index 0000000..7ce206d --- /dev/null +++ b/ctdb/tests/UNIT/shellcheck/functions.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "functions file" + +shellcheck_test -s sh "${CTDB_SCRIPTS_BASE}/functions" diff --git a/ctdb/tests/UNIT/shellcheck/init_script.sh b/ctdb/tests/UNIT/shellcheck/init_script.sh new file mode 100755 index 0000000..1e1d54c --- /dev/null +++ b/ctdb/tests/UNIT/shellcheck/init_script.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "init script" + +script="$CTDB_SCRIPTS_INIT_SCRIPT" + +if [ -z "$script" ] ; then + script="/etc/init.d/ctdb" + if [ ! -r "$script" ] ; then + script="/usr/local/etc/init.d/ctdb" + fi + if [ ! -r "$script" ] ; then + ctdb_test_skip "Unable to find ctdb init script" + fi +fi + +shellcheck_test "$script" diff --git a/ctdb/tests/UNIT/shellcheck/scripts/local.sh b/ctdb/tests/UNIT/shellcheck/scripts/local.sh new file mode 100644 index 0000000..07e72c3 --- /dev/null +++ b/ctdb/tests/UNIT/shellcheck/scripts/local.sh @@ -0,0 +1,33 @@ +# Hey Emacs, this is a -*- shell-script -*- !!! :-) + +. "${TEST_SCRIPTS_DIR}/script_install_paths.sh" + +define_test () +{ + _f=$(basename "$0" ".sh") + + printf "%-28s - %s\n" "$_f" "$1" +} +shellcheck_test () +{ + ok_null + if type shellcheck >/dev/null 2>&1 ; then + # Skip some recent checks: + # + # SC1090: Can't follow non-constant source. Use a + # directive to specify location. + # SC1091: Not following: FILE was not specified as + # input (see shellcheck -x). + # - Shellcheck doesn't handle our includes + # very well. Adding directives to handle + # include for both in-tree and installed + # cases just isn't going to be possible. + # SC2162: read without -r will mangle backslashes. + # - We never read things with backslashes, + # unnecessary churn. + _excludes="SC1090,SC1091,SC2162" + unit_test shellcheck --exclude="$_excludes" "$@" + else + ctdb_test_skip "shellcheck not installed" + fi +} diff --git a/ctdb/tests/UNIT/shellcheck/tests.sh b/ctdb/tests/UNIT/shellcheck/tests.sh new file mode 100755 index 0000000..f01ece7 --- /dev/null +++ b/ctdb/tests/UNIT/shellcheck/tests.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "tests" + +if "$CTDB_TESTS_ARE_INSTALLED" ; then + run_tests="${CTDB_SCRIPTS_TESTS_BIN_DIR}/ctdb_run_tests" + local_daemons="${CTDB_SCRIPTS_TESTS_BIN_DIR}/ctdb_local_daemons" +else + run_tests="${CTDB_TEST_DIR}/run_tests.sh" + local_daemons="${CTDB_TEST_DIR}/local_daemons.sh" +fi + +# Scripts +shellcheck_test \ + "$run_tests" \ + "$local_daemons" \ + "${TEST_SCRIPTS_DIR}/test_wrap" + +# Includes +shellcheck_test -s sh \ + "${TEST_SCRIPTS_DIR}/common.sh" \ + "${TEST_SCRIPTS_DIR}/script_install_paths.sh" \ + "${TEST_SCRIPTS_DIR}/unit.sh" + +shellcheck_test -s bash \ + "${TEST_SCRIPTS_DIR}/cluster.bash" \ + "${TEST_SCRIPTS_DIR}/integration.bash" \ + "${TEST_SCRIPTS_DIR}/integration_local_daemons.bash" \ + "${TEST_SCRIPTS_DIR}/integration_real_cluster.bash" diff --git a/ctdb/tests/UNIT/shellcheck/tools.sh b/ctdb/tests/UNIT/shellcheck/tools.sh new file mode 100755 index 0000000..2cd322c --- /dev/null +++ b/ctdb/tests/UNIT/shellcheck/tools.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "tools" + +shellcheck_test \ + "${CTDB_SCRIPTS_TOOLS_BIN_DIR}/onnode" \ + "${CTDB_SCRIPTS_TOOLS_BIN_DIR}/ctdb_diagnostics" |