From patchwork Thu Nov 14 14:09:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 843325 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2049.outbound.protection.outlook.com [40.107.243.49]) (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 963903BB48; Thu, 14 Nov 2024 14:12:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593557; cv=fail; b=T9sB39jj6SoehsPDB7X3lwaAITQ0pR7GYpW3Sre8w/xe0tbOKyjMM2GgHrHnYK0gTfyARKWoYdWtcbRHNm6HHDxBpjRA1DgRdBB1xOPVWKJrLSnnxYtEKKz8kpOr9MxmqTOCjoVF6hdlrBnzv6KMdv4KE+KKJWte8DmOPUUskbc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593557; c=relaxed/simple; bh=3ZfWdtTvPyMpZTakc0Gwfzt/1QyfrPAAl7qK0gavtHs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T3HGDzm+7uvZ7B3YlmiM3Uj0I7Fb3LS/bexHcq28qo/jPkQedhKUenk0JGprCYlhQpC0/Ze40hZ8ElKpikW6dPi0q/wLBB0Lsk8dHqqsyDQV+HW+zcEv4sBO35BptpKdHsa2XP8fZFI2cRHkjtHYptgWo6A+pBumvnqx9mbY3iU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=ilCLM2IG; arc=fail smtp.client-ip=40.107.243.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="ilCLM2IG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DnayUW3KaKLvjGvFJb1/H7p8pqxwF0asZUFxMQzd5ohieE2jCvFyf5s/y97OL5ek0LoACwkJSTghxZZLwC3TYYpHbNQdYXrJhtCd5lhJqI5p7GPGXM51w0t3J8ZTNvLyrv6uMinMD1d9EHXc+BU6PjDTk/eLdclGlYfd3geq7YDXZWgb/erorjG3t58iOIOfhQrSPWhxTrgkF3BjketnbqgUTZJyegMswMdI+X3bi0faOABH3bWRnj817waLL+GQilXDi9mtWAvBrOZM8CAL48+nKckbcAhHLOrKvzZaMzV+sm3QZfqGA8zYNQBB2Qtc5xS+vcgpuL07rX2MgZCdOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YD6zqn2kMbHyPquhEmL/7TNRjNgDHXSmBbaIweEFVMQ=; b=WjqxBuav7iolxupmAl1/CMiu0eMtXnb8yiqhBrcp2rfBrV/ESrOEcYKE72JLKszwYV7p69bPVOVFNVcu6PzKSfwI01ZfjkzGF/PIQnpZAJ0h3BQtkrJR3AyagvHi6pxzdGJLC7t/gSpTSigN5bg3lVm5cQDapyMvQTPgRbNlugmSY8VzqGWKL3tRVDMaQZXqPqnbCQxr+SVcugCuYIsp/afYH/+wW9dAqRvN5XaJ1BLiAPUPdJ8U3wLoPtZgr+VOGd4Otx173nX0uQGqNT1D3VT/dTjxQPvV51FUEIAcw42kBn3TCUEY0K1S7tMgP9ndkeqP0vTuMbiSpaPV5FQUeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YD6zqn2kMbHyPquhEmL/7TNRjNgDHXSmBbaIweEFVMQ=; b=ilCLM2IG2Ex8MtkIclOiWRnPiggaEY47AuhVzh8T/XMBHAkjEazlPK4Og/l2+j7dN5mbOxEwGSiiv1I2sxqG1fDGtZX4DmVWYqR/pRop0/aFE59hYExoy872nqvl0PSwH0XRPuu2YII+yoSQTPEYMFibqkRGZpmm2oG66INrAcUbgwH1XvowXVzt3HBHRt3+ZsHnvTpyJFid5jmKd19uFo+4WkwgaRATbA6JPP3Rfo3a5TNPGGxCaM5ly1Bd7JptUyq/WHgD4HZKgQlW3vWA9tAYVamMOrS44nDWOxQkgpLETb7i+cw/m5v4PdfDSuQGduatuMurMg4t/1CSQrU+fQ== Received: from CH0PR03CA0419.namprd03.prod.outlook.com (2603:10b6:610:11b::8) by DS7PR12MB6360.namprd12.prod.outlook.com (2603:10b6:8:93::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Thu, 14 Nov 2024 14:12:28 +0000 Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::18) by CH0PR03CA0419.outlook.office365.com (2603:10b6:610:11b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17 via Frontend Transport; Thu, 14 Nov 2024 14:12:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Thu, 14 Nov 2024 14:12:28 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:15 -0800 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:07 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v4 3/7] selftests: net: lib: Move logging from forwarding/lib.sh here Date: Thu, 14 Nov 2024 15:09:55 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D4:EE_|DS7PR12MB6360:EE_ X-MS-Office365-Filtering-Correlation-Id: 922090c6-875f-4347-97ea-08dd04b65f27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|7416014|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: MX06NW8sL/QbtlzoyWXS8TYvYQ1cDGsJYqydXqB3juvZEV119Rd3iEqd0gC1skc2vsyIVta/fJGFgKhiSQupkm1cc5JYK04by50J4mQkunSVEW3NvtLqi8CFYUHSL3V5sAt0HbwMWPLUgNxbD+NLmByuqE6QVpNhWHI3o2sdn7Oe4e315zp1GmT4GvNfowHd96oA47oE4dZuglkv/856CSbjPR8RIOsHBPzOKmb0UtMdKml0SoIGEX9QpQ4/Rqao2kfdeEYYGkD1H8fRAe0nsuE5QfI/Pm10kUxApkq+idsAEkwO2jPy33lVHgZ5l91ed0ER2cVFf4fVYeKbQBOu+bIrAttpejC6e/oxeSwvLW01RvJ7mUB2zU5dyrpbUeiwWYIqcsaNtAZNs+fwHDnU5icZSIvQe6d7BnTxVCKpKSWgXSajASlytcnOTtie45Dc+nH5RcXgF3XCv40ZpIF/fUWLbTwCpdsxEtZbC/IaPFfnYIfsTbNnTx6e5IolQOIoIW+vV7JV7xONkG+pV6cTkOd8ezNBvyBnMAq5uUdqn7oF7byagAXCFsS4V2TJhMYwwRdw7Cyo7uCbI0drStZbRzQuwv4E/8lSK/jhYtcLBQ5HpRnJG1EEz0X1FzAiyfEr4HA66kK/KyPCcJaAclHbnt/RCXwGGImcSUm+dV9RXxCte0H5NvW7pRIV5/NIW/33nw7hC+vTUDu3N9vvD5hg4y/8WpXDaaDiYwaEzVxfp9hQnZaofBxEuj1kVxKIFU1H7CYNlZNDicirgkE3G8bPotJZnuxwglTmjmF3HKGASaZtZkaiuiKNv2IQuf1vWMkIj2ehXtIc9UQ8MKrRXhzCEO7uXze71B/sL5sfZ9gnjfCIkcL1y3KZKEdZlfGEZ1HVoW0UOzjqT4BwFaPc0Q5Ke9JoSC1ggbFntZaBH7KlV5vtXf3TdcA7z4HnRBRZnxejuMR7dTQOoy0xN7N5Z+a6gL3DFiYdLKytqUufxl1UIjfYsUKwV2fhGm86koj4meLNkuH2/PrILmLqFunutphKdi32Mh/zhejiPumD4zEHZXqiRCTxr6Thsw9vLkkQsN2Rsdab8eNycP6vin/h0ldNuzHC1OIvgM8WdF3kcSLD9n2h7OkQ7R5fMCbWI46unnj/zjtPTQ1/Tqgc00YwymPL4LVr28TlHCxbfD9WPAPNKBltJKdarFE9SdcUhxy0zX/jGgwyrl2Dr02Uh4CfPux23b8SgB9awTDRS0A+8PR+yYInbShfF44/Dvp/Bby5S7vlI3fJBcEQzik8f47AvMlWklwVulL75DPZSxuThwl/UI3r65eRnPqGN2IGOcmbPPm4B6pg4rijDoZZ68b0Rt8xPvDl2Z5Pz6/UEs+YVNavypfd2iOtALUShf/IoX+c3XG6cKNn2JFTx/yEenpQBvAnbw== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(36860700013)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2024 14:12:28.2061 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 922090c6-875f-4347-97ea-08dd04b65f27 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6360 Many net selftests invent their own logging helpers. These really should be in a library sourced by these tests. Currently forwarding/lib.sh has a suite of perfectly fine logging helpers, but sourcing a forwarding/ library from a higher-level directory smells of layering violation. In this patch, move the logging helpers to net/lib.sh so that every net test can use them. Together with the logging helpers, it's also necessary to move pause_on_fail(), and EXIT_STATUS and RET. Existing lib.sh users might be using these same names for their functions or variables. However lib.sh is always sourced near the top of the file (checked), and whatever new definitions will simply override the ones provided by lib.sh. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen Acked-by: Shuah Khan --- Notes: CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko tools/testing/selftests/net/forwarding/lib.sh | 113 ----------------- tools/testing/selftests/net/lib.sh | 115 ++++++++++++++++++ 2 files changed, 115 insertions(+), 113 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 89c25f72b10c..41dd14c42c48 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -48,7 +48,6 @@ declare -A NETIFS=( : "${WAIT_TIME:=5}" # Whether to pause on, respectively, after a failure and before cleanup. -: "${PAUSE_ON_FAIL:=no}" : "${PAUSE_ON_CLEANUP:=no}" # Whether to create virtual interfaces, and what netdevice type they should be. @@ -446,22 +445,6 @@ done ############################################################################## # Helpers -# Exit status to return at the end. Set in case one of the tests fails. -EXIT_STATUS=0 -# Per-test return value. Clear at the beginning of each test. -RET=0 - -ret_set_ksft_status() -{ - local ksft_status=$1; shift - local msg=$1; shift - - RET=$(ksft_status_merge $RET $ksft_status) - if (( $? )); then - retmsg=$msg - fi -} - # Whether FAILs should be interpreted as XFAILs. Internal. FAIL_TO_XFAIL= @@ -535,102 +518,6 @@ xfail_on_veth() fi } -log_test_result() -{ - local test_name=$1; shift - local opt_str=$1; shift - local result=$1; shift - local retmsg=$1; shift - - printf "TEST: %-60s [%s]\n" "$test_name $opt_str" "$result" - if [[ $retmsg ]]; then - printf "\t%s\n" "$retmsg" - fi -} - -pause_on_fail() -{ - if [[ $PAUSE_ON_FAIL == yes ]]; then - echo "Hit enter to continue, 'q' to quit" - read a - [[ $a == q ]] && exit 1 - fi -} - -handle_test_result_pass() -{ - local test_name=$1; shift - local opt_str=$1; shift - - log_test_result "$test_name" "$opt_str" " OK " -} - -handle_test_result_fail() -{ - local test_name=$1; shift - local opt_str=$1; shift - - log_test_result "$test_name" "$opt_str" FAIL "$retmsg" - pause_on_fail -} - -handle_test_result_xfail() -{ - local test_name=$1; shift - local opt_str=$1; shift - - log_test_result "$test_name" "$opt_str" XFAIL "$retmsg" - pause_on_fail -} - -handle_test_result_skip() -{ - local test_name=$1; shift - local opt_str=$1; shift - - log_test_result "$test_name" "$opt_str" SKIP "$retmsg" -} - -log_test() -{ - local test_name=$1 - local opt_str=$2 - - if [[ $# -eq 2 ]]; then - opt_str="($opt_str)" - fi - - if ((RET == ksft_pass)); then - handle_test_result_pass "$test_name" "$opt_str" - elif ((RET == ksft_xfail)); then - handle_test_result_xfail "$test_name" "$opt_str" - elif ((RET == ksft_skip)); then - handle_test_result_skip "$test_name" "$opt_str" - else - handle_test_result_fail "$test_name" "$opt_str" - fi - - EXIT_STATUS=$(ksft_exit_status_merge $EXIT_STATUS $RET) - return $RET -} - -log_test_skip() -{ - RET=$ksft_skip retmsg= log_test "$@" -} - -log_test_xfail() -{ - RET=$ksft_xfail retmsg= log_test "$@" -} - -log_info() -{ - local msg=$1 - - echo "INFO: $msg" -} - not() { "$@" diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index c8991cc6bf28..691318b1ec55 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -9,6 +9,9 @@ source "$net_dir/lib/sh/defer.sh" : "${WAIT_TIMEOUT:=20}" +# Whether to pause on after a failure. +: "${PAUSE_ON_FAIL:=no}" + BUSYWAIT_TIMEOUT=$((WAIT_TIMEOUT * 1000)) # ms # Kselftest framework constants. @@ -20,6 +23,11 @@ ksft_skip=4 # namespace list created by setup_ns NS_LIST=() +# Exit status to return at the end. Set in case one of the tests fails. +EXIT_STATUS=0 +# Per-test return value. Clear at the beginning of each test. +RET=0 + ############################################################################## # Helpers @@ -236,3 +244,110 @@ tc_rule_handle_stats_get() | jq ".[] | select(.options.handle == $handle) | \ .options.actions[0].stats$selector" } + +ret_set_ksft_status() +{ + local ksft_status=$1; shift + local msg=$1; shift + + RET=$(ksft_status_merge $RET $ksft_status) + if (( $? )); then + retmsg=$msg + fi +} + +log_test_result() +{ + local test_name=$1; shift + local opt_str=$1; shift + local result=$1; shift + local retmsg=$1; shift + + printf "TEST: %-60s [%s]\n" "$test_name $opt_str" "$result" + if [[ $retmsg ]]; then + printf "\t%s\n" "$retmsg" + fi +} + +pause_on_fail() +{ + if [[ $PAUSE_ON_FAIL == yes ]]; then + echo "Hit enter to continue, 'q' to quit" + read a + [[ $a == q ]] && exit 1 + fi +} + +handle_test_result_pass() +{ + local test_name=$1; shift + local opt_str=$1; shift + + log_test_result "$test_name" "$opt_str" " OK " +} + +handle_test_result_fail() +{ + local test_name=$1; shift + local opt_str=$1; shift + + log_test_result "$test_name" "$opt_str" FAIL "$retmsg" + pause_on_fail +} + +handle_test_result_xfail() +{ + local test_name=$1; shift + local opt_str=$1; shift + + log_test_result "$test_name" "$opt_str" XFAIL "$retmsg" + pause_on_fail +} + +handle_test_result_skip() +{ + local test_name=$1; shift + local opt_str=$1; shift + + log_test_result "$test_name" "$opt_str" SKIP "$retmsg" +} + +log_test() +{ + local test_name=$1 + local opt_str=$2 + + if [[ $# -eq 2 ]]; then + opt_str="($opt_str)" + fi + + if ((RET == ksft_pass)); then + handle_test_result_pass "$test_name" "$opt_str" + elif ((RET == ksft_xfail)); then + handle_test_result_xfail "$test_name" "$opt_str" + elif ((RET == ksft_skip)); then + handle_test_result_skip "$test_name" "$opt_str" + else + handle_test_result_fail "$test_name" "$opt_str" + fi + + EXIT_STATUS=$(ksft_exit_status_merge $EXIT_STATUS $RET) + return $RET +} + +log_test_skip() +{ + RET=$ksft_skip retmsg= log_test "$@" +} + +log_test_xfail() +{ + RET=$ksft_xfail retmsg= log_test "$@" +} + +log_info() +{ + local msg=$1 + + echo "INFO: $msg" +} From patchwork Thu Nov 14 14:09:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 843668 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2074.outbound.protection.outlook.com [40.107.236.74]) (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 12C133BB48; Thu, 14 Nov 2024 14:12:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593566; cv=fail; b=k6XeKDI0mMW02c9uqPxOutVmQ/sqB+pQ+A2jMupsV3dRpHGXOzGtjo90/7L+qoZVThc/XzWBcR3dmO3EAeU2oG8Eu3qTqcLRS0LghNA17nmBhrVujM6fK4/GCpOFvXNt9uWI9t/P+e7yPvJXEnBJC6YCtlpivWBJDUGlL2bXkV4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593566; c=relaxed/simple; bh=u034UZiNhiJu/r2dn8swqac1RxTUeAtyHs8A0b2YlLo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DH8aozBmJMsvBLP9MTBzL7cGMX320Z7Biw77O3GPApfKxDMjqaOxcMvsK5qlvC8RFOVOrQV0sUECUBFM0Dhbko9vdOGg5M8/nP44u29PZyyHg9QjnI4cOU362VJUe2XY0X3LTzTG1oEsqBclqUi20Kbmsrf+ZcPlb8dzG3gMlNk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=RcnZnmYj; arc=fail smtp.client-ip=40.107.236.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="RcnZnmYj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xi2bqU8rL1eadMrhjAGjWnnKQ5hzHz6vRzIrlPiZ0sKLicj3xXl8xw1+1b8soaFyUlWKixpFTFNs1DXxpVkp5YixzUl3YN1ky+9f9RiXV6vTcuRCEev2lQvafX8nLJIZmEJ0sLfrc1Y6wEWdFwBNcqUY9CP86L6A/rZgtzuFy6mykdR+AMcIh89zx3tOkpbWcNSFCaIra7/1t/tZdzfaOnFWIHLaiAC93WIFZ2J/aCrh0DEpatueaBuzlkhog4/MP1TfbMLS1MH26VknBJ3q/m5Aa/VNVGpdwQBJsBklr430emvYgNVoByuUU+fXzprCpdSHo9Hp5mcUOrD8n+qSGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0knMJxu5lwi7AglwJNczxaI1E/3P2LBzh1dlVNdMhyQ=; b=rz+EKavLjcX+xeFgH8j0KEMXFKlbg390K/22uEihLibCe3LyhmPhoRReVjQ1v3QqM6i6J5sMdGSv4hNt33cOPVH8OlDPG5YW+0MtaJ5RRJN+7DTdure+axHtCV9m/wUNyhAYJPkYp0JGxOxlJL8H4iwD3iomEMnf44oyd8npxN9bTaqq2FaVc0zCADK9axLQsFjcmuNPWcIGavNILolK5hyybM1fyukag9kEdmVeSnwknBwEcJCHFDMbJ8mMhS0PsLyf4cygTMWg1oKfQlPo4a9NKNgcyLBEu5LLx5WyZv95PyCAoxAWIAbtkahOCIwEfHO8KpepYJvPxHJG13SuVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0knMJxu5lwi7AglwJNczxaI1E/3P2LBzh1dlVNdMhyQ=; b=RcnZnmYjb+SMgtDLXAURNtMLvU/903PDXJnsC+H9jTjWgUnzyyV7URDIE2/zna1+UH9v4tQnoKzCOxl3q/YfvBQqiqihpN0ZGJF1uIWT3W7vTi1OGFaUVw89HcEhq7px2zW273xcS1N9rDN04hp2JsXIw2RHS1Qj8NmhnuL+S4LRR+TaXQU6LtoZTxpEUPTECcKZD9OuHeYK/ApO/euueiLb/rlcnaEAcY78Ey9HtSx8LRzejmeEKc7TTOqOoIbqTNaJuRl2qllZMDPCp8c7C1qu06too8HrJnRRMH625kG1UlNKB9DoR6+GNfImV7AJkFQv08JhsM9rTQqix45Vqw== Received: from DM6PR01CA0023.prod.exchangelabs.com (2603:10b6:5:296::28) by IA1PR12MB6212.namprd12.prod.outlook.com (2603:10b6:208:3e4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Thu, 14 Nov 2024 14:12:41 +0000 Received: from DS3PEPF000099D7.namprd04.prod.outlook.com (2603:10b6:5:296:cafe::e4) by DM6PR01CA0023.outlook.office365.com (2603:10b6:5:296::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.16 via Frontend Transport; Thu, 14 Nov 2024 14:12:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF000099D7.mail.protection.outlook.com (10.167.17.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Thu, 14 Nov 2024 14:12:39 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:22 -0800 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:15 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v4 4/7] selftests: net: lib: Move tests_run from forwarding/lib.sh here Date: Thu, 14 Nov 2024 15:09:56 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D7:EE_|IA1PR12MB6212:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d7e8761-0a16-4227-cbe3-08dd04b66608 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: nShFgMVgGBwvD0lxY/nH3zHVN7hs0jXkwJios/Oer/Mrpk4gB+p5iGfEypbsahIUjASazWTluf/0aR+OG6oCQErLAvzBOP993ry93eP6NZDOS8sRQEWSXfauTTuVZNTOhce6vQXQAhb2Z41Q89p+7kK45Sc3N1/8w7fezHRGQmddH9m5MkPyAXSsZ4qeF1PcJpzNU9dDHW7xPDzcqcooBGSYNwu5pAqz5eoZR1pug3YexvBLvxEg0PZ+c+IyfyUX32CBnYsmZkRcpKp67evWcui/cxKvOoA/ps7nO3MQ4oFaeXol9Z7Yr5W6h7tE2aeI32cRlA29LCjoyfjyONjtA2L9fQYv9J/zWiA0AafWpdVQA+xZ7zQ8mNrHdyFjy6feTCfveoc/2ENzig1U65LskzvbgbdeMo68es/hRiMrqP8IlFwqOsewuJ3FukeYpDWkzPK4WoH1zmwIP5r9CtlGW3IrOYyt2dCZBRSsNou8UdxvaT+HhmTjhfv0q0o85hzAj0oK7SncR1ciPsUR1XxWatE/6Luo+FA+d73iiwm6uv2ex2YjcHay+leToHzUpHckA9qXEHAV6FjMfy66cfNFDYxa+wCOVU+b2qPns5AGkqDUkHN7/Sc76lIjY075XnMdpxbHD9AJovhvbjgAWoxiWZLRBYXuBf94Es9vhwowh5LL5UCITbZFLADQ96/knUyzxCZL78IH864+llMrjl43DQwicSws/FhvjUWaMkuLlRhfPPjAkxLSsUdxAsPSBDPYUDfkX4L2V7gjM1Scn2YVtvv9JD+7df4yWnjrEMiCextMdvoywuS47b2hYfKw3DbRuidIsF7x0wx0JBuyNnqSSrgGcegq1bob4X9FQFKiTwRlHca8g+RyN6ojaalzC3Mqcu74fdX8pd5MEK3b/8QINF+nX+AHRy3uIw7o79QkMQ5vudDgA6U6k3SVj1iSrkmvQScSW9pohF+J1prDnu7RVm98DxzVViEHZ5ektlJ9EWamruiF2TMplSMztWLt1mqV63YnUdb/9CtICk3fVG6ngj8NBVGSjVYxmn3YMNwRSqzbZN+/mzdmdE44ji8lmSAXk+zHENFyT+8wS22v1F4z5oZQEiD2uudt0FaMaG7PszuDDVNtUEoqVTmCiueoH4gq79GdtTle8yD2OCwo6aBlaoYbB4ulMJCWbz/z1Yz9Ra9B/KhN8omdHtd1av45wj/PjbdBT82kk9JqpBuhLXyi66KEtgajOF0W9p3JJc/PwJsFOdWnA3M2pMhm+61zU0W0RCtGKuUKyM2ypmRw0qsr0OaxG+4rFJKP6QVOCITQh8PURGhAp2tbsS5QPzGVAPQfNWi4+D5Spo3CnWdI6ZjDK8qP1SHzN15rhqGqSDRIVBjR496Iz0G1lOfrkJFgPZXCgjEZeDXXe84TjakgWZk8XQ== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2024 14:12:39.7327 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d7e8761-0a16-4227-cbe3-08dd04b66608 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6212 It would be good to use the same mechanism for scheduling and dispatching general net tests as the many forwarding tests already use. To that end, move the logging helpers to net/lib.sh so that every net test can use them. Existing lib.sh users might be using the name themselves. However lib.sh is always sourced near the top of the file (checked), and whatever new definition will simply override the one provided by lib.sh. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen Acked-by: Shuah Khan --- Notes: CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko tools/testing/selftests/net/forwarding/lib.sh | 10 ---------- tools/testing/selftests/net/lib.sh | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 41dd14c42c48..d28dbf27c1f0 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1285,16 +1285,6 @@ matchall_sink_create() action drop } -tests_run() -{ - local current_test - - for current_test in ${TESTS:-$ALL_TESTS}; do - in_defer_scope \ - $current_test - done -} - cleanup() { pre_cleanup diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 691318b1ec55..4f52b8e48a3a 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -351,3 +351,13 @@ log_info() echo "INFO: $msg" } + +tests_run() +{ + local current_test + + for current_test in ${TESTS:-$ALL_TESTS}; do + in_defer_scope \ + $current_test + done +} From patchwork Thu Nov 14 14:09:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 843324 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.87]) (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 D98EA4D8D0; Thu, 14 Nov 2024 14:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593578; cv=fail; b=UDy4RlnleqogAdNMP5+5isGSF2wGiFPYNaLM35Th9oFakuYcWuWN0mkF8yKtPmLSCI8Lyj8BV6hk5YUGa8mfK2jWCNVMIm8PsFd5u6L59WurFidjMV9kWAL1HWOFFgwy+bn2RcuFPiWQkjswqNr9X9HVySgabi+Yd81/aUrYQxs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593578; c=relaxed/simple; bh=W1Jbsrl3SASOFhpOFkg6RFsRhT9Nixy5sz1Lwc1l+ZA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qaiU+r2PcSjMC3YHvcrIoLSXIjlgyHR/pu7iD1Y9G15kstMKOh6+xwDPwkxDENToIKCh8ojn3G3cMJfoxzYtrO0mVjfSGAqkyhnhFkpDH5MKEblNNnKYhb2ZZPmMGwuDS2+RxYspD2sIFgelhZIfazghoLsdnl8alpWmwSRaTIg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=YpxQmSqp; arc=fail smtp.client-ip=40.107.244.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="YpxQmSqp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fo5WyYkkbr2sU920WwPt2PW1cdP00HhaGyuYuXTaVMy+FCjgDb58ZIP0VrLwoOQ4ZBr51zzD0EWDHp5elxUyZxiBu9/tVaNR4qDiZnaiR6Nvg1EUk1DUf0382KswoU0JZPngM4LcwZukzXJAZvGLgEMBoZ1the0OxvhNuecgg7vcffDcuOR/LxEWUyNJBGhtTNscS6tGyazlGIKL6iIwvoyExgpU0klmdIBbkX0IiOKwVup+7ruAB0kOiwErtpNd0qDDGQlpBiCrbqNsTlWAVMJmvoJ8Sn/xVm1ROTcAX3B51oIqX3jEtpVozT1ge5H4SH6RJLXc0S8kNKdt69wLYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0Ybb3cQn8Fb6xON+SG8hrDFabuFGISwWdDVgxn/JRk8=; b=h6BBCgyRVkDayrZFX3VU2r7U9FYSjk8Jq5kMshHpii13KMRSR2CpLDY1VCZzkABEAjjSSrGQbF6MHd/x3MoGKv1eIlMZTt3nf4jrm6J2ZDpX0mJKSV1980NUZSXWg9MZQ/gHKta+EuxMdbp6YLQkAT19m45hlqGBYZSx5QkNWP8IQ18cij2Cj5arFhhbwRs0367SYtFwhIgAcaNZCA/XRN5Y7PTTO44WXbJxCm1fcVQCkUszi3gKaPfdcUBt7SiR2pEuJa8hiuAU7QLSLSm2Jr5Ma6RkSo+13vI8fGDuYb/zEiyPvnaPneTUhxdlzQuxCmvvogGzgbeWoy0Sys/1ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0Ybb3cQn8Fb6xON+SG8hrDFabuFGISwWdDVgxn/JRk8=; b=YpxQmSqp1YjeamBE0phAing11hmcD+WynBDvJXfHjufRWkOutbgHdfn/FV7VoY1Q2WTQyROuI9Wf6O8GtPbL1Idssf8xAKVSfanVswwGTNyqsmu0r1ifvdso3RehByjVQDgWC/6VMP5Fl3/DHNfTxWAinz4qSukitGwEMOt7ZyY6cBDx4LJwiRtcK2PyPgTXkTQjh+lsqPoM2Q/g/kZkcHFcZWy891BQ6+hPAWVaRSbVi++JkrdEGgNl0A0SzFYM1cfuCiSAjVmR4dkurQL/toAizyGR3sHvSBVuD1Bsif+DEqqwUbau9hu2PuphK0l/nuUHjdETQlKhKBv4oxScOg== Received: from DS7PR03CA0208.namprd03.prod.outlook.com (2603:10b6:5:3b6::33) by DS7PR12MB5717.namprd12.prod.outlook.com (2603:10b6:8:70::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18; Thu, 14 Nov 2024 14:12:46 +0000 Received: from DS3PEPF000099DA.namprd04.prod.outlook.com (2603:10b6:5:3b6:cafe::2b) by DS7PR03CA0208.outlook.office365.com (2603:10b6:5:3b6::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17 via Frontend Transport; Thu, 14 Nov 2024 14:12:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF000099DA.mail.protection.outlook.com (10.167.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Thu, 14 Nov 2024 14:12:46 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:30 -0800 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:22 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v4 5/7] selftests: net: lib: Move checks from forwarding/lib.sh here Date: Thu, 14 Nov 2024 15:09:57 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DA:EE_|DS7PR12MB5717:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f78a25a-03fe-4574-32bc-08dd04b669ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: K4Qchhjo2iBHDnwjHPHwvyLygw/RfmQ4C/sqqqO1qanV8cgXzz71KgCFgcgJCnD37Ul9UvmztCtqLesDTeqJ1210ho9INBGZmqEjOSBTq72MqLLR2dNAwbM5fobun87WxFVgJebzqFovTY4zBeu/MX1GMO7vd0UTFFUBwNX5hkl+irbZFwXx+1KroHNAfuj7CMZlD7PVMDMubrP/k7ROPsHMoNEn8CoxCMVFHkzwNSYFWMrTr56XjxCY4/wtn/6LTziQwYV75oLOkLjQHXx/euft7P3ynziKmxNxezNGA0Hzmj8rD+na9nEBvnQAtGmdq4+dqAWDs3UFAUUAy3kNYp6/MPNX6As/He2XXiPx6oP9GAesJZtUt6cEEVfaOpvTMHlH+Vm5HF+x3od6YGqOiq/l8DfiFoS+eRIrTAOjxjreiPKHiQZJuF3aYnMRt0ILWAHGS97bVgvflS66nw1NLtfly7KU5UBdTJIrCL1acu9prkK6hnm20/aCViWh7r5sbjhMtFqCvtJ9DqLqKJf/d/JTD4mHMW24Bha1VW3vKRXPNeJZoYlnj8V04xccH37fZhFkmqBxAIsfFMfZwHSuqviA+2ehJQBiq7omFKStqlORaCphd30oekvQ96OkG/pvWOQycFqNAInYtYOmQaYOrTkB8z2SXML42A4OTRHQRkITAx1NOvn1fQrN51r4BnMdbeWYUUpSdj8J4wuPiHVjdDjGDfuUQ+rO+aZiauZNU8s1oM+ooPx4AtPxxLNPENv+b0Q/weJmCb14E9SdgzBzesK6pwhhidbxTH/Rl9JOD3qQkky7Kre/2JxPFy+Rhhn/KwY4EvGxFRCUgktXhTtPICs/iKoM0tDkRqSGo6hPEITbXbDySJT/BXJcXCfPqMHjx2ep5mFlC8WJ0hRtBBIMQE4jD6iwFL/CohFY5E4NLOGyGihhqu0OJXLgotU9S3xieJg4/0kQGfsb2S8iNi2yXCi2wN9LprbFeOcWYtSXV4X4pe6sTqdzq6UF+FeBsjWkVr7FS5i26NGdYwqljWLcPreGpwXc2aVoOOOuim0fNSuBkWo9CCMrMJXE2pDRvigYb76QKdSWTFeGlqHTZo+i2VKVoOaAAOhAZvgnSP8Ug1/ZnfS2N5pEfHyMX07Q+RmFRXtQlUpwl/n/DIkq0r/yOMBwrXRC/ZpZNljCEGw3cwnVFTsYoNfAyariPxodbrmgfulIjIEuFqe+gJpZJwmLpN0QmLKRoSuWdf8bhc2zz/v3EaGe/Zu9RZTyPTkdHqzeT7dBjXUEacLv9hVPhwzWCpuZkXY9ObzvjWOZqqzIJOcJhqgZJ+I0V+/0ZWjByGccqtdnJtTd/718GiYuG1fE2/zZB+7WpGCqMKkTiYUMykLy5WyrgBm3P82+r3xG+9/2qIUfh8S/VM81aA1Lx+oyuQ== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2024 14:12:46.2587 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f78a25a-03fe-4574-32bc-08dd04b669ea X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5717 For logging to be useful, something has to set RET and retmsg by calling ret_set_ksft_status(). There is a suite of functions to that end in forwarding/lib: check_err, check_fail et.al. Move them to net/lib.sh so that every net test can use them. Existing lib.sh users might be using these same names for their functions. However lib.sh is always sourced near the top of the file (checked), and whatever new definitions will simply override the ones provided by lib.sh. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen Acked-by: Shuah Khan --- Notes: CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko tools/testing/selftests/net/forwarding/lib.sh | 73 ------------------- tools/testing/selftests/net/lib.sh | 73 +++++++++++++++++++ 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index d28dbf27c1f0..8625e3c99f55 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -445,79 +445,6 @@ done ############################################################################## # Helpers -# Whether FAILs should be interpreted as XFAILs. Internal. -FAIL_TO_XFAIL= - -check_err() -{ - local err=$1 - local msg=$2 - - if ((err)); then - if [[ $FAIL_TO_XFAIL = yes ]]; then - ret_set_ksft_status $ksft_xfail "$msg" - else - ret_set_ksft_status $ksft_fail "$msg" - fi - fi -} - -check_fail() -{ - local err=$1 - local msg=$2 - - check_err $((!err)) "$msg" -} - -check_err_fail() -{ - local should_fail=$1; shift - local err=$1; shift - local what=$1; shift - - if ((should_fail)); then - check_fail $err "$what succeeded, but should have failed" - else - check_err $err "$what failed" - fi -} - -xfail() -{ - FAIL_TO_XFAIL=yes "$@" -} - -xfail_on_slow() -{ - if [[ $KSFT_MACHINE_SLOW = yes ]]; then - FAIL_TO_XFAIL=yes "$@" - else - "$@" - fi -} - -omit_on_slow() -{ - if [[ $KSFT_MACHINE_SLOW != yes ]]; then - "$@" - fi -} - -xfail_on_veth() -{ - local dev=$1; shift - local kind - - kind=$(ip -j -d link show dev $dev | - jq -r '.[].linkinfo.info_kind') - if [[ $kind = veth ]]; then - FAIL_TO_XFAIL=yes "$@" - else - "$@" - fi -} - not() { "$@" diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 4f52b8e48a3a..6bcf5d13879d 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -361,3 +361,76 @@ tests_run() $current_test done } + +# Whether FAILs should be interpreted as XFAILs. Internal. +FAIL_TO_XFAIL= + +check_err() +{ + local err=$1 + local msg=$2 + + if ((err)); then + if [[ $FAIL_TO_XFAIL = yes ]]; then + ret_set_ksft_status $ksft_xfail "$msg" + else + ret_set_ksft_status $ksft_fail "$msg" + fi + fi +} + +check_fail() +{ + local err=$1 + local msg=$2 + + check_err $((!err)) "$msg" +} + +check_err_fail() +{ + local should_fail=$1; shift + local err=$1; shift + local what=$1; shift + + if ((should_fail)); then + check_fail $err "$what succeeded, but should have failed" + else + check_err $err "$what failed" + fi +} + +xfail() +{ + FAIL_TO_XFAIL=yes "$@" +} + +xfail_on_slow() +{ + if [[ $KSFT_MACHINE_SLOW = yes ]]; then + FAIL_TO_XFAIL=yes "$@" + else + "$@" + fi +} + +omit_on_slow() +{ + if [[ $KSFT_MACHINE_SLOW != yes ]]; then + "$@" + fi +} + +xfail_on_veth() +{ + local dev=$1; shift + local kind + + kind=$(ip -j -d link show dev $dev | + jq -r '.[].linkinfo.info_kind') + if [[ $kind = veth ]]; then + FAIL_TO_XFAIL=yes "$@" + else + "$@" + fi +} From patchwork Thu Nov 14 14:09:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 843667 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) (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 8B71A4D8D0; Thu, 14 Nov 2024 14:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593583; cv=fail; b=XruHTUIjIC1ZmTWuInhNg4b3eVHim3j4pEZ9nXK1yFN1Wxyy8Fcq2DJLLO7ptyT51/s6VCzhIuX9Wky2sjH/8gwdSuNYX958bbky0JSnpd71iRPa5bHxDetFqkiRnEDgXiIbU42sJHn/e4lG9xXVR8IHu/yUfv2MEQXyOsca+tc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593583; c=relaxed/simple; bh=792cE3F7FT7Q8JnDuxa7P2ra7m8ilj9UEgxnE1f0haE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RCad0GNOoHfOFI0b8ZH2BPLVWL9oWtJAX15EtdHO30UQVHR1QdVszyDTHK1TEuMyDrcU7/GChgOyvJWqZiFuFRoxEjGK33oVAqkxLn3+gBr3TSAv6PfhmfY8qYG57rCPNXqXeOTFmJStQHv6PAJI7HAF/knnD8xuyZaAmbWRrBg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=pHfyBaID; arc=fail smtp.client-ip=40.107.94.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="pHfyBaID" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Mor0CZdq5StheqTEdT8x6lqmwYg5czstGPxnmQdZivxdcSeWReAvHkpFQYcCIzRvhXOkjAlaSeLfPbMY/isW67ciwxl6kWJ90h01OMvVebXQamaYojsYkSIJ8e/LKk2mBx8I+rV1ch995mB/PzNGB/aC0zcfHyAWVpW6rdBuj8wG8oAuLV1nyXEQhcbeLewZAva4ZfhuNQfHyj4MH2Ad3HjvwpxRGRr02jBh/bJKzAGxc/Wh12tQXK3grKijNBDIGIR6yZSkGSv+vrItSGHRpxWAy+qvP3xa/gbZSqNpeGBwuuF7cF9NzPbLhp/ximMXHY37Qh2Bi5HfV/Vx/wgNhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a+M7JV+EJfAv5VX8yUMf1PJm9BEK/oRTXDHcSdWSh5E=; b=A79T9BFcfazRDrGR6wzjIo5m8o53kC6Q6y2RlnewkBkNOI0zPCzIob05KrILPqGRmoI40rTxVre6HCQIUATqUMxCHjIAzIXDrXWrX+uT1HaVgbKJm779Q+ZA6stQuw1Wql+IAloklVOAeWwyxKxxiszZ9ZXRYweM5vO867jFdQMhJ3gBzBVTeNFnO1uLrgt+fSsSkrhFWspso/l5lC0YZ9uYxEJtCFM0cgQKfvfz/24GqYuj8eIzwvlFJmjPJ8ILuxWmQpspW2Nr7ai0duPpCTcA23/Jz1QLDrJcWvZcryqA9anfE8QbG1RQt7Z7K1RR4SvfaH6o0ZJ2mJi7ZAiMPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a+M7JV+EJfAv5VX8yUMf1PJm9BEK/oRTXDHcSdWSh5E=; b=pHfyBaIDOntpcAE6OLCFR2mlNSMeM5n3kQdXN2aTOWwQDAcrGrElbP+hZMXHMgOJUvi9kF7t4fHSxxYdaEj/TN+m6BLQjjEmW+lNPP0yprn6pFpEyzMYLbZhDxfeROTbXydERGuFbuDWy1vnc88cekynzP6pwZCNSufyKRzYtP6Ury84A0IT14o7hDtKWkxk6MSmRK1cfZhtg7H8aJq3f5p/kf1tp/MJI2zbhI6l8+NPU2mFVOTPZPDhMbLqh3Fv3+gnCBlaE9Ec4NUznLAM6JmDiVa9hpitbu1U+xdSkX7ItU06Eamft4GDPk0KHBCYGe9Iq2nDtFjkeLk6jnj7sg== Received: from SJ0PR03CA0252.namprd03.prod.outlook.com (2603:10b6:a03:3a0::17) by CH3PR12MB7692.namprd12.prod.outlook.com (2603:10b6:610:145::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Thu, 14 Nov 2024 14:12:57 +0000 Received: from SJ1PEPF000023D0.namprd02.prod.outlook.com (2603:10b6:a03:3a0:cafe::85) by SJ0PR03CA0252.outlook.office365.com (2603:10b6:a03:3a0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17 via Frontend Transport; Thu, 14 Nov 2024 14:12:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023D0.mail.protection.outlook.com (10.167.244.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Thu, 14 Nov 2024 14:12:57 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:38 -0800 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:30 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko , Andrew Lunn Subject: [PATCH net-next v4 6/7] selftests: net: lib: Add kill_process Date: Thu, 14 Nov 2024 15:09:58 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D0:EE_|CH3PR12MB7692:EE_ X-MS-Office365-Filtering-Correlation-Id: 0bd2915e-f0b9-4cd7-72b0-08dd04b67056 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: 36PjSACDRX3sSAhAZd7oYb14H3LMwBi6sAetYZRHyuYBKKRi+URBPERonPKqdqwoLWx7Nk2haEWdl/bCxj8z46F7Ep4tyfvpY5YjFIKZc83tR3kyIXLOIcS4l1mYAZHEg3j6/dBo9bLRNyrxRt+p/9awpy6k927EmXiKIkADGsD/Zwgf7y5ZguQ4kuvD5PQSR68oYVoin0l6dIahM1emN5d5OgjVnAUM7NSmbJs7m32/MFTgTNiNK4VHm54y3pZTwsvVoCnRTWTw1MLH14W+751lAzvBtt9Y+NVPBoKwFRCNPEAsgGWoaqYgwqGmtx2lyGjaUu3clagywbj0M3iEElrjaubN6BZrXM7hJjvGTyTMMw0LYBdT9P6cN4lqABCx+UWN57BKT07QgAPAYOwvh4jF+bsATN5HogGy0ZNnOJld5hybpa0pErKR/n6442tRU4opTUxJwEusb4Si1z7eN5z3ccGvoDbBpMMeXfG915FkpuLwkSrZ2jvH2tC78K9n+g0JcalqmRaX1TcvXiB/KwR1SjIhljD+uv3hzVEkfxVTcxwvm/VGx5L8/fbcGUwU/oVn5DGUeIpJsdccCg8ZKdQssocMGwCUO7+mGhD2wfAtlFd64jWyJn1Y4oeaLGKjpNipVkWqu1op10vvi5s6JQrkGdBKrlGxYVPZ2rNlIAJvXU5gq0m85gftWDBDD/jnxBdbWKmCr/67JQA5oOSNS2VBc2H5O/QXoBmTyByE8eriHWiFB9mwPOsHEN8eyNsqS7SG0vYmT9SfynuaFdKMEqbi8OvWKEwiZv57y9ea1Rw4189eCS+WBgPn7WwFZm/mRmw444B1R/dff86jKooyr/iQba4LUTnsvT7rZyjJYL6JCtR4B09yLQty/wXcEBLtf4E0IODRYQ2UK4VWrzcDRdKgO9aCIqIbO6qI/RHG8qBz3cLlO308XuXqtx278/QB3KPmqrXc9A7VkTP+aGpjnZCTTIYa+tEBey7xM5kRZOtV7l/xdIJGUIIdnDfWmvdxqXFb3ofK3KAkxsHnxMhj46ahzmM6IKi64cLSqbPH2z7h4J938sM26DLTRfa3nb7RorKH8nkyz46awrukb2OcfGr4YRHpvTce3dAUS+J5pdpWWGCrmNgL3kD7RPu86Z73HIJYQcOcNyYwMrez/Rf1iw5be6XlsAxqOpz7Y2eep6ASfrKY95LEdjThbizNPU+9D5WMsync+ipCBH0dlPfA7sSsUKgRuNWR5pPk6bMWIDATq+DquMYB68Lda1ksVw4sAQVVrszvcC66jMM0mOYGb0RUlD3z6eIecTuiEhv2MRoQ8jhxQks2ahEGfTgR+pZKbEY0uU2ep0e87q2lIgGZzAlKZmyk6c5nyR+bgYgwEBEBl2x4sP3LpR6zzLUknJba2rQk4dWZ0KqS74fm/PbMKw== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(7416014)(1800799024)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2024 14:12:57.1438 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0bd2915e-f0b9-4cd7-72b0-08dd04b67056 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D0.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7692 A number of selftests run processes in the background and need to kill them afterwards. Instead for everyone to open-code the kill / wait / redirect mantra, add a helper in net/lib.sh. Convert existing open-code sites. Signed-off-by: Petr Machata Acked-by: Shuah Khan Reviewed-by: Amit Cohen --- Notes: CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko CC: Andrew Lunn .../selftests/drivers/net/mlxsw/devlink_trap.sh | 2 +- .../drivers/net/mlxsw/devlink_trap_l3_drops.sh | 4 ++-- .../drivers/net/mlxsw/devlink_trap_l3_exceptions.sh | 12 ++++++------ .../drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh | 4 ++-- .../drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh | 4 ++-- .../drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh | 4 ++-- .../net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh | 4 ++-- .../testing/selftests/drivers/net/mlxsw/tc_sample.sh | 4 ++-- .../drivers/net/netdevsim/fib_notifications.sh | 6 +++--- tools/testing/selftests/net/drop_monitor_tests.sh | 2 +- tools/testing/selftests/net/fib_tests.sh | 8 ++++---- .../testing/selftests/net/forwarding/devlink_lib.sh | 2 +- tools/testing/selftests/net/forwarding/lib.sh | 3 +-- tools/testing/selftests/net/forwarding/tc_police.sh | 8 ++++---- tools/testing/selftests/net/lib.sh | 8 ++++++++ 15 files changed, 41 insertions(+), 34 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh index 89b55e946eed..36055279ba92 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh @@ -116,7 +116,7 @@ dev_del_test() log_test "Device delete" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid } trap cleanup EXIT diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh index 160891dcb4bc..db5806d189bb 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh @@ -595,7 +595,7 @@ irif_disabled_test() log_test "Ingress RIF disabled" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid ip link set dev $rp1 nomaster __addr_add_del $rp1 add 192.0.2.2/24 2001:db8:1::2/64 ip link del dev br0 type bridge @@ -645,7 +645,7 @@ erif_disabled_test() log_test "Egress RIF disabled" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid __addr_add_del $rp1 add 192.0.2.2/24 2001:db8:1::2/64 ip link del dev br0 type bridge devlink_trap_action_set $trap_name "drop" diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_exceptions.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_exceptions.sh index 190c1b6b5365..5d6d88b600f0 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_exceptions.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_exceptions.sh @@ -202,7 +202,7 @@ mtu_value_is_too_small_test() mtu_restore $rp2 - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $h1 ingress protocol ip pref 1 handle 101 flower } @@ -235,7 +235,7 @@ __ttl_value_is_too_small_test() log_test "TTL value is too small: TTL=$ttl_val" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $h1 ingress protocol ip pref 1 handle 101 flower } @@ -299,7 +299,7 @@ __mc_reverse_path_forwarding_test() log_test "Multicast reverse path forwarding: $desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $rp2 egress protocol $proto pref 1 handle 101 flower } @@ -347,7 +347,7 @@ __reject_route_test() log_test "Reject route: $desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid ip route del unreachable $unreachable tc filter del dev $h1 ingress protocol $proto pref 1 handle 101 flower } @@ -542,7 +542,7 @@ ipv4_lpm_miss_test() log_test "LPM miss: IPv4" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid vrf_without_routes_destroy } @@ -569,7 +569,7 @@ ipv6_lpm_miss_test() log_test "LPM miss: IPv6" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid vrf_without_routes_destroy } diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh index e9a82cae8c9a..4ac1dae92d0f 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh @@ -176,7 +176,7 @@ ecn_decap_test() log_test "$desc: Inner ECN is not ECT and outer is $ecn_desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower } @@ -207,7 +207,7 @@ no_matching_tunnel_test() log_test "$desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower } diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh index 878125041fc3..fce885184404 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh @@ -176,7 +176,7 @@ ecn_decap_test() log_test "$desc: Inner ECN is not ECT and outer is $ecn_desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ipv6 pref 1 handle 101 flower } @@ -207,7 +207,7 @@ no_matching_tunnel_test() log_test "$desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ipv6 pref 1 handle 101 flower } diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh index 5f6eb965cfd1..7aca8e5922cf 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh @@ -183,7 +183,7 @@ ecn_decap_test() log_test "$desc: Inner ECN is not ECT and outer is $ecn_desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower } @@ -253,7 +253,7 @@ corrupted_packet_test() log_test "$desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower } diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh index f6c16cbb6cf7..4599c331240b 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh @@ -188,7 +188,7 @@ ecn_decap_test() log_test "$desc: Inner ECN is not ECT and outer is $ecn_desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ipv6 pref 1 handle 101 flower } @@ -262,7 +262,7 @@ corrupted_packet_test() log_test "$desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ipv6 pref 1 handle 101 flower } diff --git a/tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh b/tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh index 83a0210e7544..bc7ea2df49fb 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh @@ -218,7 +218,7 @@ psample_capture_start() psample_capture_stop() { - { kill %% && wait %%; } 2>/dev/null + kill_process %% } __tc_sample_rate_test() @@ -499,7 +499,7 @@ tc_sample_md_out_tc_occ_test() backlog=$(tc -j -p -s qdisc show dev $rp2 | jq '.[0]["backlog"]') # Kill mausezahn. - { kill %% && wait %%; } 2>/dev/null + kill_process %% psample_capture_stop diff --git a/tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh b/tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh index 8d91191a098c..9896580c3d85 100755 --- a/tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh +++ b/tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh @@ -94,7 +94,7 @@ route_addition_check() sleep 1 $IP route add $route dev dummy1 sleep 1 - kill %% && wait %% &> /dev/null + kill_process %% route_notify_check $outfile $expected_num_notifications $offload_failed rm -f $outfile @@ -148,7 +148,7 @@ route_deletion_check() sleep 1 $IP route del $route dev dummy1 sleep 1 - kill %% && wait %% &> /dev/null + kill_process %% route_notify_check $outfile $expected_num_notifications rm -f $outfile @@ -191,7 +191,7 @@ route_replacement_check() sleep 1 $IP route replace $route dev dummy2 sleep 1 - kill %% && wait %% &> /dev/null + kill_process %% route_notify_check $outfile $expected_num_notifications rm -f $outfile diff --git a/tools/testing/selftests/net/drop_monitor_tests.sh b/tools/testing/selftests/net/drop_monitor_tests.sh index 7c4818c971fc..507d0a82f5f0 100755 --- a/tools/testing/selftests/net/drop_monitor_tests.sh +++ b/tools/testing/selftests/net/drop_monitor_tests.sh @@ -77,7 +77,7 @@ sw_drops_test() rm ${dir}/packets.pcap - { kill %% && wait %%; } 2>/dev/null + kill_process %% timeout 5 dwdump -o sw -w ${dir}/packets.pcap (( $(tshark -r ${dir}/packets.pcap \ -Y 'ip.dst == 192.0.2.10' 2> /dev/null | wc -l) == 0)) diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh index 5f3c28fc8624..3ea6f886a210 100755 --- a/tools/testing/selftests/net/fib_tests.sh +++ b/tools/testing/selftests/net/fib_tests.sh @@ -689,7 +689,7 @@ fib6_notify_test() log_test $ret 0 "ipv6 route add notify" - { kill %% && wait %%; } 2>/dev/null + kill_process %% #rm errors.txt @@ -736,7 +736,7 @@ fib_notify_test() log_test $ret 0 "ipv4 route add notify" - { kill %% && wait %%; } 2>/dev/null + kill_process %% rm errors.txt @@ -2328,7 +2328,7 @@ ipv4_mangle_test() $IP route del table 123 172.16.101.0/24 dev veth1 $IP rule del pref 100 - { kill %% && wait %%; } 2>/dev/null + kill_process %% rm $tmp_file route_cleanup @@ -2386,7 +2386,7 @@ ipv6_mangle_test() $IP -6 route del table 123 2001:db8:101::/64 dev veth1 $IP -6 rule del pref 100 - { kill %% && wait %%; } 2>/dev/null + kill_process %% rm $tmp_file route_cleanup diff --git a/tools/testing/selftests/net/forwarding/devlink_lib.sh b/tools/testing/selftests/net/forwarding/devlink_lib.sh index 62a05bca1e82..18afa89ebbcc 100644 --- a/tools/testing/selftests/net/forwarding/devlink_lib.sh +++ b/tools/testing/selftests/net/forwarding/devlink_lib.sh @@ -501,7 +501,7 @@ devlink_trap_drop_cleanup() local pref=$1; shift local handle=$1; shift - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $dev egress protocol $proto pref $pref handle $handle flower } diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 8625e3c99f55..7337f398f9cc 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1574,8 +1574,7 @@ stop_traffic() { local pid=${1-%%}; shift - # Suppress noise from killing mausezahn. - { kill $pid && wait $pid; } 2>/dev/null + kill_process "$pid" } declare -A cappid diff --git a/tools/testing/selftests/net/forwarding/tc_police.sh b/tools/testing/selftests/net/forwarding/tc_police.sh index 5103f64a71d6..509fdedfcfa1 100755 --- a/tools/testing/selftests/net/forwarding/tc_police.sh +++ b/tools/testing/selftests/net/forwarding/tc_police.sh @@ -148,7 +148,7 @@ police_common_test() log_test "$test_name" - { kill %% && wait %%; } 2>/dev/null + kill_process %% tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower } @@ -198,7 +198,7 @@ police_shared_common_test() log_test "$test_name" - { kill %% && wait %%; } 2>/dev/null + kill_process %% } police_shared_test() @@ -278,7 +278,7 @@ police_mirror_common_test() log_test "$test_name" - { kill %% && wait %%; } 2>/dev/null + kill_process %% tc filter del dev $pol_if $dir protocol ip pref 1 handle 101 flower tc filter del dev $h3 ingress protocol ip pref 1 handle 101 flower tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower @@ -320,7 +320,7 @@ police_pps_common_test() log_test "$test_name" - { kill %% && wait %%; } 2>/dev/null + kill_process %% tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower } diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 6bcf5d13879d..24f63e45735d 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -434,3 +434,11 @@ xfail_on_veth() "$@" fi } + +kill_process() +{ + local pid=$1; shift + + # Suppress noise from killing the process. + { kill $pid && wait $pid; } 2>/dev/null +} From patchwork Thu Nov 14 14:09:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 843323 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2082.outbound.protection.outlook.com [40.107.244.82]) (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 A0C3574BE1; Thu, 14 Nov 2024 14:13:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593592; cv=fail; b=aW2uE09l4evljjYv4pMVDtND8QH4fE+mYMSgksK8LWb6DmsJhn8dZJ6mhyhqDznt59mM/TogJ2wnXcV55M5GSc3CQU2ggugd3bdVKPe3XX+dPSH19c5kLJGEBYQdtJpX1VlVMCQ5SGF9OxFHMShxji43XBPgtDn6kMiiP8yQ+Uw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731593592; c=relaxed/simple; bh=Lh9ZeMDtu/EEAYzsGmicpbsxKbm2Hs8eop6jxt0MHLs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kEOShR2Qv6+B3v4dkGMl8YBox1TrRC2TXgNrhbYKC4+mzcKzwrYhIJqs2FVWAWmDEhkXyIvA971/EDcIS/ncEWAh8Hh9Dcs+4TqeaswPnFgOdAcSv0YMWbzfAr7SSjLpcrlOciYOJvT2WmN30Cf2uguNcJrTdrWCMTYAuMlil/g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Fu1528dd; arc=fail smtp.client-ip=40.107.244.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Fu1528dd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xdJz+y7UpvP4Bjar+frxgdFYcfyzKh391dfUmuz1/cl2NCron5tHp3yIQdmjWrvEe++Q1+aPRpQJefmVrOuH49C4ZOIwURDVOFGXa8sZqT6BMH01j12Ri77+cWIcPILoEWrmCrbaUq4hy5NzPS5wQwjs9VPDH9ZejOp49NmzpW5uaIQ14/6Z+mk/b87b00mioK9PQ+xg64bO1rKiL9PUhOU+GOPyxX+zDlng2c4hvt087R4VzlE1ETKItlEQ46sLRktvNUd0BIbcDxOmzSrtutZu1tpC2eFqlJnRtqhG/u/nvK5iwoEFRGgyYAS5oNzhxoNvFDE7S9dvkzTcc/ctKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oLhAWSsdS6h4Px/bZX5a9/WrfuXlE0DgG1hrjpze6/s=; b=NWVZTMb23U5P8Yxc2bayr2PjCti05PVDvMA3UfkPEg4rlZUpn979Hdk1Z++CVdsVORuDq1bYHDF8gDOuoBSHo6wyK7ZLxIFQikULCt/epeccyorPGgG1QFelBGQ8SR1H2CL6fyUAbKrj0FGJ6vgXNXTN1nj+mzPUtEUNROxV8dlrYqpqntlCkKDiFDdFKKan18Iqpn9k+xM7bq8IvEbNg1ho8OBI9iOlhs4VO70JucMj5v78VgCn4bMKc7qePhxLBFMWxvWV11CMEHWcxZG6+i8RDfMbfHaL7pSsmS6FoMN8Vug+iPJbTISsNeO0qb9QJ7a/xZVXPh1xy1zQTrLYKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oLhAWSsdS6h4Px/bZX5a9/WrfuXlE0DgG1hrjpze6/s=; b=Fu1528dd34MT3OmcRoGRJpwcPmDyBnzegxUV93Az9RBZUMWZi6kfe47tuYNSqX5B56GxjRPHUj+ZzFz6an2qzeD4poOKeaeu+wynxtyOyzYoHUZ47lxgWwwF9fTCY23QG+0KYQqjQz25Ag+L7XVaj/QeFHX+xT/TomZGRTGN4eINWy8UgifI06mDQk1JhK69XlW98rmzTBcddbBZhluT7uHxUxkua+K09egYr7DTTuXVD84IvHv0RgwjYLkohEWUTTW23OsdGwtYlK0nI+9PCz1dPbNqfmX3/B3AI7vn0zQ7rxjB5Xnl9qpWbwxfOhhY/4SbtcQ5tFlKZpMkEHwIaA== Received: from CH2PR14CA0001.namprd14.prod.outlook.com (2603:10b6:610:60::11) by SJ0PR12MB7458.namprd12.prod.outlook.com (2603:10b6:a03:48d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.16; Thu, 14 Nov 2024 14:13:05 +0000 Received: from DS3PEPF000099D3.namprd04.prod.outlook.com (2603:10b6:610:60:cafe::2d) by CH2PR14CA0001.outlook.office365.com (2603:10b6:610:60::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29 via Frontend Transport; Thu, 14 Nov 2024 14:13:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF000099D3.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Thu, 14 Nov 2024 14:13:04 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:46 -0800 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 14 Nov 2024 06:12:39 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v4 7/7] selftests: net: fdb_notify: Add a test for FDB notifications Date: Thu, 14 Nov 2024 15:09:59 +0100 Message-ID: <910c5880ae6d3b558d6889cbdba2be690c2615c6.1731589511.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D3:EE_|SJ0PR12MB7458:EE_ X-MS-Office365-Filtering-Correlation-Id: f24f67b7-6f6c-4661-9c66-08dd04b674a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: twYwB1BbJYgeV5RYhfNm2aPJqL/FtQEVkMrXcAsH/CnvsRcml7FTzhgzxeThp/YWaNnVIe/c5hfYb6nnRSejd0yYCM8THkfXLifd/kG+LSCNkbRqLUv+Mn3hpC+oufvk/xNm33hDUUqAHRQcmF1PQrL8hPlkuDlD0Non+PY/0iWMXlp1T+QkeTqA1bxWD0Lvkapw9nz+aq6vWCj7J2j6Sp88NFpxDumqP7mapKgGcNUn+MnI0JMfJiXAd7EufofV66KL364ic6qHEMVxoEnXgrC+75Dt6b3AR0fN5o5mYNCEFc93RbO7lqmcRRJnzjdOu/JQbHLnkPaUVmXfoCGTfbhFKp/6kgaVeQ6cx7+XNmB/a5d5HCJlPnv5xzRAAMHX0xKXp96n+Xu6ZMC1bQwKO/rlO389WP5XRVRi/UPStI9VHSxRB+tBckjcoJ/t1Vc1Zp/1vLLjbVJiR6cI8pL/IGj4oTfXJiAsrw/kFX5Ly1Ktm55tyzakqYYPxXE7g56H98yJhrMDK9ike6iyshYbpdh3C6Vw3/8syPqP8m3eremFXkh2HNv8V5NdZ2gBA1IOEOwK40K9dTnKR/7ZvX3+L0rc1ttwE3qE6y0tgDmeVrQjXzmYkMFK0KUxYjNBymf1QYa3P6uj6CS6jmmUGZpit695DwUJxFRwAGje4koFKl9on9VbfnPzP1XP7FlEg44NIdYVGkrxarHwuDqHExporfhmiThfPOjIEt/supDDHGdYdOTdkFer0Jm20WOT8XbvO2igQHpeTdMNaBJ9xfDAieIj9WjVRoPTC1+L/p4FwyCOwpMmUyha6A0WFvmc/eM+3Nq7PNJKINZs84Kisofl56S4WaoilCRtp1BAcEss+ITfMQFliquFdi4qkNU9DjzHT36Lk8rDNIPOX4V1jDSulEKYTIc6b0lzEIkZF3Q1CFlijLvptsAnN5LU7Ni60yWjQhj+rnv4IthrJEBKwhwqclFYCYxttkuv4XK+UARULdViSRHNbd8DzDva8G5dl8hbxWixn03T7308J1LbhKxS0OvFThwoi4Sz1yS6XlukYp7RRTmAmhZYwexO6CEPErLfhcARZhiDWctnYg2IH1Z1hP1q7+5a5yC6asLI2q9wR11zGAe16RGQHq1ey+rjlNv0xSwN9LVtpRb9b7NhgWrLH1nfk34nUt3gPJ1HqcEn5V1xHPGG9kXpC/bugCGL2jdq5rU27Eb+TeAjJy0jVM00ZfDGw/dzdpWekAt4MkaCFJBaW1KLc0D1QrS+DayKn0tMtBD9T4cGPBVc2kJ6mJMKxL7lUg3SdBo+YbPN8GTufdjGEZSb4Ij9CU+WeZW9iWpyxGD70tmvTlko3PBQPtKR7Obw3wdbrK0HOBpBEOz23Wx/z6qK2ZhnLJ5k44Kn0t2HlYfspBBpk+zUAdzvphZgFg== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2024 14:13:04.2314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f24f67b7-6f6c-4661-9c66-08dd04b674a0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7458 Check that only one notification is produced for various FDB edit operations. Regarding the ip_link_add() and ip_link_master() helpers. This pattern of action plus corresponding defer is bound to come up often, and a dedicated vocabulary to capture it will be handy. tunnel_create() and vlan_create() from forwarding/lib.sh are somewhat opaque and perhaps too kitchen-sinky, so I tried to go in the opposite direction with these ones, and wrapped only the bare minimum to schedule a corresponding cleanup. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen Acked-by: Shuah Khan --- Notes: v4: - Adjust the sleep around the FDB op --- CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/fdb_notify.sh | 96 +++++++++++++++++++++++ tools/testing/selftests/net/lib.sh | 17 ++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/net/fdb_notify.sh diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 2b2a5ec7fa6a..d1494700f501 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -92,7 +92,7 @@ TEST_PROGS += test_vxlan_mdb.sh TEST_PROGS += test_bridge_neigh_suppress.sh TEST_PROGS += test_vxlan_nolocalbypass.sh TEST_PROGS += test_bridge_backup_port.sh -TEST_PROGS += fdb_flush.sh +TEST_PROGS += fdb_flush.sh fdb_notify.sh TEST_PROGS += fq_band_pktlimit.sh TEST_PROGS += vlan_hw_filter.sh TEST_PROGS += bpf_offload.py diff --git a/tools/testing/selftests/net/fdb_notify.sh b/tools/testing/selftests/net/fdb_notify.sh new file mode 100755 index 000000000000..c03151e7791c --- /dev/null +++ b/tools/testing/selftests/net/fdb_notify.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source lib.sh + +ALL_TESTS=" + test_dup_bridge + test_dup_vxlan_self + test_dup_vxlan_master + test_dup_macvlan_self + test_dup_macvlan_master +" + +do_test_dup() +{ + local op=$1; shift + local what=$1; shift + local tmpf + + RET=0 + + tmpf=$(mktemp) + defer rm "$tmpf" + + defer_scope_push + bridge monitor fdb &> "$tmpf" & + defer kill_process $! + + sleep 0.5 + bridge fdb "$op" 00:11:22:33:44:55 vlan 1 "$@" + sleep 0.5 + defer_scope_pop + + local count=$(grep -c -e 00:11:22:33:44:55 $tmpf) + ((count == 1)) + check_err $? "Got $count notifications, expected 1" + + log_test "$what $op: Duplicate notifications" +} + +test_dup_bridge() +{ + ip_link_add br up type bridge vlan_filtering 1 + do_test_dup add "bridge" dev br self + do_test_dup del "bridge" dev br self +} + +test_dup_vxlan_self() +{ + ip_link_add br up type bridge vlan_filtering 1 + ip_link_add vx up type vxlan id 2000 dstport 4789 + ip_link_master vx br + + do_test_dup add "vxlan" dev vx self dst 192.0.2.1 + do_test_dup del "vxlan" dev vx self dst 192.0.2.1 +} + +test_dup_vxlan_master() +{ + ip_link_add br up type bridge vlan_filtering 1 + ip_link_add vx up type vxlan id 2000 dstport 4789 + ip_link_master vx br + + do_test_dup add "vxlan master" dev vx master + do_test_dup del "vxlan master" dev vx master +} + +test_dup_macvlan_self() +{ + ip_link_add dd up type dummy + ip_link_add mv up link dd type macvlan mode passthru + + do_test_dup add "macvlan self" dev mv self + do_test_dup del "macvlan self" dev mv self +} + +test_dup_macvlan_master() +{ + ip_link_add br up type bridge vlan_filtering 1 + ip_link_add dd up type dummy + ip_link_add mv up link dd type macvlan mode passthru + ip_link_master mv br + + do_test_dup add "macvlan master" dev mv self + do_test_dup del "macvlan master" dev mv self +} + +cleanup() +{ + defer_scopes_cleanup +} + +trap cleanup EXIT +tests_run + +exit $EXIT_STATUS diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 24f63e45735d..8994fec1c38f 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -442,3 +442,20 @@ kill_process() # Suppress noise from killing the process. { kill $pid && wait $pid; } 2>/dev/null } + +ip_link_add() +{ + local name=$1; shift + + ip link add name "$name" "$@" + defer ip link del dev "$name" +} + +ip_link_master() +{ + local member=$1; shift + local master=$1; shift + + ip link set dev "$member" master "$master" + defer ip link set dev "$member" nomaster +}