All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Baerts <matthieu.baerts@tessares.net>
To: mptcp@lists.linux.dev
Cc: Matthieu Baerts <matthieu.baerts@tessares.net>
Subject: [PATCH mptcp-next 5/9] selftests: mptcp: join: create tmp files only if needed
Date: Wed,  9 Feb 2022 22:25:16 +0100	[thread overview]
Message-ID: <20220209212520.2989291-6-matthieu.baerts@tessares.net> (raw)
In-Reply-To: <20220209212520.2989291-1-matthieu.baerts@tessares.net>

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 <matthieu.baerts@tessares.net>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 37 ++++++++++++-------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index ce3e7db30b9d..5691221ca302 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -18,6 +18,7 @@ checksum=0
 ip_mptcp=0
 check_invert=0
 do_all_tests=1
+INIT=0
 
 TEST_COUNT=0
 ONLY_TESTS=()
@@ -41,7 +42,7 @@ CBPF_MPTCP_SUBOPTION_ADD_ADDR="14,
 			       6 0 0 65535,
 			       6 0 0 0"
 
-init()
+init_partial()
 {
 	capout=$(mktemp)
 
@@ -104,6 +105,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"
@@ -136,8 +152,13 @@ reset()
 		return 1
 	fi
 
-	cleanup_partial
-	init
+	if [ "${INIT}" != "1" ]; then
+		init
+	else
+		cleanup_partial
+	fi
+
+	init_partial
 
 	return 0
 }
@@ -2342,16 +2363,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
-- 
2.34.1


  parent reply	other threads:[~2022-02-09 21:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 21:25 [PATCH mptcp-next 0/9] Refactor mptcp_join.sh Matthieu Baerts
2022-02-09 21:25 ` [PATCH mptcp-next 1/9] selftests: mptcp: join: allow running -cCi Matthieu Baerts
2022-02-10 14:53   ` Paolo Abeni
2022-02-11 17:30     ` Matthieu Baerts
2022-02-11 18:56       ` Paolo Abeni
2022-02-09 21:25 ` [PATCH mptcp-next 2/9] selftests: mptcp: join: exit after usage() Matthieu Baerts
2022-02-09 21:25 ` [PATCH mptcp-next 3/9] selftests: mptcp: join: option to execute specific tests Matthieu Baerts
2022-02-10  0:36   ` Mat Martineau
2022-02-10 10:04     ` Paolo Abeni
2022-02-10 10:42       ` Matthieu Baerts
2022-02-10 15:11         ` Paolo Abeni
2022-02-16 15:50           ` Matthieu Baerts
2022-02-09 21:25 ` [PATCH mptcp-next 4/9] selftests: mptcp: join: remove unused vars Matthieu Baerts
2022-02-09 21:25 ` Matthieu Baerts [this message]
2022-02-09 21:25 ` [PATCH mptcp-next 6/9] selftests: mptcp: join: check for tools only if needed Matthieu Baerts
2022-02-09 21:25 ` [PATCH mptcp-next 7/9] selftests: mptcp: join: clarify local/global vars Matthieu Baerts
2022-02-09 21:25 ` [PATCH mptcp-next 8/9] selftests: mptcp: join: avoid backquotes Matthieu Baerts
2022-02-09 21:25 ` [PATCH mptcp-next 9/9] selftests: mptcp: join: make it shellcheck compliant Matthieu Baerts
2022-02-10  0:22 ` [PATCH mptcp-next 0/9] Refactor mptcp_join.sh Mat Martineau
2022-02-11 17:34   ` Matthieu Baerts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220209212520.2989291-6-matthieu.baerts@tessares.net \
    --to=matthieu.baerts@tessares.net \
    --cc=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.