Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: mptcp: add mptcp_lib_make_file

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>

authored by

Geliang Tang and committed by
Jakub Kicinski
3a96dea9 119931cc

+13 -17
+1 -2
tools/testing/selftests/net/mptcp/mptcp_connect.sh
··· 592 592 ksize=$((SIZE / 1024)) 593 593 rem=$((SIZE - (ksize * 1024))) 594 594 595 - dd if=/dev/urandom of="$name" bs=1024 count=$ksize 2> /dev/null 595 + mptcp_lib_make_file $name 1024 $ksize 596 596 dd if=/dev/urandom conv=notrunc of="$name" oflag=append bs=1 count=$rem 2> /dev/null 597 - echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 598 597 599 598 echo "Created $name (size $(du -b "$name")) containing data sent by $who" 600 599 }
+1 -2
tools/testing/selftests/net/mptcp/mptcp_join.sh
··· 1171 1171 local who=$2 1172 1172 local size=$3 1173 1173 1174 - dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 1175 - echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 1174 + mptcp_lib_make_file $name 1024 $size 1176 1175 1177 1176 print_info "Test file (size $size KB) for $who" 1178 1177 }
+9
tools/testing/selftests/net/mptcp/mptcp_lib.sh
··· 247 247 248 248 echo "${count}" 249 249 } 250 + 251 + mptcp_lib_make_file() { 252 + local name="${1}" 253 + local bs="${2}" 254 + local size="${3}" 255 + 256 + dd if=/dev/urandom of="${name}" bs="${bs}" count="${size}" 2> /dev/null 257 + echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "${name}" 258 + }
+1 -2
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
··· 251 251 local who=$2 252 252 local size=$3 253 253 254 - dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null 255 - echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 254 + mptcp_lib_make_file $name 1024 $size 256 255 257 256 echo "Created $name (size $size KB) containing data sent by $who" 258 257 }
+1 -11
tools/testing/selftests/net/mptcp/userspace_pm.sh
··· 164 164 print_test "Created network namespaces ns1, ns2" 165 165 test_pass 166 166 167 - make_file() 168 - { 169 - # Store a chunk of data in a file to transmit over an MPTCP connection 170 - local name=$1 171 - local ksize=1 172 - 173 - dd if=/dev/urandom of="$name" bs=2 count=$ksize 2> /dev/null 174 - echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" 175 - } 176 - 177 167 make_connection() 178 168 { 179 169 if [ -z "$file" ]; then 180 170 file=$(mktemp) 181 171 fi 182 - make_file "$file" "client" 172 + mptcp_lib_make_file "$file" 2 1 183 173 184 174 local is_v6=$1 185 175 local app_port=$app4_port