[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Wed Aug 14 10:30:02 UTC 2019


The branch, master has been updated
       via  6c9d1f855ea ctdb-daemon: Avoid signed/unsigned comparison by casting
       via  4bdfbbd8d4f ctdb-daemon: Avoid signed/unsigned comparison by declaring as unsigned
       via  5a3d99dc7ad ctdb-common: Return value of ctdb_queue_length() should be unsigned
       via  f7f9f57d2e1 ctdb-tests: Use select_test_node() in ctdb setdebug simple test
       via  3ea95ab4cb7 ctdb-tests: Add function select_test_node()
       via  a074dbf6454 ctdb-tools: Fix usage for "ctdb cattdb"
       via  695b3a965b8 ctdb-tests: Don't print summary on failure if -e option is specified
       via  7c01bf3d37b ctdb-tests: Drop mention of non-existent -s option
       via  b3b44ae532a ctdb-tests: Add -I <count> option for iterating tests
       via  91e6fc209be ctdb-tests: Factor out main test loop into run_tests()
       via  da33fb27ab4 ctdb-tests: Add shellcheck test for some test scripts and includes
       via  027b7ca0036 ctdb-tests: New variable CTDB_SCRIPTS_TESTS_BIN_DIR
       via  ba55306fce0 ctdb-tests: Rename CTDB_SCRIPTS_TESTS_BINDIR to CTDB_SCRIPTS_TESTS_LIBEXEC_DIR
       via  061656d3837 ctdb-tests: Simplify test_wrap script
       via  b1d36e94d2e ctdb-tests: Avoid shellcheck warning SC2045
       via  7d95cb22a4e ctdb-tests: Avoid shellcheck warning SC2034
       via  b198de03dce ctdb-tests: Avoid shellcheck warning SC2230
       via  93b3b010327 ctdb-tests: Avoid shellcheck warning SC2188
       via  45c9fe3abbf ctdb-tests: Avoid shellcheck warning SC2155
       via  664968e523c ctdb-tests: Avoid shellcheck warning SC2004
       via  034f4cfab8b ctdb-tests: Avoid shellcheck warning SC2164
       via  83f73b5abce ctdb-tests: Avoid shellcheck warning SC2086
       via  758962a0d43 ctdb-tools: Drop 'o' option from getopts command
      from  dee721af72e torture: Fix CID 1452288 Null pointer dereferences  (NULL_RETURNS)

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


- Log -----------------------------------------------------------------
commit 6c9d1f855ea3fe3d12f712678b7b4347f8982977
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 1 10:58:42 2019 +1000

    ctdb-daemon: Avoid signed/unsigned comparison by casting
    
    Compiling with -Wsign-compare complains:
    
     1047 |  &&  (call->call_id == CTDB_FETCH_WITH_HEADER_FUNC)) {
          |                     ^~
    
    struct ctdb_call is a protocol element, so we can't simply change it.
    
    Found by csbuild.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Wed Aug 14 10:29:59 UTC 2019 on sn-devel-184

commit 4bdfbbd8d4fb681d509d702a8a357b11c8dddcac
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 1 10:55:39 2019 +1000

    ctdb-daemon: Avoid signed/unsigned comparison by declaring as unsigned
    
    Compiling with -Wsign-compare complains:
    
    ctdb/server/ctdb_call.c:831:12: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
      831 |  if (count <= ctdb_db->statistics.hot_keys[0].count) {
          |            ^~
    
    and
    
    ctdb/server/ctdb_call.c:844:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
      844 |   if (count <= ctdb_db->statistics.hot_keys[i].count) {
          |             ^~
    
    Found by cs-build.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5a3d99dc7ad49717252d8c9625e0f8d064cffcd8
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 1 10:46:36 2019 +1000

    ctdb-common: Return value of ctdb_queue_length() should be unsigned
    
    Compiling with -Wsign-compare complains:
    
    ctdb/server/ctdb_daemon.c: scope_hint: In function ‘daemon_queue_send’
    ctdb/server/ctdb_daemon.c:259:40: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
    ...
    
    The struct ctdb_queue member out_queue_length is actually uint32_t, so
    just return that type.
    
    Found by csbuild.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit f7f9f57d2e13e7ced1f2237273965af8dfc29335
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jul 26 11:15:50 2019 +1000

    ctdb-tests: Use select_test_node() in ctdb setdebug simple test
    
    There is no requirement for IP addresses here.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 3ea95ab4cb70224b96a3f40fed9bb6dcc2abedf7
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jul 26 11:15:05 2019 +1000

    ctdb-tests: Add function select_test_node()
    
    Should be used when public IP addresses are not assigned.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a074dbf6454cc37ec9cda92dd897316cc27cd630
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 1 16:16:31 2019 +1000

    ctdb-tools: Fix usage for "ctdb cattdb"
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 695b3a965b856b2bffa5809d4bb71b9d827c392c
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 11:52:16 2019 +1000

    ctdb-tests: Don't print summary on failure if -e option is specified
    
    If there is a failure it will always be the last test run.  Don't
    obscure this by following it with a summary.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 7c01bf3d37b1b21550ee6aabbad266acc34056a2
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 11:50:21 2019 +1000

    ctdb-tests: Drop mention of non-existent -s option
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b3b44ae532a19348a93b16314c44b983070a78c0
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 11:48:13 2019 +1000

    ctdb-tests: Add -I <count> option for iterating tests
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 91e6fc209be07c13db1d85fb268d4ff56b257973
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 11:19:30 2019 +1000

    ctdb-tests: Factor out main test loop into run_tests()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit da33fb27ab4f858689d4e93760edadd2018b9068
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 12 15:13:47 2019 +1000

    ctdb-tests: Add shellcheck test for some test scripts and includes
    
    These files now pass, so we might as well keep them in good shape.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 027b7ca0036db952d647df41e87498dc66a40054
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 13 10:57:47 2019 +1000

    ctdb-tests: New variable CTDB_SCRIPTS_TESTS_BIN_DIR
    
    This can be used to find ctdb_run_tests and ctdb_local_daemons.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ba55306fce0025023e6deea637fa8eb13aa73ad2
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 13 10:53:48 2019 +1000

    ctdb-tests: Rename CTDB_SCRIPTS_TESTS_BINDIR to CTDB_SCRIPTS_TESTS_LIBEXEC_DIR
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 061656d383772b27607b8feb4a4ea9c988ce17d8
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 12 22:10:41 2019 +1000

    ctdb-tests: Simplify test_wrap script
    
    Given other improvements, this is now needlessly complex.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b1d36e94d2edbab89d7db5055b13689d94b128ad
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 10:28:52 2019 +1000

    ctdb-tests: Avoid shellcheck warning SC2045
    
    SC2045 Iterating over ls output is fragile. Use globs.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 7d95cb22a4e8638d71072e3d377076e9e01877ed
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 10:22:36 2019 +1000

    ctdb-tests: Avoid shellcheck warning SC2034
    
    SC2034 summary appears unused. Verify use (or export if used externally)
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b198de03dce559decc25fd3ba65ee457fe6cb0ef
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 10:21:16 2019 +1000

    ctdb-tests: Avoid shellcheck warning SC2230
    
    SC2230 which is non-standard...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 93b3b01032781b75b3d7002f05ddbe2ffc38168d
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 10:19:13 2019 +1000

    ctdb-tests: Avoid shellcheck warning SC2188
    
    SC2188 This redirection doesn't have a command...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 45c9fe3abbf02646b68fe47dd89357bd055feb09
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 10:18:08 2019 +1000

    ctdb-tests: Avoid shellcheck warning SC2155
    
    SC2155 Declare and assign separately to avoid masking return values
    
    The wscript changes require an identical change in local_daemons.sh.
    
    While touching the lines in wscript, escape the backslashes to make
    them literal backslashes.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 664968e523c1533e0fd420d5a0961c7ae1790cff
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 10:14:22 2019 +1000

    ctdb-tests: Avoid shellcheck warning SC2004
    
    SC2004 $/${} is unnecessary on arithmetic variables
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 034f4cfab8b6690e07f5b9cfaaa5cb31ac29336e
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 10:12:23 2019 +1000

    ctdb-tests: Avoid shellcheck warning SC2164
    
    SC2164 Use 'cd ... || exit' or 'cd ... || return' in case cd fails
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 83f73b5abcef860a5a80b685337e5947c7c41b24
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 5 10:09:34 2019 +1000

    ctdb-tests: Avoid shellcheck warning SC2086
    
    SC2086 Double quote to prevent globbing and word splitting
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 758962a0d435fa595e3917b860a8fd266d122550
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 12 16:11:13 2019 +1000

    ctdb-tools: Drop 'o' option from getopts command
    
    Commit 90de5e0594b9180226b9a13293afe31f18576b3d remove the processing
    for this option but forgot to remove it from the getopts command.
    
    Versions of ShellCheck >= 0.4.7 warn on this, so it is worth fixing.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14086
    RN: Fix onnode test failure with ShellCheck >= 0.4.7
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/common/common.h                       |   2 +-
 ctdb/common/ctdb_io.c                      |   2 +-
 ctdb/server/ctdb_call.c                    |   6 +-
 ctdb/tests/local_daemons.sh                |   6 +-
 ctdb/tests/run_tests.sh                    | 116 +++++++++++++++++++----------
 ctdb/tests/scripts/common.sh               |   4 +-
 ctdb/tests/scripts/integration.bash        |   8 ++
 ctdb/tests/scripts/script_install_paths.sh |   9 ++-
 ctdb/tests/scripts/test_wrap               |  18 +----
 ctdb/tests/shellcheck/tests.sh             |  24 ++++++
 ctdb/tests/simple/13_ctdb_setdebug.sh      |   2 +-
 ctdb/tools/ctdb.c                          |   2 +-
 ctdb/tools/onnode                          |   2 +-
 ctdb/wscript                               |  16 ++--
 14 files changed, 140 insertions(+), 77 deletions(-)
 create mode 100755 ctdb/tests/shellcheck/tests.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/common/common.h b/ctdb/common/common.h
index 79f6b9ed03a..c50b52a5eb5 100644
--- a/ctdb/common/common.h
+++ b/ctdb/common/common.h
@@ -27,7 +27,7 @@
 typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
 				   void *private_data);
 
-int ctdb_queue_length(struct ctdb_queue *queue);
+uint32_t ctdb_queue_length(struct ctdb_queue *queue);
 
 int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length);
 
diff --git a/ctdb/common/ctdb_io.c b/ctdb/common/ctdb_io.c
index c16eb7f67b7..000f71e4c20 100644
--- a/ctdb/common/ctdb_io.c
+++ b/ctdb/common/ctdb_io.c
@@ -72,7 +72,7 @@ struct ctdb_queue {
 
 
 
-int ctdb_queue_length(struct ctdb_queue *queue)
+uint32_t ctdb_queue_length(struct ctdb_queue *queue)
 {
 	return queue->out_queue_length;
 }
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 346fe89010e..9e1c51bf57d 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -822,7 +822,7 @@ ctdb_defer_pinned_down_request(struct ctdb_context *ctdb, struct ctdb_db_context
 
 static void
 ctdb_update_db_stat_hot_keys(struct ctdb_db_context *ctdb_db, TDB_DATA key,
-			     int count)
+			     unsigned int count)
 {
 	int i, id;
 	char *keystr;
@@ -1044,7 +1044,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 		}
 	}
 	if ((c->flags & CTDB_WANT_READONLY) 
-	&&  (call->call_id == CTDB_FETCH_WITH_HEADER_FUNC)) {
+	&&  ((unsigned int)call->call_id == CTDB_FETCH_WITH_HEADER_FUNC)) {
 		TDB_DATA tdata;
 
 		tdata = tdb_fetch(ctdb_db->rottdb, call->key);
@@ -1983,7 +1983,7 @@ static void ctdb_migration_count_handler(TDB_DATA key, uint64_t counter,
 {
 	struct ctdb_db_context *ctdb_db = talloc_get_type_abort(
 		private_data, struct ctdb_db_context);
-	int value;
+	unsigned int value;
 
 	value = (counter < INT_MAX ? counter : INT_MAX);
 	ctdb_update_db_stat_hot_keys(ctdb_db, key, value);
diff --git a/ctdb/tests/local_daemons.sh b/ctdb/tests/local_daemons.sh
index d9bbc5dfbea..4934783ff9a 100755
--- a/ctdb/tests/local_daemons.sh
+++ b/ctdb/tests/local_daemons.sh
@@ -5,8 +5,9 @@ set -u
 export CTDB_TEST_MODE="yes"
 
 # Following 2 lines may be modified by installation script
-export CTDB_TESTS_ARE_INSTALLED=false
-export CTDB_TEST_DIR=$(dirname "$0")
+CTDB_TESTS_ARE_INSTALLED=false
+CTDB_TEST_DIR=$(dirname "$0")
+export CTDB_TESTS_ARE_INSTALLED CTDB_TEST_DIR
 
 export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts"
 
@@ -17,6 +18,7 @@ export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts"
 # to be correctly set so setup_ctdb_base() finds the etc-ctdb/
 # subdirectory and the test event script is correctly installed, so
 # fix it.
+# shellcheck disable=SC2034
 TEST_SUBDIR="$CTDB_TEST_DIR"
 
 if ! $CTDB_TESTS_ARE_INSTALLED ; then
diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh
index a9c68464883..2f692c1b90b 100755
--- a/ctdb/tests/run_tests.sh
+++ b/ctdb/tests/run_tests.sh
@@ -12,8 +12,9 @@ Options:
   -D		Show diff between failed/expected test output (some tests only)
   -e		Exit on the first test failure
   -H		No headers - for running single test with other wrapper
+  -I <count>    Iterate tests <count> times, exiting on failure (implies -e, -N)
   -N		Don't print summary of tests results after running all tests
-  -q		Quiet - don't show tests being run (hint: use with -s)
+  -q		Quiet - don't show tests being run (still displays summary)
   -S <lib>      Use socket wrapper library <lib> for local integration tests
   -v		Verbose - print test output for non-failures (only some tests)
   -V <dir>	Use <dir> as TEST_VAR_DIR
@@ -26,7 +27,7 @@ EOF
 # Print a message and exit.
 die ()
 {
-    echo "$1" >&2 ; exit ${2:-1}
+    echo "$1" >&2 ; exit "${2:-1}"
 }
 
 ######################################################################
@@ -35,6 +36,7 @@ with_summary=true
 with_desc=false
 quiet=false
 exit_on_fail=false
+max_iterations=1
 no_header=false
 
 export TEST_VERBOSE=false
@@ -48,7 +50,7 @@ export TEST_CLEANUP=false
 export TEST_TIMEOUT=3600
 export TEST_SOCKET_WRAPPER_SO_PATH=""
 
-while getopts "AcCdDehHNqS:T:vV:xX?" opt ; do
+while getopts "AcCdDehHI:NqS:T:vV:xX?" opt ; do
 	case "$opt" in
 	A) TEST_CAT_RESULTS_OPTS="-A" ;;
 	c) TEST_LOCAL_DAEMONS="" ;;
@@ -57,6 +59,7 @@ while getopts "AcCdDehHNqS:T:vV:xX?" opt ; do
 	D) TEST_DIFF_RESULTS=true ;;
 	e) exit_on_fail=true ;;
 	H) no_header=true ;;
+	I) max_iterations="$OPTARG" ; exit_on_fail=true ; with_summary=false ;;
 	N) with_summary=false ;;
 	q) quiet=true ;;
 	S) TEST_SOCKET_WRAPPER_SO_PATH="$OPTARG" ;;
@@ -106,11 +109,11 @@ ctdb_test_end ()
     local interp="SKIPPED"
     local statstr=" (reason $*)"
     if [ -n "$status" ] ; then
-	if [ $status -eq 0 ] ; then
+	if [ "$status" -eq 0 ] ; then
 	    interp="PASSED"
 	    statstr=""
 	    echo "ALL OK: $*"
-	elif [ $status -eq 124 ] ; then
+	elif [ "$status" -eq 124 ] ; then
 	    interp="TIMEOUT"
 	    statstr=" (status $status)"
 	else
@@ -119,7 +122,7 @@ ctdb_test_end ()
 	fi
     fi
 
-    testduration=$(($(date +%s)-$teststarttime))
+    testduration=$(($(date +%s) - teststarttime))
 
     echo "=========================================================================="
     echo "TEST ${interp}: ${name}${statstr} (duration: ${testduration}s)"
@@ -137,7 +140,7 @@ ctdb_test_run ()
 
     local status=0
     if [ -x "$1" ] ; then
-	    timeout $TEST_TIMEOUT "$@" || status=$?
+	    timeout "$TEST_TIMEOUT" "$@" || status=$?
     else
 	    echo "TEST IS NOT EXECUTABLE"
 	    status=1
@@ -153,9 +156,8 @@ ctdb_test_run ()
 tests_total=0
 tests_passed=0
 tests_failed=0
-summary=""
 
-if ! which mktemp >/dev/null 2>&1 ; then
+if ! type mktemp >/dev/null 2>&1 ; then
     # Not perfect, but it will do...
     mktemp ()
     {
@@ -169,7 +171,7 @@ if ! which mktemp >/dev/null 2>&1 ; then
 	    if $dir ; then
 		mkdir "$t"
 	    else
-		>"$t"
+		: >"$t"
 	    fi
 	)
 	echo "$t"
@@ -185,14 +187,14 @@ run_one_test ()
 {
     local f="$1"
 
-    tests_total=$(($tests_total + 1))
+    tests_total=$((tests_total + 1))
 
     ctdb_test_run "$f" | tee "$tf" | show_progress
     status=$?
     if [ $status -eq 0 ] ; then
-	tests_passed=$(($tests_passed + 1))
+	tests_passed=$((tests_passed + 1))
     else
-	tests_failed=$(($tests_failed + 1))
+	tests_failed=$((tests_failed + 1))
     fi
     if $with_summary ; then
 	local t
@@ -202,7 +204,7 @@ run_one_test ()
 	    t="*FAILED*"
 	fi
 	if $with_desc ; then
-	    desc=$(tail -n +4 $tf | head -n 1)
+	    desc=$(tail -n +4 "$tf" | head -n 1)
 	    f="$desc"
 	fi
 	echo "$t $f" >>"$sf"
@@ -218,7 +220,11 @@ find_and_run_one_test ()
 
     if [ -d "$f" ] ; then
 	local i
-	for i in $(ls "${f%/}/"*".sh" 2>/dev/null) ; do
+	for i in "${f%/}/"*".sh" ; do
+	    # Only happens if test removed (unlikely) or empty directory
+	    if [ ! -f "$i" ] ; then
+		break
+	    fi
 	    run_one_test "$i"
 	    if $exit_on_fail && [ $status -ne 0 ] ; then
 		break
@@ -233,11 +239,43 @@ find_and_run_one_test ()
     fi
 }
 
+run_tests ()
+{
+	local tests=("$@")
+
+	for f in "${tests[@]}" ; do
+		find_and_run_one_test "$f"
+
+		if [ $status -eq 127 ] ; then
+			# Find the the top-level tests directory
+			d=$(cd "$TEST_SCRIPTS_DIR" && echo "$PWD")
+			if [ -z "$d" ] ; then
+				local t="$TEST_SCRIPTS_DIR"
+				die "Unable to find TEST_SCRIPTS_DIR=\"${t}\""
+			fi
+			tests_dir=$(dirname "$d")
+			# Strip off current directory from beginning,
+			# if there, just to make paths more friendly.
+			tests_dir="${tests_dir#${PWD}/}"
+			find_and_run_one_test "$f" "$tests_dir"
+		fi
+
+		if [ $status -eq 127 ] ; then
+			die "test \"$f\" is not recognised"
+		fi
+
+		if $exit_on_fail && [ $status -ne 0 ] ; then
+			return $status
+		fi
+	done
+}
+
 export CTDB_TEST_MODE="yes"
 
 # Following 2 lines may be modified by installation script
-export CTDB_TESTS_ARE_INSTALLED=false
-export CTDB_TEST_DIR=$(dirname "$0")
+CTDB_TESTS_ARE_INSTALLED=false
+CTDB_TEST_DIR=$(dirname "$0")
+export CTDB_TESTS_ARE_INSTALLED CTDB_TEST_DIR
 
 if [ -z "$TEST_VAR_DIR" ] ; then
     if $CTDB_TESTS_ARE_INSTALLED ; then
@@ -295,34 +333,36 @@ for f ; do
 	fi
 done
 
-for f in "${tests[@]}" ; do
-    find_and_run_one_test "$f"
-
-    if [ $status -eq 127 ] ; then
-	# Find the the top-level tests directory
-	tests_dir=$(dirname $(cd $TEST_SCRIPTS_DIR; echo $PWD))
-	# Strip off current directory from beginning, if there, just
-	# to make paths more friendly.
-	tests_dir=${tests_dir#$PWD/}
-	find_and_run_one_test "$f" "$tests_dir"
-    fi
+iterations=0
+# Special case: -I 0 means iterate forever (until failure)
+while [ "$max_iterations" -eq 0 ] || [ $iterations -lt "$max_iterations" ] ; do
+	iterations=$((iterations + 1))
+
+	if [ "$max_iterations" -ne 1 ] ; then
+		echo
+		echo "##################################################"
+		echo "ITERATION ${iterations}"
+		echo "##################################################"
+		echo
+	fi
 
-    if [ $status -eq 127 ] ; then
-	    die "test \"$f\" is not recognised"
-    fi
+	run_tests "${tests[@]}"
+	status=$?
 
-    if $exit_on_fail && [ $status -ne 0 ] ; then
-	    break
-    fi
+	if [ $status -ne 0 ] ; then
+		break
+	fi
 done
 
 rm -f "$tf"
 
 if $with_summary ; then
-    echo
-    cat "$sf"
-    echo
-    echo "${tests_passed}/${tests_total} tests passed"
+	if [ $status -eq 0 ] || ! $exit_on_fail ; then
+		echo
+		cat "$sf"
+		echo
+		echo "${tests_passed}/${tests_total} tests passed"
+	fi
 fi
 
 rm -f "$sf"
diff --git a/ctdb/tests/scripts/common.sh b/ctdb/tests/scripts/common.sh
index ec06fa0c8db..519219ca982 100644
--- a/ctdb/tests/scripts/common.sh
+++ b/ctdb/tests/scripts/common.sh
@@ -25,8 +25,8 @@ if [ -d "$CTDB_SCRIPTS_TOOLS_BIN_DIR" ] ; then
 	PATH="${CTDB_SCRIPTS_TOOLS_BIN_DIR}:${PATH}"
 fi
 
-if [ -d "$CTDB_SCRIPTS_TESTS_BINDIR" ] ; then
-	PATH="${CTDB_SCRIPTS_TESTS_BINDIR}:${PATH}"
+if [ -d "$CTDB_SCRIPTS_TESTS_LIBEXEC_DIR" ] ; then
+	PATH="${CTDB_SCRIPTS_TESTS_LIBEXEC_DIR}:${PATH}"
 fi
 
 # Wait until either timeout expires or command succeeds.  The command
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash
index 30725c48e53..011aeadee40 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -150,6 +150,14 @@ sanity_check_output ()
     return $ret
 }
 
+select_test_node ()
+{
+	try_command_on_node any ctdb pnn || return 1
+
+	test_node="$out"
+	echo "Selected node ${test_node}"
+}
+
 # This returns a list of "ip node" lines in $outfile
 all_ips_on_node()
 {
diff --git a/ctdb/tests/scripts/script_install_paths.sh b/ctdb/tests/scripts/script_install_paths.sh
index d67d3fba19f..2bd8542e4b7 100644
--- a/ctdb/tests/scripts/script_install_paths.sh
+++ b/ctdb/tests/scripts/script_install_paths.sh
@@ -19,7 +19,8 @@ if ! $CTDB_TESTS_ARE_INSTALLED ; then
 	CTDB_SCRIPTS_TOOLS_HELPER_DIR="${ctdb_dir}/tools"
 	CTDB_SCRIPTS_HELPER_BINDIR="${top_dir}/bin"
 	CTDB_SCRIPTS_DATA_DIR="${ctdb_dir}/config"
-	CTDB_SCRIPTS_TESTS_BINDIR="${top_dir}/bin"
+	CTDB_SCRIPTS_TESTS_LIBEXEC_DIR="${top_dir}/bin"
+	CTDB_SCRIPTS_TESTS_BIN_DIR="$CTDB_TEST_DIR"
 else
 	# Installed
 	CTDB_SCRIPTS_BASE="/usr/local/etc/ctdb"
@@ -29,7 +30,8 @@ else
 	CTDB_SCRIPTS_TOOLS_HELPER_DIR="/usr/local/libexec/ctdb"
 	CTDB_SCRIPTS_HELPER_BINDIR="/usr/local/libexec/ctdb"
 	CTDB_SCRIPTS_DATA_DIR="/usr/local/share/ctdb"
-	CTDB_SCRIPTS_TESTS_BINDIR="/usr/local/libexec/ctdb/tests"
+	CTDB_SCRIPTS_TESTS_LIBEXEC_DIR="/usr/local/libexec/ctdb/tests"
+	CTDB_SCRIPTS_TESTS_BIN_DIR="/usr/local/bin"
 fi
 
 export CTDB_SCRIPTS_BASE \
@@ -40,4 +42,5 @@ export CTDB_SCRIPTS_BASE \
        CTDB_SCRIPTS_TOOLS_HELPER_DIR \
        CTDB_SCRIPTS_HELPER_BINDIR \
        CTDB_SCRIPTS_DATA_DIR \
-       CTDB_SCRIPTS_TESTS_BINDIR
+       CTDB_SCRIPTS_TESTS_LIBEXEC_DIR \
+       CTDB_SCRIPTS_TESTS_BIN_DIR
diff --git a/ctdb/tests/scripts/test_wrap b/ctdb/tests/scripts/test_wrap
index 3db3180ae98..d9a6d09e202 100755
--- a/ctdb/tests/scripts/test_wrap
+++ b/ctdb/tests/scripts/test_wrap
@@ -1,20 +1,10 @@
 #!/bin/bash
 
-# Execute the given command.  The intention is that it is a function
-# from "${TEST_SCRIPTS_DIR}/integration.bash".
+# Execute the given command.  The intention is that it is either
+# * a function from "${TEST_SCRIPTS_DIR}/integration.bash"; or
+# * a test helper binary
 
-PATH="$(dirname $0):${PATH}"
-
-TEST_SCRIPTS_DIR=$(dirname $0)
-
-# We need the test binaries (i.e. tests/bin/) to be in $PATH.  If they
-# aren't already in $PATH then we know that tests/bin/ sits alongside
-# tests/scripts/.
-f="fetch_ring"
-if [ ! $(which $f >/dev/null 2>&1) ] ; then
-    d=$(dirname "$TEST_SCRIPTS_DIR")/bin
-    [ -x "$d/$f" ] && PATH="$d:$PATH"
-fi
+TEST_SCRIPTS_DIR=$(dirname "$0")
 
 . "${TEST_SCRIPTS_DIR}/integration.bash"
 
diff --git a/ctdb/tests/shellcheck/tests.sh b/ctdb/tests/shellcheck/tests.sh
new file mode 100755
index 00000000000..c5a25aaf81a
--- /dev/null
+++ b/ctdb/tests/shellcheck/tests.sh
@@ -0,0 +1,24 @@
+#!/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"
diff --git a/ctdb/tests/simple/13_ctdb_setdebug.sh b/ctdb/tests/simple/13_ctdb_setdebug.sh
index 50c435b624d..3e04ca33733 100755
--- a/ctdb/tests/simple/13_ctdb_setdebug.sh
+++ b/ctdb/tests/simple/13_ctdb_setdebug.sh
@@ -19,7 +19,7 @@ set -e
 
 cluster_is_healthy
 
-select_test_node_and_ips
+select_test_node
 
 get_debug ()
 {
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 2cc72eedc76..4bbe8843671 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -2183,7 +2183,7 @@ static int control_cattdb(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 	int ret;
 
 	if (argc != 1) {
-		usage("catdb");
+		usage("cattdb");
 	}
 
 	if (! db_exists(mem_ctx, ctdb, argv[0], &db_id, &db_name, &db_flags)) {
diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode
index e143ba2d4d4..d6595fff4aa 100755
--- a/ctdb/tools/onnode
+++ b/ctdb/tools/onnode
@@ -72,7 +72,7 @@ parse_options ()
 {
 	local opt
 
-	while getopts "cf:hno:pqvPi?" opt ; do
+	while getopts "cf:hnpqvPi?" opt ; do
 		case "$opt" in
 		c) current=true ;;
 		f) ctdb_nodes_file="$OPTARG" ;;
diff --git a/ctdb/wscript b/ctdb/wscript
index 573a8f0e643..45207d5548a 100644
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -1091,14 +1091,10 @@ def build(bld):
                           os.path.join('tests/scripts', t),
                           destname=os.path.join('scripts', t))
 
-    sed_expr = 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
-               bld.env.CTDB_TEST_LIBEXECDIR)
-    bld.SAMBA_GENERATOR('ctdb-test-wrap',


-- 
Samba Shared Repository



More information about the samba-cvs mailing list