[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Tue Mar 10 09:18:02 UTC 2020


The branch, master has been updated
       via  9f9dcfb6c32 ctdb-tests: Use built-in hexdump() in system socket tests
       via  602694522f5 ctdb-tests: Split system socket test
       via  b10e79f2088 ctdb-tests: Skip "ctdb process-exists" tests when not on Linux
       via  c5dd4767156 ctdb-tests: Add function ctdb_test_check_supported_OS
       via  8402dabf880 ctdb-tests: Use ctdb_test_skip() when initscript can not be found
       via  30180ef6c28 ctdb-tests: Use ctdb_test_skip() when shellcheck is not installed
       via  77f6977102e ctdb-tests: Skipped tests should not cause failure
      from  54f26cfcf25 autobuild: Run the none env in the samba-o3 build

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


- Log -----------------------------------------------------------------
commit 9f9dcfb6c3270a21f2a805b2aa308c5b584813e5
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 4 14:38:15 2020 +1100

    ctdb-tests: Use built-in hexdump() in system socket tests
    
    Better compatibility, since od output isn't consistent on FreeBSD.
    
    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): Tue Mar 10 09:17:12 UTC 2020 on sn-devel-184

commit 602694522f5650ebfa78adec8088002ca979af45
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Mar 10 17:32:52 2020 +1100

    ctdb-tests: Split system socket test
    
    One test for each of types, TCP, ARP.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b10e79f208848956f836b908dbcb58b030fab9c0
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 4 14:08:12 2020 +1100

    ctdb-tests: Skip "ctdb process-exists" tests when not on Linux
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c5dd476715640d532c37ad5b5a9065b70eadeea8
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 4 14:05:02 2020 +1100

    ctdb-tests: Add function ctdb_test_check_supported_OS
    
    Skips test if not on one of the supported OSes.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 8402dabf880a4aebca6aa6dc48e7db29a96cab28
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 9 20:03:09 2020 +1100

    ctdb-tests: Use ctdb_test_skip() when initscript can not be found
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 30180ef6c280a7aa3d683ae33877daa60ce6b3dd
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Mar 3 17:48:40 2020 +1100

    ctdb-tests: Use ctdb_test_skip() when shellcheck is not installed
    
    When the tests are run interactively this will make it more noticeable
    that shellcheck is not installed because the test summary will
    indicate missing tests.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 77f6977102e07286810a1f8420e63048183cfe22
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 5 11:40:56 2020 +1100

    ctdb-tests: Skipped tests should not cause failure
    
    Skipped tests return a status that indicates failure.  In combination
    with the -e option this results in an exit with failure on the first
    skipped test.
    
    Convert skipped test status to success.  The skip has already been
    counted.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/tests/UNIT/cunit/system_socket_test_001.sh    | 123 ---------------------
 ...ocket_test_001.sh => system_socket_test_002.sh} |  71 +-----------
 ctdb/tests/UNIT/cunit/system_socket_test_003.sh    |  39 +++++++
 ctdb/tests/UNIT/shellcheck/init_script.sh          |   3 +-
 ctdb/tests/UNIT/shellcheck/scripts/local.sh        |   2 +-
 ctdb/tests/UNIT/tool/ctdb.process-exists.001.sh    |   2 +
 ctdb/tests/UNIT/tool/ctdb.process-exists.002.sh    |   2 +
 ctdb/tests/UNIT/tool/ctdb.process-exists.003.sh    |   2 +
 ctdb/tests/run_tests.sh                            |   7 ++
 ctdb/tests/scripts/common.sh                       |  13 +++
 ctdb/tests/src/system_socket_test.c                |  27 +++--
 11 files changed, 87 insertions(+), 204 deletions(-)
 copy ctdb/tests/UNIT/cunit/{system_socket_test_001.sh => system_socket_test_002.sh} (50%)
 create mode 100755 ctdb/tests/UNIT/cunit/system_socket_test_003.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/tests/UNIT/cunit/system_socket_test_001.sh b/ctdb/tests/UNIT/cunit/system_socket_test_001.sh
index 4a74b8c64a0..389cec6ac8c 100755
--- a/ctdb/tests/UNIT/cunit/system_socket_test_001.sh
+++ b/ctdb/tests/UNIT/cunit/system_socket_test_001.sh
@@ -2,128 +2,5 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-out_file="${CTDB_TEST_TMP_DIR}/packet.out"
-
-remove_file ()
-{
-	rm -f "$out_file"
-}
-
-test_cleanup remove_file
-
-d=$(dirname "$out_file")
-mkdir -p "$d"
-
-########################################
-
 ok_null
 unit_test system_socket_test types
-
-arp_run ()
-{
-	$VALGRIND system_socket_test arp "$@" >"$out_file" || exit $?
-	od -A x -t x1 "$out_file"
-}
-
-arp_test ()
-{
-	os=$(uname)
-	if [ "$os" = "Linux" ] ; then
-		unit_test_notrace arp_run "$@"
-	else
-		ok "PACKETSOCKET not supported"
-		unit_test system_socket_test arp "$@"
-	fi
-}
-
-ok <<EOF
-000000 ff ff ff ff ff ff 12 34 56 78 9a bc 08 06 00 01
-000010 08 00 06 04 00 01 12 34 56 78 9a bc c0 a8 01 19
-000020 00 00 00 00 00 00 c0 a8 01 19 00 00 00 00 00 00
-000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-000040
-EOF
-arp_test "192.168.1.25" "12:34:56:78:9a:bc"
-
-ok <<EOF
-000000 ff ff ff ff ff ff 12 34 56 78 9a bc 08 06 00 01
-000010 08 00 06 04 00 02 12 34 56 78 9a bc c0 a8 01 19
-000020 12 34 56 78 9a bc c0 a8 01 19 00 00 00 00 00 00
-000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-000040
-EOF
-arp_test "192.168.1.25" "12:34:56:78:9a:bc" reply
-
-ok <<EOF
-000000 33 33 00 00 00 01 12 34 56 78 9a bc 86 dd 60 00
-000010 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 6a f7
-000020 28 ff fe fa d1 36 ff 02 00 00 00 00 00 00 00 00
-000030 00 00 00 00 00 01 88 00 8d e4 20 00 00 00 fe 80
-000040 00 00 00 00 00 00 6a f7 28 ff fe fa d1 36 02 01
-000050 12 34 56 78 9a bc
-000056
-EOF
-arp_test "fe80::6af7:28ff:fefa:d136" "12:34:56:78:9a:bc"
-
-tcp_run ()
-{
-	$VALGRIND system_socket_test tcp "$@" >"$out_file" || exit $?
-	od -A x -t x1 "$out_file"
-}
-
-tcp_test ()
-{
-	unit_test_notrace tcp_run "$@"
-}
-
-ok <<EOF
-000000 45 00 00 08 00 00 00 00 ff 06 00 00 c0 a8 01 19
-000010 c0 a8 02 4b 01 bd d4 31 00 00 00 00 00 00 00 00
-000020 50 10 04 d2 50 5f 00 00
-000028
-EOF
-tcp_test "192.168.1.25:445" "192.168.2.75:54321" 0 0 0
-
-ok <<EOF
-000000 45 00 00 08 00 00 00 00 ff 06 00 00 c0 a8 01 19
-000010 c0 a8 02 4b 01 bd d4 31 00 00 00 00 00 00 00 00
-000020 50 14 04 d2 50 5b 00 00
-000028
-EOF
-tcp_test "192.168.1.25:445" "192.168.2.75:54321" 0 0 1
-
-ok <<EOF
-000000 45 00 00 08 00 00 00 00 ff 06 00 00 c0 a8 01 19
-000010 c0 a8 02 4b 01 bd d4 31 39 30 00 00 a0 5b 00 00
-000020 50 14 04 d2 76 cf 00 00
-000028
-EOF
-tcp_test "192.168.1.25:445" "192.168.2.75:54321" 12345 23456 1
-
-ok <<EOF
-000000 60 00 00 00 00 14 06 40 fe 80 00 00 00 00 00 00
-000010 6a f7 28 ff fe fa d1 36 fe 80 00 00 00 00 00 00
-000020 6a f7 28 ff fe fb d1 37 01 bd d4 31 00 00 00 00
-000030 00 00 00 00 50 10 04 d2 0f c0 00 00
-00003c
-EOF
-tcp_test "fe80::6af7:28ff:fefa:d136:445" "fe80::6af7:28ff:fefb:d137:54321" 0 0 0
-
-ok <<EOF
-000000 60 00 00 00 00 14 06 40 fe 80 00 00 00 00 00 00
-000010 6a f7 28 ff fe fa d1 36 fe 80 00 00 00 00 00 00
-000020 6a f7 28 ff fe fb d1 37 01 bd d4 31 00 00 00 00
-000030 00 00 00 00 50 14 04 d2 0f bc 00 00
-00003c
-EOF
-tcp_test "fe80::6af7:28ff:fefa:d136:445" "fe80::6af7:28ff:fefb:d137:54321" 0 0 1
-
-ok <<EOF
-000000 60 00 00 00 00 14 06 40 fe 80 00 00 00 00 00 00
-000010 6a f7 28 ff fe fa d1 36 fe 80 00 00 00 00 00 00
-000020 6a f7 28 ff fe fb d1 37 01 bd d4 31 39 30 00 00
-000030 a0 5b 00 00 50 14 04 d2 36 30 00 00
-00003c
-EOF
-tcp_test "fe80::6af7:28ff:fefa:d136:445" \
-	 "fe80::6af7:28ff:fefb:d137:54321" 12345 23456 1
diff --git a/ctdb/tests/UNIT/cunit/system_socket_test_001.sh b/ctdb/tests/UNIT/cunit/system_socket_test_002.sh
similarity index 50%
copy from ctdb/tests/UNIT/cunit/system_socket_test_001.sh
copy to ctdb/tests/UNIT/cunit/system_socket_test_002.sh
index 4a74b8c64a0..8bea074bd8d 100755
--- a/ctdb/tests/UNIT/cunit/system_socket_test_001.sh
+++ b/ctdb/tests/UNIT/cunit/system_socket_test_002.sh
@@ -2,78 +2,9 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-out_file="${CTDB_TEST_TMP_DIR}/packet.out"
-
-remove_file ()
-{
-	rm -f "$out_file"
-}
-
-test_cleanup remove_file
-
-d=$(dirname "$out_file")
-mkdir -p "$d"
-
-########################################
-
-ok_null
-unit_test system_socket_test types
-
-arp_run ()
-{
-	$VALGRIND system_socket_test arp "$@" >"$out_file" || exit $?
-	od -A x -t x1 "$out_file"
-}
-
-arp_test ()
-{
-	os=$(uname)
-	if [ "$os" = "Linux" ] ; then
-		unit_test_notrace arp_run "$@"
-	else
-		ok "PACKETSOCKET not supported"
-		unit_test system_socket_test arp "$@"
-	fi
-}
-
-ok <<EOF
-000000 ff ff ff ff ff ff 12 34 56 78 9a bc 08 06 00 01
-000010 08 00 06 04 00 01 12 34 56 78 9a bc c0 a8 01 19
-000020 00 00 00 00 00 00 c0 a8 01 19 00 00 00 00 00 00
-000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-000040
-EOF
-arp_test "192.168.1.25" "12:34:56:78:9a:bc"
-
-ok <<EOF
-000000 ff ff ff ff ff ff 12 34 56 78 9a bc 08 06 00 01
-000010 08 00 06 04 00 02 12 34 56 78 9a bc c0 a8 01 19
-000020 12 34 56 78 9a bc c0 a8 01 19 00 00 00 00 00 00
-000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-000040
-EOF
-arp_test "192.168.1.25" "12:34:56:78:9a:bc" reply
-
-ok <<EOF
-000000 33 33 00 00 00 01 12 34 56 78 9a bc 86 dd 60 00
-000010 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 6a f7
-000020 28 ff fe fa d1 36 ff 02 00 00 00 00 00 00 00 00
-000030 00 00 00 00 00 01 88 00 8d e4 20 00 00 00 fe 80
-000040 00 00 00 00 00 00 6a f7 28 ff fe fa d1 36 02 01
-000050 12 34 56 78 9a bc
-000056
-EOF
-arp_test "fe80::6af7:28ff:fefa:d136" "12:34:56:78:9a:bc"
-
-tcp_run ()
-{
-	$VALGRIND system_socket_test tcp "$@" >"$out_file" || exit $?
-	od -A x -t x1 "$out_file"
-}
-
 tcp_test ()
 {
-	unit_test_notrace tcp_run "$@"
+	unit_test system_socket_test tcp "$@"
 }
 
 ok <<EOF
diff --git a/ctdb/tests/UNIT/cunit/system_socket_test_003.sh b/ctdb/tests/UNIT/cunit/system_socket_test_003.sh
new file mode 100755
index 00000000000..0b265eabdfa
--- /dev/null
+++ b/ctdb/tests/UNIT/cunit/system_socket_test_003.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+ctdb_test_check_supported_OS "Linux"
+
+arp_test ()
+{
+	unit_test system_socket_test arp "$@"
+}
+
+ok <<EOF
+000000 ff ff ff ff ff ff 12 34 56 78 9a bc 08 06 00 01
+000010 08 00 06 04 00 01 12 34 56 78 9a bc c0 a8 01 19
+000020 00 00 00 00 00 00 c0 a8 01 19 00 00 00 00 00 00
+000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+000040
+EOF
+arp_test "192.168.1.25" "12:34:56:78:9a:bc"
+
+ok <<EOF
+000000 ff ff ff ff ff ff 12 34 56 78 9a bc 08 06 00 01
+000010 08 00 06 04 00 02 12 34 56 78 9a bc c0 a8 01 19
+000020 12 34 56 78 9a bc c0 a8 01 19 00 00 00 00 00 00
+000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+000040
+EOF
+arp_test "192.168.1.25" "12:34:56:78:9a:bc" reply
+
+ok <<EOF
+000000 33 33 00 00 00 01 12 34 56 78 9a bc 86 dd 60 00
+000010 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 6a f7
+000020 28 ff fe fa d1 36 ff 02 00 00 00 00 00 00 00 00
+000030 00 00 00 00 00 01 88 00 8d e4 20 00 00 00 fe 80
+000040 00 00 00 00 00 00 6a f7 28 ff fe fa d1 36 02 01
+000050 12 34 56 78 9a bc
+000056
+EOF
+arp_test "fe80::6af7:28ff:fefa:d136" "12:34:56:78:9a:bc"
diff --git a/ctdb/tests/UNIT/shellcheck/init_script.sh b/ctdb/tests/UNIT/shellcheck/init_script.sh
index 148f6d7a4ff..1e1d54c08af 100755
--- a/ctdb/tests/UNIT/shellcheck/init_script.sh
+++ b/ctdb/tests/UNIT/shellcheck/init_script.sh
@@ -12,8 +12,7 @@ if [ -z "$script" ] ; then
 		script="/usr/local/etc/init.d/ctdb"
 	fi
 	if [ ! -r "$script" ] ; then
-		echo "WARNING: Unable to find ctdb init script, skipping test"
-		exit 0
+		ctdb_test_skip "Unable to find ctdb init script"
 	fi
 fi
 
diff --git a/ctdb/tests/UNIT/shellcheck/scripts/local.sh b/ctdb/tests/UNIT/shellcheck/scripts/local.sh
index 84019144009..6bc93fd9146 100644
--- a/ctdb/tests/UNIT/shellcheck/scripts/local.sh
+++ b/ctdb/tests/UNIT/shellcheck/scripts/local.sh
@@ -31,7 +31,7 @@ shellcheck_test ()
 		_excludes="SC1090,SC1091,SC2162,SC2164"
 		unit_test shellcheck --exclude="$_excludes" "$@"
 	else
-		echo "WARNING: shellcheck not installed, skipping test"
+		ctdb_test_skip "shellcheck not installed"
 		unit_test true
 	fi
 }
diff --git a/ctdb/tests/UNIT/tool/ctdb.process-exists.001.sh b/ctdb/tests/UNIT/tool/ctdb.process-exists.001.sh
index 1b6d213b3ad..d7dc3b21fe3 100755
--- a/ctdb/tests/UNIT/tool/ctdb.process-exists.001.sh
+++ b/ctdb/tests/UNIT/tool/ctdb.process-exists.001.sh
@@ -4,6 +4,8 @@
 
 define_test "ctdbd process on node 0"
 
+ctdb_test_check_supported_OS "Linux"
+
 setup_ctdbd <<EOF
 NODEMAP
 0       192.168.20.41   0x0     CURRENT RECMASTER
diff --git a/ctdb/tests/UNIT/tool/ctdb.process-exists.002.sh b/ctdb/tests/UNIT/tool/ctdb.process-exists.002.sh
index ace77493565..e432e212ba0 100755
--- a/ctdb/tests/UNIT/tool/ctdb.process-exists.002.sh
+++ b/ctdb/tests/UNIT/tool/ctdb.process-exists.002.sh
@@ -4,6 +4,8 @@
 
 define_test "ctdbd process on node 0"
 
+ctdb_test_check_supported_OS "Linux"
+
 setup_ctdbd <<EOF
 NODEMAP
 0       192.168.20.41   0x0     CURRENT RECMASTER
diff --git a/ctdb/tests/UNIT/tool/ctdb.process-exists.003.sh b/ctdb/tests/UNIT/tool/ctdb.process-exists.003.sh
index 402b0d6f5ab..630702673dc 100755
--- a/ctdb/tests/UNIT/tool/ctdb.process-exists.003.sh
+++ b/ctdb/tests/UNIT/tool/ctdb.process-exists.003.sh
@@ -4,6 +4,8 @@
 
 define_test "ctdbd process with multiple connections on node 0"
 
+ctdb_test_check_supported_OS "Linux"
+
 setup_ctdbd <<EOF
 NODEMAP
 0       192.168.20.41   0x0     CURRENT RECMASTER
diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh
index 2a5e4bbf996..cb7884054aa 100755
--- a/ctdb/tests/run_tests.sh
+++ b/ctdb/tests/run_tests.sh
@@ -176,6 +176,13 @@ ctdb_test_run ()
 		printf '%-10s %s\n' "$t" "$f" >>"$summary_file"
 	fi
 
+	# Skipped tests should not cause failure
+	case "$status" in
+	77)
+		status=0
+		;;
+	esac
+
 	return $status
 }
 
diff --git a/ctdb/tests/scripts/common.sh b/ctdb/tests/scripts/common.sh
index 326f136d638..5bc5869802c 100644
--- a/ctdb/tests/scripts/common.sh
+++ b/ctdb/tests/scripts/common.sh
@@ -47,6 +47,19 @@ ctdb_test_skip ()
 	exit 77
 }
 
+# "$@" is supported OSes
+ctdb_test_check_supported_OS ()
+{
+	_os=$(uname -s)
+	for _i ; do
+		if [ "$_os" = "$_i" ] ; then
+			return
+		fi
+	done
+
+	ctdb_test_skip "This test is not supported on ${_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.
diff --git a/ctdb/tests/src/system_socket_test.c b/ctdb/tests/src/system_socket_test.c
index da962f00a2c..a6fe8547651 100644
--- a/ctdb/tests/src/system_socket_test.c
+++ b/ctdb/tests/src/system_socket_test.c
@@ -36,6 +36,23 @@
 
 #include "protocol/protocol_util.h"
 
+static void hexdump(uint8_t *buf, size_t len)
+{
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		if (i % 16 == 0) {
+			if (i != 0) {
+				printf("\n");
+			}
+			printf("%06zx", i);
+		}
+		printf(" %02x", buf[i]);
+	}
+
+	printf("\n%06zx\n", i);
+}
+
 static void test_types(void)
 {
 	/*
@@ -59,7 +76,6 @@ static void test_arp(const char *addr_str, const char *hwaddr_str, bool reply)
 	uint8_t buf[512];
 	size_t buflen = sizeof(buf);
 	size_t len;
-	ssize_t num_written;
 	int ret;
 
 	ret = ctdb_sock_addr_from_string(addr_str, &addr, false);
@@ -81,8 +97,7 @@ static void test_arp(const char *addr_str, const char *hwaddr_str, bool reply)
 
 	assert(ret == 0);
 
-	num_written = write(STDOUT_FILENO, buf, len);
-	assert(num_written != -1 && (size_t)num_written == len);
+	hexdump(buf, len);
 }
 
 #else /* HAVE_PACKETSOCKET  */
@@ -106,7 +121,6 @@ static void test_tcp(const char *src_str,
 	uint8_t buf[512];
 	struct ether_header *eth;
 	size_t expected_len, len;
-	ssize_t num_written;
 	char src_str_out[64], dst_str_out[64];
 	uint32_t seq_out, ack_out;
 	int rst_out = 0;
@@ -159,10 +173,7 @@ static void test_tcp(const char *src_str,
 	assert(ret == 0);
 	assert(len == expected_len);
 
-	num_written = write(STDOUT_FILENO,
-			    buf + sizeof(struct ether_header),
-			    len);
-	assert(num_written != -1 && (size_t)num_written == len);
+	hexdump(buf + sizeof(struct ether_header), len);
 
 	switch (ntohs(eth->ether_type)) {
 	case ETHERTYPE_IP:


-- 
Samba Shared Repository



More information about the samba-cvs mailing list