Skip to content

Commit

Permalink
selftests: mptcp: add mptcp_lib_make_file
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Oct 17, 2023
1 parent 5131090 commit 1687fef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
3 changes: 1 addition & 2 deletions tools/testing/selftests/net/mptcp/mptcp_connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
9 changes: 9 additions & 0 deletions tools/testing/selftests/net/mptcp/mptcp_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 1 addition & 2 deletions tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $bs $size

echo "Created $name (size $size KB) containing data sent by $who"
}
Expand Down
12 changes: 1 addition & 11 deletions tools/testing/selftests/net/mptcp/userspace_pm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1687fef

Please sign in to comment.