ctdb-tests: Split system socket test
authorMartin Schwenke <martin@meltin.net>
Tue, 10 Mar 2020 06:32:52 +0000 (17:32 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 10 Mar 2020 07:37:34 +0000 (07:37 +0000)
One test for each of types, TCP, ARP.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/UNIT/cunit/system_socket_test_001.sh
ctdb/tests/UNIT/cunit/system_socket_test_002.sh [new file with mode: 0755]
ctdb/tests/UNIT/cunit/system_socket_test_003.sh [new file with mode: 0755]

index 4a74b8c64a00d3a70d433ea8383b3126a3796bbf..389cec6ac8cb54d5e53f4da7c27a7f9fbe025c40 100755 (executable)
@@ -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_002.sh b/ctdb/tests/UNIT/cunit/system_socket_test_002.sh
new file mode 100755 (executable)
index 0000000..e22f248
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+. "${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"
+
+########################################
+
+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_003.sh b/ctdb/tests/UNIT/cunit/system_socket_test_003.sh
new file mode 100755 (executable)
index 0000000..df8bf5f
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+. "${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"
+
+########################################
+
+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"