The branch, master has been updated
       via  d950c739979 ctdb-tests: Don't hard code creation of 
$CTDB_BASE/events/legacy/
       via  98cecce76d1 ctdb-tests: Improve setup_ctdb_base() to fix 
local_daemons.sh bug
       via  5a30073278e ctdb-event: Improve error message
       via  4ba5a8ff106 ctdb-tests: Reformat with "shfmt -w -i 0 -fn "
      from  b72a7e2fb53 s3:libsmb: Fix heap-use-after-free in 
py_cli_notify_get_changes()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d950c7399796458bcbfda4d7d8d3de3a24b532dd
Author: Martin Schwenke <[email protected]>
Date:   Sat Oct 11 17:52:32 2025 +1100

    ctdb-tests: Don't hard code creation of $CTDB_BASE/events/legacy/
    
    setup_ctdb_base() should always create from etc-ctdb/.  That directory
    may be changed to not include the legacy/ component subdirectory, so
    don't hard-code this particular subdirectory.
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    
    Autobuild-User(master): Ralph Böhme <[email protected]>
    Autobuild-Date(master): Tue Oct 14 17:57:49 UTC 2025 on atb-devel-224

commit 98cecce76d15308e321a3ce57ce389ad457ee858
Author: Martin Schwenke <[email protected]>
Date:   Tue Oct 7 22:27:06 2025 +1100

    ctdb-tests: Improve setup_ctdb_base() to fix local_daemons.sh bug
    
    $ ctdb/tests/local_daemons.sh foo onnode 0 ctdb event script list legacy
    Unable to find event script installation directory: 
foo/node.0/share/events/legacy
    
    This happens if the $CTDB_BASE/share/events/legacy/ directory does not
    exist.  This directory is (theoretically) for installed but not
    necessarily enabled event scripts.  ctdb/tests/etc-ctdb/ contains
    events/legacy/ but setup_ctdb_base() currently does not ensure
    creation of the corresponding directory under $CTDB_BASE/share/.
    
    Ensure that an event script component installation subdirectory exists
    for each corresponding configuration subdirectory.
    
    An alternative would be to continue to allow the existing failure, but
    create directory ctdb/tests/etc-ctdb/share/events/legacy/ specifically
    to make local_daemons.sh work.  However, it took 5 years to find the
    current bug, so this may be too subtle for other users of
    local_daemons.sh.  Anyone wanting to test the failure case can remove
    unwanted subdirectories after "local_daemons.sh setup".
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 5a30073278e038629cf80f7d4df5b11b4c0ebaeb
Author: Martin Schwenke <[email protected]>
Date:   Sat Oct 11 15:45:09 2025 +1100

    ctdb-event: Improve error message
    
    The current message:
    
      Command script list finished with result=2
    
    does not clearly explain the problem.
    
    Improve it.
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 4ba5a8ff106653292432d7cc32e1f2c8fca2a650
Author: Martin Schwenke <[email protected]>
Date:   Tue Oct 7 22:48:40 2025 +1100

    ctdb-tests: Reformat with "shfmt -w -i 0 -fn "
    
    Best reviewed with "git show -w".
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/event/event_tool.c                           |  11 +-
 ctdb/tests/UNIT/eventd/eventd_001.sh              |   3 +-
 ctdb/tests/scripts/cluster.bash                   |   6 +-
 ctdb/tests/scripts/common.sh                      |  75 ++-
 ctdb/tests/scripts/integration.bash               | 710 +++++++++++-----------
 ctdb/tests/scripts/integration_local_daemons.bash |  35 +-
 ctdb/tests/scripts/integration_real_cluster.bash  |  14 +-
 ctdb/tests/scripts/script_install_paths.sh        |  31 +-
 8 files changed, 459 insertions(+), 426 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/event/event_tool.c b/ctdb/event/event_tool.c
index baf4763cb1f..b93b9454ad1 100644
--- a/ctdb/event/event_tool.c
+++ b/ctdb/event/event_tool.c
@@ -385,6 +385,7 @@ static int event_command_script_list(TALLOC_CTX *mem_ctx,
        char *data_dir = NULL;
        char *etc_dir = NULL;
        char *t = NULL;
+       char *real_data_dir = NULL;
        struct event_script_list *data_list = NULL;
        struct event_script_list *etc_list = NULL;
        unsigned int i, j, matched;
@@ -410,14 +411,18 @@ static int event_command_script_list(TALLOC_CTX *mem_ctx,
                return ENOMEM;
        }
 
-       data_dir = realpath(data_dir, t);
-       if (data_dir == NULL) {
+       real_data_dir = realpath(data_dir, t);
+       if (real_data_dir == NULL) {
                if (errno != ENOENT) {
                        return errno;
                }
-               D_ERR("Command script list finished with result=%d\n", ENOENT);
+               D_ERR("Unable to find event script installation directory: 
%s\n",
+                     data_dir);
                return ENOENT;
        }
+       /* Some static analysers don't understand talloc */
+       TALLOC_FREE(data_dir);
+       data_dir = real_data_dir;
 
        etc_dir = path_etcdir_append(mem_ctx, subdir);
        if (etc_dir == NULL) {
diff --git a/ctdb/tests/UNIT/eventd/eventd_001.sh 
b/ctdb/tests/UNIT/eventd/eventd_001.sh
index 7d4ee9e4e91..2d39ee5ab1b 100755
--- a/ctdb/tests/UNIT/eventd/eventd_001.sh
+++ b/ctdb/tests/UNIT/eventd/eventd_001.sh
@@ -21,7 +21,8 @@ Script 01.test does not exist in foobar
 EOF
 simple_test script enable foobar 01.test
 
+dir="${CTDB_BASE}/share/events/foobar"
 required_error ENOENT <<EOF
-Command script list finished with result=$(errcode ENOENT)
+Unable to find event script installation directory: ${dir}
 EOF
 simple_test script list foobar
diff --git a/ctdb/tests/scripts/cluster.bash b/ctdb/tests/scripts/cluster.bash
index 916fc843bad..6a3d63fbf6b 100755
--- a/ctdb/tests/scripts/cluster.bash
+++ b/ctdb/tests/scripts/cluster.bash
@@ -2,7 +2,7 @@
 
 . "${TEST_SCRIPTS_DIR}/integration.bash"
 
-if ! ctdb_test_on_cluster ; then
+if ! ctdb_test_on_cluster; then
        # Do not run on local daemons
        ctdb_test_error \
                "ERROR: This test must be run against a real/virtual cluster"
@@ -10,8 +10,8 @@ fi
 
 h=$(hostname)
 
-for i in $(onnode -q all hostname) ; do
-       if [ "$h" = "$i" ] ; then
+for i in $(onnode -q all hostname); do
+       if [ "$h" = "$i" ]; then
                ctdb_test_error \
                        "ERROR: This test must not be run from a cluster node"
        fi
diff --git a/ctdb/tests/scripts/common.sh b/ctdb/tests/scripts/common.sh
index 5bc5869802c..ccdb7d6a04c 100644
--- a/ctdb/tests/scripts/common.sh
+++ b/ctdb/tests/scripts/common.sh
@@ -2,57 +2,57 @@
 
 # Common variables and functions for all CTDB tests.
 
-
 # Commands on different platforms may quote or sort things differently
 # without this
 export LANG=C
 
 # Print a message and exit.
-die ()
+die()
 {
-       echo "$1" >&2 ; exit "${2:-1}"
+       echo "$1" >&2
+       exit "${2:-1}"
 }
 
 . "${TEST_SCRIPTS_DIR}/script_install_paths.sh"
 
-if [ -d "$CTDB_SCRIPTS_TOOLS_BIN_DIR" ] ; then
+if [ -d "$CTDB_SCRIPTS_TOOLS_BIN_DIR" ]; then
        PATH="${CTDB_SCRIPTS_TOOLS_BIN_DIR}:${PATH}"
 fi
 
-if [ -d "$CTDB_SCRIPTS_TESTS_LIBEXEC_DIR" ] ; then
+if [ -d "$CTDB_SCRIPTS_TESTS_LIBEXEC_DIR" ]; then
        PATH="${CTDB_SCRIPTS_TESTS_LIBEXEC_DIR}:${PATH}"
 fi
 
-ctdb_test_error ()
+ctdb_test_error()
 {
-       if [ $# -gt 0 ] ; then
+       if [ $# -gt 0 ]; then
                echo "$*"
        fi
        exit 99
 }
 
-ctdb_test_fail ()
+ctdb_test_fail()
 {
-       if [ $# -gt 0 ] ; then
+       if [ $# -gt 0 ]; then
                echo "$*"
        fi
        exit 1
 }
 
-ctdb_test_skip ()
+ctdb_test_skip()
 {
-       if [ $# -gt 0 ] ; then
+       if [ $# -gt 0 ]; then
                echo "$*"
        fi
        exit 77
 }
 
 # "$@" is supported OSes
-ctdb_test_check_supported_OS ()
+ctdb_test_check_supported_OS()
 {
        _os=$(uname -s)
-       for _i ; do
-               if [ "$_os" = "$_i" ] ; then
+       for _i; do
+               if [ "$_os" = "$_i" ]; then
                        return
                fi
        done
@@ -63,35 +63,41 @@ ctdb_test_check_supported_OS ()
 # Wait until either timeout expires or command succeeds.  The command
 # will be tried once per second, unless timeout has format T/I, where
 # I is the recheck interval.
-wait_until ()
+wait_until()
 {
-       _timeout="$1" ; shift # "$@" is the command...
+       _timeout="$1"
+       shift # "$@" is the command...
 
        _interval=1
        case "$_timeout" in
        */*)
                _interval="${_timeout#*/}"
                _timeout="${_timeout%/*}"
+               ;;
        esac
 
        _negate=false
-       if [ "$1" = "!" ] ; then
+       if [ "$1" = "!" ]; then
                _negate=true
                shift
        fi
 
        printf '<%d|' "$_timeout"
        _t="$_timeout"
-       while [ "$_t" -gt 0 ] ; do
+       while [ "$_t" -gt 0 ]; do
                _rc=0
                "$@" || _rc=$?
-               if { ! $_negate && [ $_rc -eq 0 ] ; } || \
-                          { $_negate && [ $_rc -ne 0 ] ; } ; then
+               if {
+                       ! $_negate && [ $_rc -eq 0 ]
+               } ||
+                       {
+                               $_negate && [ $_rc -ne 0 ]
+                       }; then
                        echo "|$((_timeout - _t))|"
                        echo "OK"
                        return 0
                fi
-               for _i in $(seq 1 "$_interval") ; do
+               for _i in $(seq 1 "$_interval"); do
                        printf '.'
                done
                _t=$((_t - _interval))
@@ -104,12 +110,12 @@ wait_until ()
 }
 
 # setup_ctdb_base <parent> <subdir> [item-to-copy]...
-setup_ctdb_base ()
+setup_ctdb_base()
 {
        [ $# -ge 2 ] || die "usage: setup_ctdb_base <parent> <subdir> [item]..."
        # If empty arguments are passed then we attempt to remove /
        # (i.e. the root directory) below
-       if [ -z "$1" ] || [ -z "$2" ] ; then
+       if [ -z "$1" ] || [ -z "$2" ]; then
                die "usage: setup_ctdb_base <parent> <subdir> [item]..."
        fi
 
@@ -120,27 +126,38 @@ setup_ctdb_base ()
        shift 2
 
        export CTDB_BASE="${_parent}/${_subdir}"
-       if [ -d "$CTDB_BASE" ] ; then
+       if [ -d "$CTDB_BASE" ]; then
                rm -r "$CTDB_BASE"
        fi
        mkdir -p "$CTDB_BASE" || die "Failed to create CTDB_BASE=$CTDB_BASE"
        mkdir -p "${CTDB_BASE}/run" || die "Failed to create ${CTDB_BASE}/run"
        mkdir -p "${CTDB_BASE}/var" || die "Failed to create ${CTDB_BASE}/var"
 
-       for _i ; do
+       for _i; do
                cp -pr "${CTDB_SCRIPTS_BASE}/${_i}" "${CTDB_BASE}/"
        done
 
-       mkdir -p "${CTDB_BASE}/events/legacy"
-
-       if [ -z "$CTDB_TEST_SUITE_DIR" ] ; then
+       if [ -z "$CTDB_TEST_SUITE_DIR" ]; then
                return
        fi
 
-       for _i in "${CTDB_TEST_SUITE_DIR}/etc-ctdb/"* ; do
+       for _i in "${CTDB_TEST_SUITE_DIR}/etc-ctdb/"*; do
                # No/empty etc-ctdb directory
                [ -e "$_i" ] || break
 
                cp -pr "$_i" "${CTDB_BASE}/"
+
+       done
+
+       # Ensure existence of an event script component installation
+       # subdirectory corresponding to each event script component
+       # configuration subdirectory.
+       #
+       # This helps:
+       #   local_daemons.sh <dir> onnode <n> ctdb event script list <component>
+       # to work.
+       for _d in "${CTDB_BASE}/events/"*; do
+               _b=$(basename "$_d")
+               mkdir -p "${CTDB_BASE}/share/events/${_b}"
        done
 }
diff --git a/ctdb/tests/scripts/integration.bash 
b/ctdb/tests/scripts/integration.bash
index 65e974e4e36..1670b6572ed 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -6,10 +6,10 @@
 
 export CTDB_TIMEOUT=60
 
-if [ -n "$CTDB_TEST_REMOTE_DIR" ] ; then
+if [ -n "$CTDB_TEST_REMOTE_DIR" ]; then
        CTDB_TEST_WRAPPER="${CTDB_TEST_REMOTE_DIR}/test_wrap"
 else
-       _d=$(cd "$TEST_SCRIPTS_DIR" &&  echo "$PWD")
+       _d=$(cd "$TEST_SCRIPTS_DIR" && echo "$PWD")
        CTDB_TEST_WRAPPER="$_d/test_wrap"
 fi
 export CTDB_TEST_WRAPPER
@@ -23,49 +23,49 @@ PATH="${TEST_SCRIPTS_DIR}:${PATH}"
 
 ######################################################################
 
-ctdb_test_on_cluster ()
+ctdb_test_on_cluster()
 {
        [ -z "$CTDB_TEST_LOCAL_DAEMONS" ]
 }
 
-ctdb_test_exit ()
+ctdb_test_exit()
 {
-    local status=$?
+       local status=$?
 
-    trap - 0
+       trap - 0
 
-    # run_tests.sh pipes stdout into tee.  If the tee process is
-    # killed then any attempt to write to stdout (e.g. echo) will
-    # result in SIGPIPE, terminating the caller.  Ignore SIGPIPE to
-    # ensure that all clean-up is run.
-    trap '' PIPE
+       # run_tests.sh pipes stdout into tee.  If the tee process is
+       # killed then any attempt to write to stdout (e.g. echo) will
+       # result in SIGPIPE, terminating the caller.  Ignore SIGPIPE to
+       # ensure that all clean-up is run.
+       trap '' PIPE
 
-    # Avoid making a test fail from this point onwards.  The test is
-    # now complete.
-    set +e
+       # Avoid making a test fail from this point onwards.  The test is
+       # now complete.
+       set +e
 
-    echo "*** TEST COMPLETED (RC=$status) AT $(date '+%F %T'), CLEANING UP..."
+       echo "*** TEST COMPLETED (RC=$status) AT $(date '+%F %T'), CLEANING 
UP..."
 
-    eval "$ctdb_test_exit_hook" || true
-    unset ctdb_test_exit_hook
+       eval "$ctdb_test_exit_hook" || true
+       unset ctdb_test_exit_hook
 
-    echo "Stopping cluster..."
-    ctdb_nodes_stop || ctdb_test_error "Cluster shutdown failed"
+       echo "Stopping cluster..."
+       ctdb_nodes_stop || ctdb_test_error "Cluster shutdown failed"
 
-    exit $status
+       exit $status
 }
 
-ctdb_test_exit_hook_add ()
+ctdb_test_exit_hook_add()
 {
-    ctdb_test_exit_hook="${ctdb_test_exit_hook}${ctdb_test_exit_hook:+ ; }$*"
+       ctdb_test_exit_hook="${ctdb_test_exit_hook}${ctdb_test_exit_hook:+ ; 
}$*"
 }
 
 # Setting cleanup_pid to <pid>@<node> will cause <pid> to be killed on
 # <node> when the test completes.  To cancel, just unset cleanup_pid.
 ctdb_test_cleanup_pid=""
-ctdb_test_cleanup_pid_exit_hook ()
+ctdb_test_cleanup_pid_exit_hook()
 {
-       if [ -n "$ctdb_test_cleanup_pid" ] ; then
+       if [ -n "$ctdb_test_cleanup_pid" ]; then
                local pid="${ctdb_test_cleanup_pid%@*}"
                local node="${ctdb_test_cleanup_pid#*@}"
 
@@ -75,7 +75,7 @@ ctdb_test_cleanup_pid_exit_hook ()
 
 ctdb_test_exit_hook_add ctdb_test_cleanup_pid_exit_hook
 
-ctdb_test_cleanup_pid_set ()
+ctdb_test_cleanup_pid_set()
 {
        local node="$1"
        local pid="$2"
@@ -83,19 +83,19 @@ ctdb_test_cleanup_pid_set ()
        ctdb_test_cleanup_pid="${pid}@${node}"
 }
 
-ctdb_test_cleanup_pid_clear ()
+ctdb_test_cleanup_pid_clear()
 {
        ctdb_test_cleanup_pid=""
 }
 
 # -n option means do not configure/start cluster
-ctdb_test_init ()
+ctdb_test_init()
 {
        trap "ctdb_test_exit" 0
 
        ctdb_nodes_stop >/dev/null 2>&1 || true
 
-       if [ "$1" != "-n" ] ; then
+       if [ "$1" != "-n" ]; then
                echo "Configuring cluster..."
                setup_ctdb || ctdb_test_error "Cluster configuration failed"
 
@@ -103,12 +103,12 @@ ctdb_test_init ()
                ctdb_init || ctdb_test_error "Cluster startup failed"
        fi
 
-       echo  "*** SETUP COMPLETE AT $(date '+%F %T'), RUNNING TEST..."
+       echo "*** SETUP COMPLETE AT $(date '+%F %T'), RUNNING TEST..."
 }
 
-ctdb_nodes_start_custom ()
+ctdb_nodes_start_custom()
 {
-       if ctdb_test_on_cluster ; then
+       if ctdb_test_on_cluster; then
                ctdb_test_error "ctdb_nodes_start_custom() on real cluster"
        fi
 
@@ -121,16 +121,15 @@ ctdb_nodes_start_custom ()
        ctdb_init || ctdb_test_fail "Cluster startup failed"
 }
 
-ctdb_test_skip_on_cluster ()
+ctdb_test_skip_on_cluster()
 {
-       if ctdb_test_on_cluster ; then
+       if ctdb_test_on_cluster; then
                ctdb_test_skip \
                        "SKIPPING this test - only runs against local daemons"
        fi
 }
 
-
-ctdb_nodes_restart ()
+ctdb_nodes_restart()
 {
        ctdb_nodes_stop "$@"
        ctdb_nodes_start "$@"
@@ -145,57 +144,59 @@ ctdb_nodes_restart ()
 out=""
 outfile="${CTDB_TEST_TMP_DIR}/try_command_on_node.out"
 
-outfile_cleanup ()
+outfile_cleanup()
 {
        rm -f "$outfile"
 }
 
 ctdb_test_exit_hook_add outfile_cleanup
 
-try_command_on_node ()
+try_command_on_node()
 {
-    local nodespec="$1" ; shift
+       local nodespec="$1"
+       shift
 
-    local verbose=false
-    local onnode_opts=""
+       local verbose=false
+       local onnode_opts=""
 
-    while [ "${nodespec#-}" != "$nodespec" ] ; do
-       if [ "$nodespec" = "-v" ] ; then
-           verbose=true
-       else
-           onnode_opts="${onnode_opts}${onnode_opts:+ }${nodespec}"
-       fi
-       nodespec="$1" ; shift
-    done
+       while [ "${nodespec#-}" != "$nodespec" ]; do
+               if [ "$nodespec" = "-v" ]; then
+                       verbose=true
+               else
+                       onnode_opts="${onnode_opts}${onnode_opts:+ }${nodespec}"
+               fi
+               nodespec="$1"
+               shift
+       done
 
-    local cmd="$*"
+       local cmd="$*"
 
-    local status=0
-    # Intentionally unquoted - might be empty
-    # shellcheck disable=SC2086
-    onnode -q $onnode_opts "$nodespec" "$cmd" >"$outfile" 2>&1 || status=$?
-    out=$(dd if="$outfile" bs=1k count=1 2>/dev/null)
+       local status=0
+       # Intentionally unquoted - might be empty
+       # shellcheck disable=SC2086
+       onnode -q $onnode_opts "$nodespec" "$cmd" >"$outfile" 2>&1 || status=$?
+       out=$(dd if="$outfile" bs=1k count=1 2>/dev/null)
 
-    if [ $status -ne 0 ] ; then
-       echo "Failed to execute \"$cmd\" on node(s) \"$nodespec\""
-       cat "$outfile"
-       return $status
-    fi
+       if [ $status -ne 0 ]; then
+               echo "Failed to execute \"$cmd\" on node(s) \"$nodespec\""
+               cat "$outfile"
+               return $status
+       fi
 
-    if $verbose ; then
-       echo "Output of \"$cmd\":"
-       cat "$outfile" || true
-    fi
+       if $verbose; then
+               echo "Output of \"$cmd\":"
+               cat "$outfile" || true
+       fi
 }
 
-_run_onnode ()
+_run_onnode()
 {
        local thing="$1"
        shift
 
        local options nodespec
 
-       while : ; do


-- 
Samba Shared Repository

Reply via email to