From nobody Mon Feb 9 21:40:26 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6180A50 for ; Wed, 6 Mar 2024 01:41:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709689275; cv=none; b=ilo119xPYIESbbrHCVyRdQWm94B1mE3fiPNURbzmmNB2eAraM0wLnyiagudeCqo23jFMofMdyDdUrEJ9596ssa+gOdAabeTbDH76WIRMxDBcvM12MSE3Rg11G5VPmmQPbOIzi+tx+27CsUFxhCdPhv0zGKkaqLhRcP3CWklYKSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709689275; c=relaxed/simple; bh=U7Qd4CEZyemiDU0r36GRs/1UAHIoXdcQ9LKEGKjgY5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LgMApht6HionjgQqYKuHVVLSwwHj/umMlNmQsp+cTXW6cH/DVD8iWbdgGcbs6fle/FsTpq1VBdwLkUm4kQ864+pZn5PydfeFsK1nvBITmseYDC8zsLrSFTD/AbboFoXN7vO9hBE4zaPpdCctDKCHDeAj8+uXZ9GXYcW9nFG6G3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kQBIhHF1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kQBIhHF1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1949C433F1; Wed, 6 Mar 2024 01:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709689275; bh=U7Qd4CEZyemiDU0r36GRs/1UAHIoXdcQ9LKEGKjgY5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQBIhHF1hgOfjE81Eu33ynD6P49bRMY/UU6M9+/uEbkBOFXoDNOTg8OYFWS+voeIt PPreU3U4Gr/Yl6hy6cCiMYOiivEzFUiRzJowvvhUQ59xKz8ewE1iU6sIZjku9BtDkA eWilHsFgB+lPKPkW0JkgceDEwIXuRRDOWMYfZIEqhTHW167233/qiCNKfMtnxecirY QQ83OjlAMDHPWwKDU7spYm4CphpoOxCWPKEa3nBeXqONDHfulWX7EzI8rsxVt+pfaJ N54Kww/+4uIg5K4A39mCU5IqZllHrHPy6kFX6c9GDoyFvd0zNYXi3KMm3qyRave1/o vDtxGhfZuB2Fw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v13 6/9] selftests: mptcp: add print_title in mptcp_lib Date: Wed, 6 Mar 2024 09:40:56 +0800 Message-Id: <957cf4d3a63fd645c610b67f41533a21fc5b8756.1709688778.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch adds a new variable MPTCP_LIB_TEST_FORMAT as the test title printing format. Also add a helper mptcp_lib_print_title() to use this format to print the test title with test counters. They are used in mptcp_join.sh first. Each MPTCP selftest is having subtests, and it helps to give them a number to quickly identify them. This can be managed by mptcp_lib.sh, reusing what has been done here. The following commit will use these new helpers in the other tests. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 13 ++++--------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 10 +++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 4ef0d5ae9dae..2f34e2b9a1c4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -48,6 +48,7 @@ declare -A all_tests declare -a only_tests_ids declare -a only_tests_names declare -A failed_tests +MPTCP_LIB_TEST_FORMAT=3D"%03u %s\n" TEST_NAME=3D"" nr_blank=3D6 =20 @@ -169,11 +170,6 @@ cleanup() cleanup_partial } =20 -print_title() -{ - printf "%03u %s\n" "${MPTCP_LIB_TEST_COUNTER}" "${TEST_NAME}" -} - print_check() { printf "%-${nr_blank}s%-36s" " " "${*}" @@ -232,7 +228,7 @@ skip_test() =20 local i for i in "${only_tests_ids[@]}"; do - if [ "${MPTCP_LIB_TEST_COUNTER}" -eq "${i}" ]; then + if [ "$((MPTCP_LIB_TEST_COUNTER+1))" -eq "${i}" ]; then return 1 fi done @@ -267,14 +263,13 @@ reset() =20 TEST_NAME=3D"${1}" =20 - MPTCP_LIB_TEST_COUNTER=3D$((MPTCP_LIB_TEST_COUNTER+1)) - if skip_test; then + MPTCP_LIB_TEST_COUNTER=3D$((MPTCP_LIB_TEST_COUNTER+1)) last_test_ignored=3D1 return 1 fi =20 - print_title + mptcp_lib_print_title "${TEST_NAME}" =20 if [ "${init}" !=3D "1" ]; then init diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 63abf4431993..eb740a2f7898 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -10,8 +10,8 @@ readonly KSFT_TEST=3D"${MPTCP_LIB_KSFT_TEST:-$(basename "= ${0}" .sh)}" =20 MPTCP_LIB_SUBTESTS=3D() MPTCP_LIB_SUBTESTS_DUPLICATED=3D0 -# shellcheck disable=3DSC2034 # unused at this moment MPTCP_LIB_TEST_COUNTER=3D0 +MPTCP_LIB_TEST_FORMAT=3D"%02u %-50s" =20 # only if supported (or forced) and not disabled, see no-color.org if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" =3D "1" ]; } && @@ -412,3 +412,11 @@ mptcp_lib_events() { ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 & pid=3D$! } + +mptcp_lib_print_title() { + : "${MPTCP_LIB_TEST_COUNTER:?}" + : "${MPTCP_LIB_TEST_FORMAT:?}" + + # shellcheck disable=3DSC2059 # the format is in a variable + printf "${MPTCP_LIB_TEST_FORMAT}" "$((++MPTCP_LIB_TEST_COUNTER))" "${*}" +} --=20 2.40.1