]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
selftests: mptcp: add mptcp_lib_make_file
authorGeliang Tang <geliang.tang@suse.com>
Tue, 28 Nov 2023 23:18:57 +0000 (15:18 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 Nov 2023 04:06:18 +0000 (20:06 -0800)
To avoid duplicated code in different MPTCP selftests, we can add
and use helpers defined in mptcp_lib.sh.

make_file() helper in mptcp_sockopt.sh and userspace_pm.sh are the same.
Export it into mptcp_lib.sh and rename it as mptcp_lib_kill_wait(). Use
it in both mptcp_connect.sh and mptcp_join.sh.

Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Mat Martineau <martineau@kernel.org>
Link: https://lore.kernel.org/r/20231128-send-net-next-2023107-v4-13-8d6b94150f6b@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/mptcp/mptcp_connect.sh
tools/testing/selftests/net/mptcp/mptcp_join.sh
tools/testing/selftests/net/mptcp/mptcp_lib.sh
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
tools/testing/selftests/net/mptcp/userspace_pm.sh

index c4f08976c4187e535bd357cea6fc5fca071e8aae..d20e278480fb620b4a1ffac93c89fead6631acea 100755 (executable)
@@ -592,9 +592,8 @@ make_file()
        ksize=$((SIZE / 1024))
        rem=$((SIZE - (ksize * 1024)))
 
-       dd if=/dev/urandom of="$name" bs=1024 count=$ksize 2> /dev/null
+       mptcp_lib_make_file $name 1024 $ksize
        dd if=/dev/urandom conv=notrunc of="$name" oflag=append bs=1 count=$rem 2> /dev/null
-       echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
 
        echo "Created $name (size $(du -b "$name")) containing data sent by $who"
 }
index a5d66d1bfeb4367ccbcf2b36f2cba233d67523ab..37f434cbfa4473494030f84535001119bce31a61 100755 (executable)
@@ -1171,8 +1171,7 @@ make_file()
        local who=$2
        local size=$3
 
-       dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null
-       echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
+       mptcp_lib_make_file $name 1024 $size
 
        print_info "Test file (size $size KB) for $who"
 }
index 718c79dda2b3cd43b6fc4ff6bbfc08b925736d96..61be4f29a69a797d3b152049bcd0a1f38ed5fb8a 100644 (file)
@@ -247,3 +247,12 @@ mptcp_lib_get_counter() {
 
        echo "${count}"
 }
+
+mptcp_lib_make_file() {
+       local name="${1}"
+       local bs="${2}"
+       local size="${3}"
+
+       dd if=/dev/urandom of="${name}" bs="${bs}" count="${size}" 2> /dev/null
+       echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "${name}"
+}
index bfa744e350eff246f8105d8f8e1342e7a9efc802..96dc46eda133cada72d39ed9012f162049b2f991 100755 (executable)
@@ -251,8 +251,7 @@ make_file()
        local who=$2
        local size=$3
 
-       dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null
-       echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
+       mptcp_lib_make_file $name 1024 $size
 
        echo "Created $name (size $size KB) containing data sent by $who"
 }
index f136956f6c95f7112b0ba9aedbc68f8e698d9132..6167837f48e17ef8ba0d41ba541f73da765f945e 100755 (executable)
@@ -164,22 +164,12 @@ print_title "Init"
 print_test "Created network namespaces ns1, ns2"
 test_pass
 
-make_file()
-{
-       # Store a chunk of data in a file to transmit over an MPTCP connection
-       local name=$1
-       local ksize=1
-
-       dd if=/dev/urandom of="$name" bs=2 count=$ksize 2> /dev/null
-       echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
-}
-
 make_connection()
 {
        if [ -z "$file" ]; then
                file=$(mktemp)
        fi
-       make_file "$file" "client"
+       mptcp_lib_make_file "$file" 2 1
 
        local is_v6=$1
        local app_port=$app4_port