]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Reformat with "shfmt -w -i 0 -fn"
authorMartin Schwenke <mschwenke@ddn.com>
Wed, 29 Oct 2025 04:44:42 +0000 (15:44 +1100)
committerVolker Lendecke <vl@samba.org>
Wed, 25 Feb 2026 12:33:39 +0000 (12:33 +0000)
Best reviewed with "git show -w" or similar.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
16 files changed:
ctdb/tests/INTEGRATION/simple/cluster.016.reclock_move_lock_dir.sh
ctdb/tests/INTEGRATION/simple/cluster.091.version_check.sh
ctdb/tests/UNIT/cunit/cluster_mutex_002.sh
ctdb/tests/UNIT/cunit/cluster_mutex_003.sh
ctdb/tests/UNIT/cunit/config_test_001.sh
ctdb/tests/UNIT/cunit/config_test_002.sh
ctdb/tests/UNIT/cunit/config_test_003.sh
ctdb/tests/UNIT/cunit/config_test_004.sh
ctdb/tests/UNIT/cunit/config_test_005.sh
ctdb/tests/UNIT/cunit/config_test_006.sh
ctdb/tests/UNIT/cunit/config_test_007.sh
ctdb/tests/UNIT/eventd/scripts/local.sh
ctdb/tests/UNIT/shellcheck/tests.sh
ctdb/tests/UNIT/takeover_helper/scripts/local.sh
ctdb/tests/UNIT/tool/scripts/local.sh
ctdb/tests/local_daemons.sh

index 147547dd3ef87a13bdb1d3906a545bdc75b07ffa..654bc5819a042d5903e0fab8e40f95854ce5123e 100755 (executable)
@@ -29,14 +29,14 @@ ctdb_onnode "$test_node" getreclock
 # $out set by ctdb_onnode() above
 reclock_setting="$out"
 
-if [ -z "$reclock_setting" ] ; then
+if [ -z "$reclock_setting" ]; then
        ctdb_test_skip "Cluster lock is not set"
 fi
 
 t="${reclock_setting% 5}"
 reclock="${t##* }"
 
-if [ ! -f "$reclock" ] ; then
+if [ ! -f "$reclock" ]; then
        ctdb_test_error "Cluster lock file \"${reclock}\" is missing"
 fi
 
index be7175036dcf1f603673fb045ede25a129dd9433..fc4cddd75c2fd22b5b2d5653db0b3251cf25ea5b 100755 (executable)
@@ -22,10 +22,10 @@ minor="${rest%%.*}"
 echo "Node ${test_node} has version ${major}.${minor}"
 
 # Unchanged version - this should work
-export CTDB_TEST_SAMBA_VERSION=$(( (major << 16) | minor ))
+export CTDB_TEST_SAMBA_VERSION=$(((major << 16) | minor))
 printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
-       "$test_node" \
-       "$CTDB_TEST_SAMBA_VERSION"
+       "$test_node" \
+       "$CTDB_TEST_SAMBA_VERSION"
 ctdb_nodes_restart "$test_node"
 wait_until_ready
 echo "GOOD: ctdbd restarted successfully on node ${test_node}"
@@ -35,20 +35,20 @@ try_command_on_node "$test_node" "${d}/ctdb-path" "pidfile" "ctdbd"
 pidfile="$out"
 
 # Changed major version - this should fail
-export CTDB_TEST_SAMBA_VERSION=$(( ((major + 1) << 16) | minor ))
+export CTDB_TEST_SAMBA_VERSION=$((((major + 1) << 16) | minor))
 printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
-       "$test_node" \
-       "$CTDB_TEST_SAMBA_VERSION"
+       "$test_node" \
+       "$CTDB_TEST_SAMBA_VERSION"
 ctdb_nodes_restart "$test_node"
 echo "Will use PID file ${pidfile} to check for ctdbd exit"
 wait_until 30 ! test -f "$pidfile"
 echo "GOOD: ctdbd exited early on node ${test_node}"
 
 # Changed minor version - this should fail
-export CTDB_TEST_SAMBA_VERSION=$(( (major << 16) | (minor + 1) ))
+export CTDB_TEST_SAMBA_VERSION=$(((major << 16) | (minor + 1)))
 printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
-       "$test_node" \
-       "$CTDB_TEST_SAMBA_VERSION"
+       "$test_node" \
+       "$CTDB_TEST_SAMBA_VERSION"
 ctdb_nodes_start "$test_node"
 echo "Will use PID file ${pidfile} to check for ctdbd exit"
 wait_until 30 ! test -f "$pidfile"
index c672eaf87ee373ecff5fb97a43e046c6fc3aa9af..37e4389bee5fd9c8298f0fc1d240a322530f619d 100755 (executable)
@@ -75,7 +75,7 @@ UNLOCK
 UNLOCK
 EOF
 unit_test cluster_mutex_test lock-file-removed-no-recheck \
-         "$helper 0" "$lockfile"
+       "$helper 0" "$lockfile"
 
 test_case "Recheck on, lock file not removed"
 ok <<EOF
@@ -83,7 +83,7 @@ LOCK
 UNLOCK
 EOF
 unit_test cluster_mutex_test lock-file-wait-recheck-unlock \
-         "$helper 5" 10
+       "$helper 5" 10
 
 test_case "Recheck on, lock file removed"
 ok <<EOF
@@ -122,7 +122,6 @@ UNLOCK
 EOF
 unit_test cluster_mutex_test lock-io-timeout "$helper 5 7" "$lockfile" 1 2
 
-
 test_case "Recheck on, ping on, child waits, child blocks causing ping timeout"
 ok <<EOF
 LOCK
index 57319bd2ef26485f9da497a7e36fdc763edded67..4b350e9a13b161860b9ed6c786b04f6b8fd28624 100755 (executable)
@@ -12,7 +12,7 @@ export CTDB_CLUSTER_MUTEX_HELPER="/bin/false"
 lockfile="${CTDB_TEST_TMP_DIR}/cluster_mutex.lockfile"
 trap 'rm ${lockfile}' 0
 
-if [ -n "$CTDB_TEST_MUTEX_HELPER" ] ; then
+if [ -n "$CTDB_TEST_MUTEX_HELPER" ]; then
        helper="$CTDB_TEST_MUTEX_HELPER"
 else
        t="${CTDB_SCRIPTS_HELPER_BINDIR}/ctdb_mutex_fcntl_helper"
index b4d73a993aa9b569a5a0fba2a263462f810d6f71..a03524a88489a7737b07ffe45bbcd3f26a9d6e07 100755 (executable)
@@ -8,7 +8,7 @@ setup_ctdb_base "${CTDB_TEST_TMP_DIR}" "ctdb-etc"
 
 conffile="${CTDB_BASE}/ctdb.conf"
 
-remove_files ()
+remove_files()
 {
        rm -f "$conffile"
 }
@@ -18,14 +18,14 @@ test_cleanup remove_files
 # Get the default values that are dependent on install prefix
 logging_location=$(ctdb-config get "logging" "location")
 database_volatile_dbdir=$(ctdb-config get \
-                                     "database" \
-                                     "volatile database directory")
+       "database" \
+       "volatile database directory")
 database_persistent_dbdir=$(ctdb-config get \
-                                       "database" \
-                                       "persistent database directory")
+       "database" \
+       "persistent database directory")
 database_state_dbdir=$(ctdb-config get \
-                                  "database" \
-                                  "state database directory")
+       "database" \
+       "state database directory")
 
 ok <<EOF
 [logging]
@@ -65,13 +65,13 @@ Failed to load config file $conffile
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 EOF
 
 ok_null
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [foobar]
 EOF
 
@@ -81,7 +81,7 @@ Failed to load config file $conffile
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 foobar = cat
 EOF
 
@@ -98,7 +98,7 @@ unit_test ctdb-config get section key
 
 # Confirm that an unknown key doesn't stop the rest of the file from
 # loading
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [database]
        unknown key = 123
 
index 23b0863b4b8659ff688881ee36dd40937834516d..4a3752b8f2a51a87e837087fdd0a8f9ad12018d1 100755 (executable)
@@ -8,14 +8,14 @@ setup_ctdb_base "${CTDB_TEST_TMP_DIR}" "ctdb-etc"
 
 conffile="${CTDB_BASE}/ctdb.conf"
 
-remove_files ()
+remove_files()
 {
        rm -f "$conffile"
 }
 
 test_cleanup remove_files
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 EOF
 
 ok <<EOF
@@ -23,7 +23,7 @@ NOTICE
 EOF
 unit_test ctdb-config get "logging" "log level"
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [logging]
     location = syslog:magic
 EOF
@@ -34,7 +34,7 @@ Failed to load config file $conffile
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [logging]
     log level = high
 EOF
@@ -45,7 +45,7 @@ Failed to load config file $conffile
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [logging]
     location = syslog
     log level = notice
index 4e8d55397c0652e0f34d7099cb813366265ee126..79d57b921cb8b3810849a3bdcee99a4c9b86d8cb 100755 (executable)
@@ -9,21 +9,21 @@ setup_ctdb_base "${CTDB_TEST_TMP_DIR}" "ctdb-etc"
 conffile="${CTDB_BASE}/ctdb.conf"
 scriptfile="${CTDB_BASE}/debug-hung-script.sh"
 
-remove_files ()
+remove_files()
 {
        rm -f "$conffile"
 }
 
 test_cleanup remove_files
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 EOF
 
 ok <<EOF
 EOF
 unit_test ctdb-config get "event" "debug script"
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [event]
     debug script = debug-hung-script.sh
 EOF
index ebbc05b63292ab84247cde1e3fcfefa93c43f3c6..964d1c2288867f7e107553eff7e832bfa188f4cd 100755 (executable)
@@ -8,14 +8,14 @@ setup_ctdb_base "${CTDB_TEST_TMP_DIR}" "ctdb-etc"
 
 conffile="$CTDB_BASE/ctdb.conf"
 
-remove_files ()
+remove_files()
 {
        rm -f "$conffile"
 }
 
 test_cleanup remove_files
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 EOF
 
 ok <<EOF
@@ -41,7 +41,7 @@ true
 EOF
 unit_test ctdb-config get "cluster" "leader capability"
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     transport = invalid
 EOF
@@ -53,7 +53,7 @@ Failed to load config file $conffile
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     node address = 10.1.2.3
 EOF
@@ -62,7 +62,7 @@ ok <<EOF
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     node address = fc00:10:1:2::123
 EOF
@@ -71,7 +71,7 @@ ok <<EOF
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     node address = 10.1.2.3:123
 EOF
@@ -83,7 +83,7 @@ Failed to load config file $conffile
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     cluster lock = /foo/bar
 EOF
@@ -92,7 +92,7 @@ required_result 0 <<EOF
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     recovery lock = /foo/bar
 EOF
@@ -102,7 +102,7 @@ Configuration option [cluster] -> recovery lock is deprecated
 EOF
 unit_test ctdb-config -d WARNING validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     leader timeout = 10
 EOF
@@ -111,7 +111,7 @@ required_result 0 <<EOF
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     leader timeout = 0
 EOF
@@ -123,7 +123,7 @@ Failed to load config file $conffile
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     leader timeout = -5
 EOF
@@ -134,7 +134,7 @@ Failed to load config file $conffile
 EOF
 unit_test ctdb-config validate
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [cluster]
     leader capability = false
 EOF
index c16a43f8265644c3d5aa3988845af49e2bd55152..79e86a60149be1e66f6350d0b90ce6340769c094 100755 (executable)
@@ -13,14 +13,14 @@ dbdir_volatile="${dbdir}/volatile"
 dbdir_persistent="${dbdir}/persistent"
 dbdir_state="${dbdir}/state"
 
-remove_files ()
+remove_files()
 {
        rm -f "$conffile" "$scriptfile"
 }
 
 test_cleanup remove_files
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [database]
     volatile database directory = ${dbdir_volatile}
     persistent database directory = ${dbdir_persistent}
@@ -68,7 +68,7 @@ ok <<EOF
 EOF
 unit_test ctdb-config get "database" "lock debug script"
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [database]
     lock debug script = $scriptfile
 EOF
index 622fb665844fd6b37f897a930982c6600a7dce50..3810a08c31e825742c51a6e070b7fefad1a4e552 100755 (executable)
@@ -8,14 +8,14 @@ setup_ctdb_base "${CTDB_TEST_TMP_DIR}" "ctdb-etc"
 
 conffile="${CTDB_BASE}/ctdb.conf"
 
-remove_files ()
+remove_files()
 {
        rm -f "$conffile"
 }
 
 test_cleanup remove_files
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 EOF
 
 ok <<EOF
@@ -43,7 +43,7 @@ ERROR
 EOF
 unit_test ctdb-config get "legacy" "script log level"
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 [legacy]
        script log level = INVALID
 EOF
index 8804448af89edc5d74b11b3c9c4b51520ec30a77..3279e586dbce739f72f6fbdad2de3900eb40dc56 100755 (executable)
@@ -8,14 +8,14 @@ setup_ctdb_base "${CTDB_TEST_TMP_DIR}" "ctdb-etc"
 
 conffile="${CTDB_BASE}/ctdb.conf"
 
-remove_files ()
+remove_files()
 {
        rm -f "$conffile"
 }
 
 test_cleanup remove_files
 
-cat > "$conffile" <<EOF
+cat >"$conffile" <<EOF
 EOF
 
 ok <<EOF
index 04cce63b9e428983d61b1757a2c1a9141abeaa21..5f0f225e4e8197e92e446814cde96e8b5449fccb 100644 (file)
@@ -4,10 +4,16 @@
 
 PATH="$PATH:$CTDB_SCRIPTS_TOOLS_HELPER_DIR"
 
-if "$CTDB_TEST_VERBOSE" ; then
-    debug () { echo "$@" ; }
+if "$CTDB_TEST_VERBOSE"; then
+       debug()
+       {
+               echo "$@"
+       }
 else
-    debug () { : ; }
+       debug()
+       {
+               :
+       }
 fi
 
 setup_ctdb_base "$CTDB_TEST_TMP_DIR" "ctdb-etc"
@@ -18,72 +24,72 @@ eventd_pidfile=$(ctdb-path pidfile eventd)
 eventd_scriptdir=$(ctdb-path etcdir append events)
 eventd_logfile="${CTDB_BASE}/eventd.log"
 
-define_test ()
+define_test()
 {
-    _f=$(basename "$0" ".sh")
+       _f=$(basename "$0" ".sh")
 
-    printf "%-28s - %s\n" "$_f" "$1"
+       printf "%-28s - %s\n" "$_f" "$1"
 }
 
-cleanup_eventd ()
+cleanup_eventd()
 {
        debug "Cleaning up eventd"
 
        pid=$(cat "$eventd_pidfile" 2>/dev/null || echo)
-       if [ -n "$pid" ] ; then
+       if [ -n "$pid" ]; then
                kill $pid || true
        fi
 }
 
-setup_eventd ()
+setup_eventd()
 {
        echo "Setting up eventd"
 
        $VALGRIND ctdb-eventd 2>&1 | tee "$eventd_logfile" &
        # Wait till eventd is running
-       wait_until 10 test -S "$eventd_socket" || \
+       wait_until 10 test -S "$eventd_socket" ||
                die "ctdb_eventd failed to start"
 
        test_cleanup cleanup_eventd
 }
 
-simple_test_background ()
+simple_test_background()
 {
        background_log="${CTDB_BASE}/background.log"
        background_status="${CTDB_BASE}/background.status"
        background_running=1
 
        (
-       (unit_test ctdb-event "$@") > "$background_log" 2>&1
-       echo $? > "$background_status"
+               (unit_test ctdb-event "$@") >"$background_log" 2>&1
+               echo $? >"$background_status"
        ) &
        background_pid=$!
 }
 
-background_wait ()
+background_wait()
 {
        [ -n "$background_running" ] || return
 
        count=0
-       while [ ! -s "$background_status" -a $count -lt 30 ] ; do
-               count=$(( $count + 1 ))
+       while [ ! -s "$background_status" -a $count -lt 30 ]; do
+               count=$(($count + 1))
                sleep 1
        done
 
-       if [ ! -s "$background_status" ] ; then
+       if [ ! -s "$background_status" ]; then
                kill -9 "$background_pid"
-               echo TIMEOUT > "$background_status"
+               echo TIMEOUT >"$background_status"
        fi
 }
 
-background_output ()
+background_output()
 {
        [ -n "$background_running" ] || return
 
        bg_status=$(cat "$background_status")
        rm -f "$background_status"
        echo "--- Background ---"
-       if [ "$bg_status" = "TIMEOUT" ] ; then
+       if [ "$bg_status" = "TIMEOUT" ]; then
                echo "Background process did not complete"
                bg_status=1
        else
@@ -95,7 +101,7 @@ background_output ()
        [ $bg_status -eq 0 ] || exit $bg_status
 }
 
-simple_test ()
+simple_test()
 {
        (unit_test ctdb-event "$@")
        status=$?
@@ -106,7 +112,7 @@ simple_test ()
        [ $status -eq 0 ] || exit $status
 }
 
-result_filter ()
+result_filter()
 {
        _duration="\<[0-9][0-9]*\.[0-9][0-9][0-9]\>"
        _day="[FMSTW][aehoru][deintu]"
@@ -117,6 +123,6 @@ result_filter ()
        _datetime="${_day} ${_month} ${_date} ${_time} ${_year}"
        _pid="[0-9][0-9]*"
        sed -e "s#${_duration}#DURATION#" \
-           -e "s#${_datetime}#DATETIME#" \
-           -e "s#,${_pid}#,PID#"
+               -e "s#${_datetime}#DATETIME#" \
+               -e "s#,${_pid}#,PID#"
 }
index fe5538123cf17080bd391402a1176e878e621027..7a297e9704fa39456e25c0268a6f5527bfa238e2 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "tests"
 
-if "$CTDB_TESTS_ARE_INSTALLED" ; then
+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
@@ -14,9 +14,9 @@ fi
 
 # Scripts
 shellcheck_test \
-               "$run_tests" \
-               "$local_daemons" \
-               "${TEST_SCRIPTS_DIR}/test_wrap"
+       "$run_tests" \
+       "$local_daemons" \
+       "${TEST_SCRIPTS_DIR}/test_wrap"
 
 # Includes
 shellcheck_test -s sh \
index d36d4e495007f7280f6cfe17886f0d2351bd0061..f349fdb0f8d8e70f07f8efab379a8f0f04344f13 100644 (file)
@@ -1,9 +1,15 @@
 # Hey Emacs, this is a -*- shell-script -*- !!!  :-)
 
-if "$CTDB_TEST_VERBOSE" ; then
-       debug () { echo "$@" ; }
+if "$CTDB_TEST_VERBOSE"; then
+       debug()
+       {
+               echo "$@"
+       }
 else
-       debug () { : ; }
+       debug()
+       {
+               :
+       }
 fi
 
 . "${TEST_SCRIPTS_DIR}/script_install_paths.sh"
@@ -17,29 +23,29 @@ ctdbd_socket=$(ctdb-path socket "ctdbd")
 ctdbd_pidfile=$(ctdb-path pidfile "ctdbd")
 ctdbd_dbdir=$(ctdb-path vardir append "db")
 
-define_test ()
+define_test()
 {
        _f=$(basename "$0" ".sh")
 
        printf "%-28s - %s\n" "$_f" "$1"
 
-       if [ -z "$FAKE_CTDBD_DEBUGLEVEL" ] ; then
+       if [ -z "$FAKE_CTDBD_DEBUGLEVEL" ]; then
                FAKE_CTDBD_DEBUGLEVEL="ERR"
        fi
-       if [ -z "$HELPER_DEBUGLEVEL" ] ; then
+       if [ -z "$HELPER_DEBUGLEVEL" ]; then
                HELPER_DEBUGLEVEL="NOTICE"
        fi
-       if [ -z "$CTDB_DEBUGLEVEL" ] ; then
+       if [ -z "$CTDB_DEBUGLEVEL" ]; then
                CTDB_DEBUGLEVEL="ERR"
        fi
 }
 
-cleanup_ctdbd ()
+cleanup_ctdbd()
 {
        debug "Cleaning up fake ctdbd"
 
        pid=$(cat "$ctdbd_pidfile" 2>/dev/null || echo)
-       if [ -n "$pid" ] ; then
+       if [ -n "$pid" ]; then
                kill $pid || true
                rm -f "$ctdbd_pidfile"
        fi
@@ -47,14 +53,14 @@ cleanup_ctdbd ()
        rm -rf "$ctdbd_dbdir"
 }
 
-setup_ctdbd ()
+setup_ctdbd()
 {
        debug "Setting up fake ctdbd"
 
        mkdir -p "$ctdbd_dbdir"
        $VALGRIND fake_ctdbd -d "$FAKE_CTDBD_DEBUGLEVEL" \
-                 -s "$ctdbd_socket" -p "$ctdbd_pidfile" \
-                 -D "$ctdbd_dbdir"
+               -s "$ctdbd_socket" -p "$ctdbd_pidfile" \
+               -D "$ctdbd_dbdir"
        # This current translates to a 6 second timeout for the
        # important controls
        ctdb setvar TakeoverTimeout 2
@@ -63,36 +69,36 @@ setup_ctdbd ()
 
 # Render non-printable characters.  The helper prints the status as
 # binary, so render it for easy comparison.
-result_filter ()
+result_filter()
 {
        sed -e 's|ctdb-takeover\[[0-9]*\]: ||'
 }
 
-ctdb_cmd ()
+ctdb_cmd()
 {
        echo Running: ctdb -d "$CTDB_DEBUGLEVEL" "$@"
        ctdb -d "$CTDB_DEBUGLEVEL" "$@"
 }
 
-test_ctdb_ip_all ()
+test_ctdb_ip_all()
 {
        unit_test ctdb -d "$CTDB_DEBUGLEVEL" ip all || exit $?
 }
 
 takeover_helper_out="${CTDB_TEST_TMP_DIR}/takover_helper.out"
 
-takeover_helper_format_outfd ()
+takeover_helper_format_outfd()
 {
        od -A n -t d4 "$takeover_helper_out" | sed -e 's|[[:space:]]*||g'
 }
 
-test_takeover_helper ()
+test_takeover_helper()
 {
        (
                export CTDB_DEBUGLEVEL="$HELPER_DEBUGLEVEL"
                export CTDB_LOGGING="file:"
                unit_test ctdb_takeover_helper 3 "$ctdbd_socket" "$@" \
-                         3>"$takeover_helper_out"
+                       3>"$takeover_helper_out"
        ) || exit $?
 
        case "$required_rc" in
index 11b1a711bcab8e6c6934fc806a878dc5c64662c5..364d1e9e8db137ad8cf99889904792e69df21df1 100644 (file)
@@ -4,47 +4,54 @@ PATH="${PATH}:${CTDB_SCRIPTS_TOOLS_HELPER_DIR}"
 PATH="${PATH}:${CTDB_SCRIPTS_HELPER_BINDIR}"
 
 setup_ctdb_base "$CTDB_TEST_TMP_DIR" "ctdb-etc" \
-               functions
+       functions
 
-if "$CTDB_TEST_VERBOSE" ; then
-    debug () { echo "$@" ; }
+if "$CTDB_TEST_VERBOSE"; then
+       debug()
+       {
+               echo "$@"
+       }
 else
-    debug () { : ; }
+       debug()
+       {
+               :
+       }
 fi
 
 ctdbd_socket=$(ctdb-path socket "ctdbd")
 ctdbd_pidfile=$(ctdb-path pidfile "ctdbd")
 ctdbd_dbdir=$(ctdb-path vardir append "db")
 
-define_test ()
+define_test()
 {
-    _f=$(basename "$0" ".sh")
+       _f=$(basename "$0" ".sh")
 
-    case "$_f" in
+       case "$_f" in
        ctdb.*)
-           _cmd="${_f#ctdb.}"
-           _cmd="${_cmd%.*}" # Strip test number
-           export CTDB="ctdb"
-           export CTDB_DEBUGLEVEL=NOTICE
-           if [ -z "$FAKE_CTDBD_DEBUGLEVEL" ] ; then
-                   FAKE_CTDBD_DEBUGLEVEL="ERR"
-           fi
-           export FAKE_CTDBD_DEBUGLEVEL
-           test_args="$_cmd"
-           ;;
+               _cmd="${_f#ctdb.}"
+               _cmd="${_cmd%.*}" # Strip test number
+               export CTDB="ctdb"
+               export CTDB_DEBUGLEVEL=NOTICE
+               if [ -z "$FAKE_CTDBD_DEBUGLEVEL" ]; then
+                       FAKE_CTDBD_DEBUGLEVEL="ERR"
+               fi
+               export FAKE_CTDBD_DEBUGLEVEL
+               test_args="$_cmd"
+               ;;
        *)
-           die "Unknown pattern for testcase \"$_f\""
-    esac
+               die "Unknown pattern for testcase \"$_f\""
+               ;;
+       esac
 
-    printf "%-28s - %s\n" "$_f" "$1"
+       printf "%-28s - %s\n" "$_f" "$1"
 }
 
-cleanup_ctdbd ()
+cleanup_ctdbd()
 {
        debug "Cleaning up fake ctdbd"
 
        pid=$(cat "$ctdbd_pidfile" 2>/dev/null || echo)
-       if [ -n "$pid" ] ; then
+       if [ -n "$pid" ]; then
                kill $pid || true
                rm -f "$ctdbd_pidfile"
        fi
@@ -52,27 +59,27 @@ cleanup_ctdbd ()
        rm -rf "$ctdbd_dbdir"
 }
 
-setup_ctdbd ()
+setup_ctdbd()
 {
        echo "Setting up fake ctdbd"
 
        mkdir -p "$ctdbd_dbdir"
        $VALGRIND fake_ctdbd -d "$FAKE_CTDBD_DEBUGLEVEL" \
-                 -s "$ctdbd_socket" -p "$ctdbd_pidfile" \
-                 -D "$ctdbd_dbdir"
+               -s "$ctdbd_socket" -p "$ctdbd_pidfile" \
+               -D "$ctdbd_dbdir"
        # Wait till fake_ctdbd is running
-       wait_until 10 test -S "$ctdbd_socket" || \
+       wait_until 10 test -S "$ctdbd_socket" ||
                die "fake_ctdbd failed to start"
 
        test_cleanup cleanup_ctdbd
 }
 
-ctdbd_getpid ()
+ctdbd_getpid()
 {
        cat "$ctdbd_pidfile"
 }
 
-setup_natgw ()
+setup_natgw()
 {
        debug "Setting up NAT gateway"
 
@@ -82,7 +89,7 @@ setup_natgw ()
        cat >"$CTDB_NATGW_NODES"
 }
 
-setup_lvs ()
+setup_lvs()
 {
        debug "Setting up LVS"
 
@@ -92,21 +99,21 @@ setup_lvs ()
        cat >"$CTDB_LVS_NODES"
 }
 
-setup_nodes ()
+setup_nodes()
 {
-    _pnn="$1"
+       _pnn="$1"
 
-    _f="${CTDB_BASE}/nodes${_pnn:+.}${_pnn}"
+       _f="${CTDB_BASE}/nodes${_pnn:+.}${_pnn}"
 
-    cat >"$_f"
+       cat >"$_f"
 }
 
-simple_test_other ()
+simple_test_other()
 {
        unit_test $CTDB -d $CTDB_DEBUGLEVEL "$@"
 }
 
-simple_test ()
+simple_test()
 {
        simple_test_other $test_args "$@"
 }
index b4746681c1fbb0633e17fdaedf588fdeb20ca05a..b0c71a6306473734f14dec18d220843ba06ae151 100755 (executable)
@@ -13,7 +13,7 @@ export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts"
 
 . "${TEST_SCRIPTS_DIR}/common.sh"
 
-if ! $CTDB_TESTS_ARE_INSTALLED ; then
+if ! $CTDB_TESTS_ARE_INSTALLED; then
        hdir="$CTDB_SCRIPTS_HELPER_BINDIR"
        export CTDB_EVENTD="${hdir}/ctdb-eventd"
        export CTDB_EVENT_HELPER="${hdir}/ctdb-event"
@@ -26,30 +26,30 @@ fi
 ########################################
 
 # If the given IP is hosted then print 2 items: maskbits and iface
-have_ip ()
+have_ip()
 {
        _addr="$1"
 
        case "$_addr" in
        *:*) _bits=128 ;;
-       *)   _bits=32  ;;
+       *) _bits=32 ;;
        esac
 
        _t=$(ip addr show to "${_addr}/${_bits}")
        [ -n "$_t" ]
 }
 
-setup_nodes ()
+setup_nodes()
 {
        _num_nodes="$1"
        _use_ipv6="$2"
 
        _have_all_ips=true
-       for _i in $(seq 0 $((_num_nodes - 1)) ) ; do
-               if $_use_ipv6 ; then
-                       _j=$(printf "%04x" $((0x5f00 + 1 + _i)) )
+       for _i in $(seq 0 $((_num_nodes - 1))); do
+               if $_use_ipv6; then
+                       _j=$(printf "%04x" $((0x5f00 + 1 + _i)))
                        _node_ip="fd00::5357:${_j}"
-                       if have_ip "$_node_ip" ; then
+                       if have_ip "$_node_ip"; then
                                echo "$_node_ip"
                        else
                                cat >&2 <<EOF
@@ -58,8 +58,8 @@ EOF
                                _have_all_ips=false
                        fi
                else
-                       _c=$(( _i / 100 ))
-                       _d=$(( 1 + (_i % 100) ))
+                       _c=$((_i / 100))
+                       _d=$((1 + (_i % 100)))
                        echo "127.0.${_c}.${_d}"
                fi
        done
@@ -68,38 +68,38 @@ EOF
        $_have_all_ips
 }
 
-setup_public_addresses ()
+setup_public_addresses()
 {
        _num_nodes="$1"
        _node_no_ips="$2"
        _use_ipv6="$3"
 
-       for _i in $(seq 0 $((_num_nodes - 1)) ) ; do
-               if  [ "$_i" -eq "$_node_no_ips" ] ; then
+       for _i in $(seq 0 $((_num_nodes - 1))); do
+               if [ "$_i" -eq "$_node_no_ips" ]; then
                        continue
                fi
 
                # 2 public addresses on most nodes, just to make
                # things interesting
-               if $_use_ipv6 ; then
+               if $_use_ipv6; then
                        printf 'fc00:10::1:%x/64 lo\n' $((1 + _i))
                        printf 'fc00:10::2:%x/64 lo\n' $((1 + _i))
                else
-                       _c1=$(( 100 + (_i / 100) ))
-                       _c2=$(( 200 + (_i / 100) ))
-                       _d=$(( 1 + (_i % 100) ))
+                       _c1=$((100 + (_i / 100)))
+                       _c2=$((200 + (_i / 100)))
+                       _d=$((1 + (_i % 100)))
                        printf '192.168.%d.%d/24 lo\n' "$_c1" "$_d"
                        printf '192.168.%d.%d/24 lo\n' "$_c2" "$_d"
                fi
        done
 }
 
-setup_socket_wrapper ()
+setup_socket_wrapper()
 {
        _socket_wrapper_so="$1"
 
        _so="${directory}/libsocket-wrapper.so"
-       if [ ! -f "$_socket_wrapper_so" ] ; then
+       if [ ! -f "$_socket_wrapper_so" ]; then
                die "$0 setup: Unable to find ${_socket_wrapper_so}"
        fi
 
@@ -117,7 +117,7 @@ setup_socket_wrapper ()
        mkdir -p "$_d"
 }
 
-local_daemons_setup_usage ()
+local_daemons_setup_usage()
 {
        cat >&2 <<EOF
 $0 <directory> setup [ <options>... ]
@@ -137,7 +137,7 @@ EOF
        exit 1
 }
 
-local_daemons_setup ()
+local_daemons_setup()
 {
        _commented_config=""
        _disable_failover=false
@@ -151,22 +151,24 @@ local_daemons_setup ()
 
        set -e
 
-       while getopts "C:FN:n:P:Rr:S:6h?" _opt ; do
+       while getopts "C:FN:n:P:Rr:S:6h?" _opt; do
                case "$_opt" in
-               C) _t="${_commented_config}${_commented_config:+|}"
-                  _commented_config="${_t}${OPTARG}"
-                  ;;
+               C)
+                       _t="${_commented_config}${_commented_config:+|}"
+                       _commented_config="${_t}${OPTARG}"
+                       ;;
                F) _disable_failover=true ;;
                N) _nodes_file="$OPTARG" ;;
                n) _num_nodes="$OPTARG" ;;
                P) _public_addresses_file="$OPTARG" ;;
                R) _cluster_lock_use_command=true ;;
-               r) _cluster_lock_use_command=true
-                  _cluster_lock_recheck_interval="$OPTARG"
-                  ;;
+               r)
+                       _cluster_lock_use_command=true
+                       _cluster_lock_recheck_interval="$OPTARG"
+                       ;;
                S) _socket_wrapper="$OPTARG" ;;
                6) _use_ipv6=true ;;
-               \?|h) local_daemons_setup_usage ;;
+               \? | h) local_daemons_setup_usage ;;
                esac
        done
        shift $((OPTIND - 1))
@@ -174,7 +176,7 @@ local_daemons_setup ()
        mkdir -p "$directory"
 
        _nodes_all="${directory}/nodes"
-       if [ -n "$_nodes_file" ] ; then
+       if [ -n "$_nodes_file" ]; then
                cp "$_nodes_file" "$_nodes_all"
        else
                setup_nodes "$_num_nodes" $_use_ipv6 >"$_nodes_all"
@@ -183,50 +185,50 @@ local_daemons_setup ()
        # If there are (strictly) greater than 2 nodes then we'll
        # "randomly" choose a node to have no public addresses
        _node_no_ips=-1
-       if [ "$_num_nodes" -gt 2 ] ; then
+       if [ "$_num_nodes" -gt 2 ]; then
                _node_no_ips=$(($$ % _num_nodes))
        fi
 
        _public_addresses_all="${directory}/public_addresses"
-       if [ -n "$_public_addresses_file" ] ; then
+       if [ -n "$_public_addresses_file" ]; then
                cp "$_public_addresses_file" "$_public_addresses_all"
        else
                setup_public_addresses "$_num_nodes" \
-                                      $_node_no_ips \
-                                      "$_use_ipv6" >"$_public_addresses_all"
+                       $_node_no_ips \
+                       "$_use_ipv6" >"$_public_addresses_all"
        fi
 
        _cluster_lock_dir="${directory}/shared/.ctdb"
        mkdir -p "$_cluster_lock_dir"
        _cluster_lock="${_cluster_lock_dir}/cluster.lock"
-       if $_cluster_lock_use_command ; then
+       if $_cluster_lock_use_command; then
                _helper="${CTDB_SCRIPTS_HELPER_BINDIR}/ctdb_mutex_fcntl_helper"
                _t="! ${_helper} ${_cluster_lock}"
-               if [ -n "$_cluster_lock_recheck_interval" ] ; then
+               if [ -n "$_cluster_lock_recheck_interval" ]; then
                        _t="${_t} ${_cluster_lock_recheck_interval}"
                fi
                _cluster_lock="$_t"
        fi
 
-       if [ -n "$_socket_wrapper" ] ; then
+       if [ -n "$_socket_wrapper" ]; then
                setup_socket_wrapper "$_socket_wrapper"
        fi
 
-       for _n in $(seq 0 $((_num_nodes - 1))) ; do
+       for _n in $(seq 0 $((_num_nodes - 1))); do
                # CTDB_TEST_SUITE_DIR needs to be correctly set so
                # setup_ctdb_base() finds the etc-ctdb/ subdirectory
                # and the test event script is correctly installed
                # shellcheck disable=SC2034
                CTDB_TEST_SUITE_DIR="$CTDB_TEST_DIR" \
-                          setup_ctdb_base "$directory" "node.${_n}" \
-                               functions notify.sh debug-hung-script.sh
+                       setup_ctdb_base "$directory" "node.${_n}" \
+                       functions notify.sh debug-hung-script.sh
 
                cp "$_nodes_all" "${CTDB_BASE}/nodes"
 
                _public_addresses="${CTDB_BASE}/public_addresses"
 
-               if  [ -z "$_public_addresses_file" ] && \
-                           [ "$_node_no_ips" -eq "$_n" ] ; then
+               if [ -z "$_public_addresses_file" ] &&
+                       [ "$_node_no_ips" -eq "$_n" ]; then
                        echo "Node ${_n} will have no public IPs."
                        : >"$_public_addresses"
                else
@@ -236,7 +238,7 @@ local_daemons_setup ()
                _node_ip=$(sed -n -e "$((_n + 1))p" "$_nodes_all")
 
                _db_dir="${CTDB_BASE}/db"
-               for _d in "volatile" "persistent" "state" ; do
+               for _d in "volatile" "persistent" "state"; do
                        mkdir -p "${_db_dir}/${_d}"
                done
 
@@ -263,16 +265,16 @@ EOF
 
                (
                        IFS='|'
-                       for _c in $_commented_config ; do
+                       for _c in $_commented_config; do
                                # Quote all backslashes due to double-quotes
                                sed -i -e "s|^\\t\\(${_c}\\) = |\\t# \\1 = |" \
-                                   "${CTDB_BASE}/ctdb.conf"
+                                       "${CTDB_BASE}/ctdb.conf"
                        done
                )
        done
 }
 
-local_daemons_ssh_usage ()
+local_daemons_ssh_usage()
 {
        cat >&2 <<EOF
 usage: $0 <directory> ssh [ -n ] <ip> <command>
@@ -281,51 +283,51 @@ EOF
        exit 1
 }
 
-local_daemons_ssh ()
+local_daemons_ssh()
 {
-       if [ $# -lt 2 ] ; then
+       if [ $# -lt 2 ]; then
                local_daemons_ssh_usage
        fi
 
        # Only try to respect ssh -n option, others can't be used so discard them
        _close_stdin=false
-       while getopts "nh?" _opt ; do
+       while getopts "nh?" _opt; do
                case "$_opt" in
                n) _close_stdin=true ;;
-               \?|h) local_daemons_ssh_usage ;;
+               \? | h) local_daemons_ssh_usage ;;
                *) : ;;
                esac
        done
        shift $((OPTIND - 1))
 
-       if [ $# -lt 2 ] ; then
+       if [ $# -lt 2 ]; then
                local_daemons_ssh_usage
        fi
 
        _nodes="${directory}/nodes"
 
        # IP address of node. onnode can pass hostnames but not in these tests
-       _ip="$1" ; shift
+       _ip="$1"
+       shift
        # "$*" is command
 
-
        # Determine the correct CTDB base directory
        _num=$(awk -v ip="$_ip" '$1 == ip { print NR }' "$_nodes")
        _node=$((_num - 1))
        export CTDB_BASE="${directory}/node.${_node}"
 
-       if [ ! -d "$CTDB_BASE" ] ; then
+       if [ ! -d "$CTDB_BASE" ]; then
                die "$0 ssh: Unable to find base for node ${_ip}"
        fi
 
-       if $_close_stdin ; then
+       if $_close_stdin; then
                exec sh -c "$*" </dev/null
        else
                exec sh -c "$*"
        fi
 }
 
-onnode_common ()
+onnode_common()
 {
        # onnode will execute this, which fakes ssh against local daemons
        export ONNODE_SSH="${0} ${directory} ssh"
@@ -334,7 +336,7 @@ onnode_common ()
        export CTDB_BASE="$directory"
 }
 
-local_daemons_generic_usage ()
+local_daemons_generic_usage()
 {
        cat >&2 <<EOF
 usage: $0 <directory> ${1} <nodes>
@@ -345,21 +347,21 @@ EOF
        exit 1
 }
 
-local_daemons_start_socket_wrapper ()
+local_daemons_start_socket_wrapper()
 {
        _so="${directory}/libsocket-wrapper.so"
        _d="${directory}/sw"
 
-       if [ -d "$_d" ] && [ -f "$_so" ] ; then
+       if [ -d "$_d" ] && [ -f "$_so" ]; then
                export SOCKET_WRAPPER_DIR="$_d"
                export LD_PRELOAD="$_so"
                export SOCKET_WRAPPER_DIR_ALLOW_ORIG="1"
        fi
 }
 
-local_daemons_start ()
+local_daemons_start()
 {
-       if [ $# -ne 1 ] || [ "$1" = "-h" ] ; then
+       if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
                local_daemons_generic_usage "start"
        fi
 
@@ -372,9 +374,9 @@ local_daemons_start ()
        onnode -i "$_nodes" "${VALGRIND:-} ctdbd"
 }
 
-local_daemons_stop ()
+local_daemons_stop()
 {
-       if [ $# -ne 1 ] || [ "$1" = "-h" ] ; then
+       if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
                local_daemons_generic_usage "stop"
        fi
 
@@ -388,7 +390,7 @@ local_daemons_stop ()
                 fi"
 }
 
-local_daemons_onnode_usage ()
+local_daemons_onnode_usage()
 {
        cat >&2 <<EOF
 usage: $0 <directory> onnode <nodes> <command>...
@@ -399,9 +401,9 @@ EOF
        exit 1
 }
 
-local_daemons_onnode ()
+local_daemons_onnode()
 {
-       if [ $# -lt 2 ] || [ "$1" = "-h" ] ; then
+       if [ $# -lt 2 ] || [ "$1" = "-h" ]; then
                local_daemons_onnode_usage
        fi
 
@@ -413,9 +415,9 @@ local_daemons_onnode ()
        onnode "$_nodes" "$@"
 }
 
-local_daemons_print_socket ()
+local_daemons_print_socket()
 {
-       if [ $# -ne 1 ] || [ "$1" = "-h" ] ; then
+       if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
                local_daemons_generic_usage "print-socket"
        fi
 
@@ -428,9 +430,9 @@ local_daemons_print_socket ()
        onnode -q "$_nodes" "${VALGRIND:-} ${_path} socket ctdbd"
 }
 
-local_daemons_print_log ()
+local_daemons_print_log()
 {
-       if [ $# -ne 1 ] || [ "$1" = "-h" ] ; then
+       if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
                local_daemons_generic_usage "print-log"
        fi
 
@@ -442,13 +444,13 @@ local_daemons_print_log ()
        # shellcheck disable=SC2016
        # $CTDB_BASE must only be expanded under onnode, not in top-level shell
        onnode -q "$_nodes" 'cat ${CTDB_BASE}/log.ctdb' |
-       sort
+               sort
 
 }
 
-local_daemons_tail_log ()
+local_daemons_tail_log()
 {
-       if [ $# -ne 1 ] || [ "$1" = "-h" ] ; then
+       if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
                local_daemons_generic_usage "tail-log"
        fi
 
@@ -463,7 +465,7 @@ local_daemons_tail_log ()
        tail -f $(onnode -q "$_nodes" 'echo ${CTDB_BASE}/log.ctdb')
 }
 
-usage ()
+usage()
 {
        cat <<EOF
 usage: $0 <directory> <command> [ <options>... ]
@@ -485,7 +487,7 @@ EOF
        exit 1
 }
 
-if [ $# -lt 2 ] ; then
+if [ $# -lt 2 ]; then
        usage
 fi