Skip to content

Commit

Permalink
selftests: mptcp: join: create tmp files only if needed
Browse files Browse the repository at this point in the history
These tmp files will only be created when a test will be launched.

This avoid 'dd' output when '-h' is used for example.

While at it, also avoid creating netns that will be removed when
starting the first test.

Signed-off-by: Matthieu Baerts <[email protected]>
Signed-off-by: Mat Martineau <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
matttbe authored and kuba-moo committed Feb 18, 2022
1 parent 0a40e27 commit 93827ad
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ capture=0
checksum=0
ip_mptcp=0
do_all_tests=1
init=0

TEST_COUNT=0

Expand All @@ -38,7 +39,7 @@ CBPF_MPTCP_SUBOPTION_ADD_ADDR="14,
6 0 0 65535,
6 0 0 0"

init()
init_partial()
{
capout=$(mktemp)

Expand Down Expand Up @@ -98,6 +99,21 @@ cleanup_partial()
done
}

init() {
init=1

sin=$(mktemp)
sout=$(mktemp)
cin=$(mktemp)
cinsent=$(mktemp)
cout=$(mktemp)

trap cleanup EXIT

make_file "$cin" "client" 1
make_file "$sin" "server" 1
}

cleanup()
{
rm -f "$cin" "$cout" "$sinfail"
Expand All @@ -107,8 +123,13 @@ cleanup()

reset()
{
cleanup_partial
init
if [ "${init}" != "1" ]; then
init
else
cleanup_partial
fi

init_partial
}

reset_with_cookies()
Expand Down Expand Up @@ -2106,16 +2127,6 @@ usage()
exit ${ret}
}

sin=$(mktemp)
sout=$(mktemp)
cin=$(mktemp)
cinsent=$(mktemp)
cout=$(mktemp)
init
make_file "$cin" "client" 1
make_file "$sin" "server" 1
trap cleanup EXIT

for arg in "$@"; do
# check for "capture/checksum" args before launching tests
if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then
Expand Down

0 comments on commit 93827ad

Please sign in to comment.