Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp866384lqc; Fri, 8 Mar 2024 14:14:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0szaLOvPdXhmDbhfXTZUcWGZepZJty0iDuoidaUCL9XqOADfdy73VOKSbPYOwPEM0ffMieSIi7j5H3yrFeBFfSl5E6w9y++lpDOtesw== X-Google-Smtp-Source: AGHT+IF48bFLWjsq67E0Ke72s0Nf+G/Sagd+D/HG9RS7Z52x/QA/njdX2VQz28RHtWmPFWsybFPt X-Received: by 2002:a17:906:578c:b0:a44:2ee1:eab3 with SMTP id k12-20020a170906578c00b00a442ee1eab3mr8632ejq.31.1709936099371; Fri, 08 Mar 2024 14:14:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709936099; cv=pass; d=google.com; s=arc-20160816; b=vmjQBXDUGfV1D4Gnet/e9jL/EaGnGhvR2wEkbSLF90qwuUiyLIAmxUjq2TWVHU0zQ3 40fCCoUHqJ5fHxvRec0FQUXemPPDERFt5FdNdMOmAQucwjw6mcejrJ/LZh7OACmGn1VG xNJO/9obvtAnbEC6MRAjuN6X1s9OjxqUBfM/nVko0mvbpVHsjQikmnUS9ZvvP2dDhLYW 6nuDhT73wt8dupb7cMrDwn2DMSfcNGQrpEtajAYTdjMdYQSlHCsIbel09MOkNnqKaW5r i5BumdcLfUx64+tzuoepl5NXn0S+LIzXfsc+Nr27W+T7rqmPe2hvRLVCrFFMqodhR/R4 DW8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=LakCxF/LdKX0sGlKoL3rLKNIOylQ35j7IGO9LrZPEeE=; fh=2dk07KolaZJL0JeqFGRxwJVwvAyA78FaKBXVM6bwbyU=; b=Mq6JSST2NAzx3EUnzl5bnP1Lkol6dEQUkkKUUJNF+9YYhqFX5yT/PnC0MDpUVb2NAz d1xpzGsOQgdMRn7nDgn0KB51kaoCejyfRb54sp09qkkfnlB8H8KPYHc7OkASERE6kqok j1tOxpsd9kzKaF4Dx1/8lImx6YbHCZw98RTq++1pzlYPyqa0/fwzKT5DDfHat9r5Nf6g BfcQD/MQv2APBct6LsMqduDywztyNnliCUMY+uYVo9iziBl4H+aXWo4PwjbY3IKKea2B ql7Itbl62BrG7uJPo3Jjq320Z+BzMzKn110puli+mnLnu7EPVaInlKOF6rqaosnuJZof USkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hpCtWGOE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-97639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id hr34-20020a1709073fa200b00a45beaf0d6esi180833ejc.366.2024.03.08.14.14.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 14:14:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hpCtWGOE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-97639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id ED0381F227D7 for ; Fri, 8 Mar 2024 22:14:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1A3F657A7; Fri, 8 Mar 2024 22:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hpCtWGOE" 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 E1CE7651A4; Fri, 8 Mar 2024 22:11:08 +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=1709935869; cv=none; b=c1c5Yqbm5uhtF34Ux4TvEN4fK8WdBOLf2TewE16lhn9B+JObgIfHqvyJReoQbnrmiLtlvdG6O0mldO6tUE0zRIdyATYWiQUiOuHimBnt321HKzCZcJo2oDXX0dsxitIHDAESdji1BwCW1Ya0soAAfkyH/MuR954lyCh1VA0a2h8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935869; c=relaxed/simple; bh=gI7gAxG7/7enPUG2m1/wk/2tQuTd6pa5cKzSuAGaaZE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gD5rEng5s0ttTNumtbKerKZl1lvK7eIuikRxLiTPqCqrrlmclu92Q1i3rNq1mpFGgCSmeDAk9FZgnlgFNUdIcVOrgfHsitNU7KKHwlPniAuWD7HHR1tamkP3o67sRFov2q3ix7IvsTRbDYObVwbNXWS/n/Sk6wqeowaJ9q2fID4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hpCtWGOE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96D7AC43394; Fri, 8 Mar 2024 22:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935868; bh=gI7gAxG7/7enPUG2m1/wk/2tQuTd6pa5cKzSuAGaaZE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hpCtWGOEX+iXWfErxAPPeQO3r8fzsK71uNugJ99jFLMCiy9IT72HCfTpPxq8JdHkC K+O81QHv8Vkz9BihnpFTKU9/33gB9EFNqWdsil1kYXWJvlapHuhD8qe/sY3KEj3xRA wdgauIBQ2cKpb+aERvIcUavVUzWECmaClCxgL2PEwPSad2ZrE0Qo7qMAjvDWz0AI7o nM5EdBRaw+Rln+MS8vyGLPJnaTwmIxBfjVZi8emEs7VSvyvCpVWHrnBJgE80R3/iCa kNnFeQsQbYOYOR3HOAWRo7fooXks+Gq6yWKK2pKhp5kmZOWLpVT9Be+NMU58wpjlWK tAK3c7yXK44GA== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:20 +0100 Subject: [PATCH net-next 13/15] selftests: mptcp: add mptcp_lib_verify_listener_events Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-13-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4275; i=matttbe@kernel.org; h=from:subject:message-id; bh=pARL3ytgyARb+QzDKu12q0Cw4Y2pvqigZlKc4xpTC+8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJ7kzUaDOHz8NVkhyIbvdx3NmFlSXMhO7GF uZKiTuBxNmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg cwSPEACZoaAg5fwmfNaFNwjUo6mzoRqE7sI6Hr2fml9t52zDSp3VsP9I3TduJwROs05U8j/DDZn El4a80D+yyaMEsv9/PZpvCH9H8Bn7bhcopWvMSVfmmHnQY5oOFSy3x8d+4eC5mhW1S0IPTKpYM1 ciApsfwz7VKORpm/ubOdmVKhBQg7Bm+LFqsLhootFwZYneRO+Goe6jVu48gYlVSnucrkvsA8Rvg m/LFprUpnfdrhkNU/tj3JaXxfxC+E4wx5XVHe66u0+eYcVezX3g7OAwOHkTYC1AYSXBcckMePla XSsdewrfD1rp6ijv7xcoBxqQl+YAoDSqa9AKpaHZDpOIAY0eC2XVH2rNHFmYrhbXj3p1GxLidKt ZVaR40QrZRO+qOvsP3BuoBKgXZR4LNdAU7Gc6XJaiG1WrADG4gBW1upm6ZKtTnBJkfObIN9fdhe NOemXnJvRKulu1wOzmcWbXO4tn2t1/NFEdiTFwx9yOQt/VL3QobVwI4x5rrDkUldr7xsCZpEhJO R8B2Un5QA/hh6wuXHzLWjCnYRRSoHYWLg8Pql+YhbJs53rBRHB5d0TpTfNk6ixe7vFGPbC9Ac2g lWvW1p1+1DJlJycMzpsprLFaznc+gKuS+mcWeXYyig0DB7JgCOVrYzqdxd6eJ4nDed2Y7sQdsJr xW3d9tXzoqDNr/Q== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang To avoid duplicated code in different MPTCP selftests, we can add and use helpers defined in mptcp_lib.sh. The helper verify_listener_events() is defined both in mptcp_join.sh and userspace_pm.sh, export it into mptcp_lib.sh and rename it with mptcp_lib_ prefix. Use this new helper in both scripts. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 21 +----------------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 26 +++++++++++++++++++++++ tools/testing/selftests/net/mptcp/userspace_pm.sh | 21 +++--------------- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 041175ec1304..9b538a7071e7 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2794,15 +2794,9 @@ AF_INET6=10 verify_listener_events() { - local evt=$1 local e_type=$2 - local e_family=$3 local e_saddr=$4 local e_sport=$5 - local type - local family - local saddr - local sport local name if [ $e_type = $LISTENER_CREATED ]; then @@ -2820,23 +2814,10 @@ verify_listener_events() return fi - type=$(mptcp_lib_evts_get_info type "$evt" "$e_type") - family=$(mptcp_lib_evts_get_info family "$evt" "$e_type") - sport=$(mptcp_lib_evts_get_info sport "$evt" "$e_type") - if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") - else - saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") - fi - - if [ $type ] && [ $type = $e_type ] && - [ $family ] && [ $family = $e_family ] && - [ $saddr ] && [ $saddr = $e_saddr ] && - [ $sport ] && [ $sport = $e_sport ]; then + if mptcp_lib_verify_listener_events "${@}"; then print_ok return 0 fi - print_fail "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" fail_test } diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 44491f18ed17..a977a722fb3d 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -468,3 +468,29 @@ mptcp_lib_check_expected() { return "${rc}" } + +# shellcheck disable=SC2034 # Some variables are used below but indirectly +mptcp_lib_verify_listener_events() { + local evt=${1} + local e_type=${2} + local e_family=${3} + local e_saddr=${4} + local e_sport=${5} + local type + local family + local saddr + local sport + local rc=0 + + type=$(mptcp_lib_evts_get_info type "${evt}" "${e_type}") + family=$(mptcp_lib_evts_get_info family "${evt}" "${e_type}") + if [ "${family}" ] && [ "${family}" = "${AF_INET6}" ]; then + saddr=$(mptcp_lib_evts_get_info saddr6 "${evt}" "${e_type}") + else + saddr=$(mptcp_lib_evts_get_info saddr4 "${evt}" "${e_type}") + fi + sport=$(mptcp_lib_evts_get_info sport "${evt}" "${e_type}") + + mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}" + return "${rc}" +} diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index e9aea44edee5..1e0b39e5525c 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -835,26 +835,11 @@ test_prio() verify_listener_events() { - local evt=$1 - local e_type=$2 - local e_family=$3 - local e_saddr=$4 - local e_sport=$5 - local type - local family - local saddr - local sport - - type=$(mptcp_lib_evts_get_info type $evt $e_type) - family=$(mptcp_lib_evts_get_info family $evt $e_type) - sport=$(mptcp_lib_evts_get_info sport $evt $e_type) - if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(mptcp_lib_evts_get_info saddr6 $evt $e_type) + if mptcp_lib_verify_listener_events "${@}"; then + test_pass else - saddr=$(mptcp_lib_evts_get_info saddr4 $evt $e_type) + test_fail fi - - check_expected "type" "family" "saddr" "sport" } test_listener() -- 2.43.0