From patchwork Tue Jun 26 00:07:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10487575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A0E77603B5 for ; Tue, 26 Jun 2018 00:07:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9317928619 for ; Tue, 26 Jun 2018 00:07:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87DCC2870B; Tue, 26 Jun 2018 00:07:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 078D628619 for ; Tue, 26 Jun 2018 00:07:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934317AbeFZAHt (ORCPT ); Mon, 25 Jun 2018 20:07:49 -0400 Received: from mail-eopbgr60055.outbound.protection.outlook.com ([40.107.6.55]:41485 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933803AbeFZAHr (ORCPT ); Mon, 25 Jun 2018 20:07:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vhm/HIdQx5J7BVb8kYn43Wxp1v3qJR8jYVoiG28d5vU=; b=aPkpV+LALD8nWie7l+SjBS0qCwqyWIdGLpee9AG932ugO3CALs+gryNWRPI0+6VNNsQCcwq0R3mRCKXg1wzVqBpjT6qbkMoCZ19mtn94DCWfbsNYw92EY7w5KqaaagaOFsQymkP6aJEkrqoue7ZpFAx8AUoQq9RT3nfPODulsOo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.23; Tue, 26 Jun 2018 00:07:44 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, shuah@kernel.org Subject: [PATCH net-next 2/6] selftests: forwarding: multipath_eval(): Improve style In-Reply-To: References: Message-Id: <8fe4847c65e75c633f20740a8144e1d35944004a.1529971148.git.petrm@mellanox.com> Date: Tue, 26 Jun 2018 02:07:08 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: LO2P265CA0091.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::31) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fb1a355-d767-42ee-bf16-08d5daf8d7bf X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:kF6ne5D3CrmSrMMfZ9p20R2PTbF0Um6T4spPOm24xNacMN+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k65J888cCKZOVndWGm/uHuWswBR20ckL9VJtmvpfee6+E8pcKF6rUfiq7GXbz2Iee5oL5MTeCLSo2f+fyxzv2CSj8e1od8FCs49VVb0pqPuBy/eLcWVeIX3yEOyd1OQsZEf0Kjq6N/dYSR2FB/m8sMvs9Mt9K7llNwHbNz2ff7IohhqjQHpxW677u3uPRsZv03mHVN9Ktb/3XpvzPLhhuaWnOcIHiwow2PPLSzDkyK9LVLIYeWLcsa/+Z1QtiHG3zaYW09ywZ11Tt8ns1swiHtwxtz18Zu7eYe3GV3Q52exTc; 4:hq6vCZWfZKaNwA/UBlCQqT99i6rmU7vusVPvRVW4rrCoz4I/eVHm1UF73Mllvtlc2EDKXNDaTqxr7hHO4BAfoXdgHLZMTYcmZFJqJ9TxNuSee9L99NGEKGAuwJiYhCBQLQGsDYQrXb2t7t5E6dGNC9AcDsVJPWA1Zs8HQBWnf+/c53w1/M9O85jFEQTffkcC4nHYELL/V4tw3i+4eBzuB0RehvIDoIilPM6/UjIOGQfj7UlrvwCbgofRckXF/ku4hjySf990+akr27ONLbaKgQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 071518EF63 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39860400002)(396003)(376002)(366004)(136003)(189003)(199004)(446003)(6666003)(86362001)(26005)(186003)(5660300001)(97736004)(11346002)(16526019)(486006)(50466002)(36756003)(386003)(76176011)(2616005)(476003)(48376002)(956004)(2906002)(6496006)(52116002)(16586007)(316002)(6116002)(3846002)(118296001)(47776003)(6486002)(66066001)(68736007)(53936002)(106356001)(305945005)(7736002)(8936002)(51416003)(8676002)(4326008)(81166006)(81156014)(105586002)(58126008)(25786009)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4191; 23:Tzw3RBFbhPce/NrsGFbcZFOD5sXPbxI6gGpZqSKON?= =?us-ascii?Q?Lr1HK3+ZGrtcvuV2L60RLpktFH6xXrLky7g1VjC2Mj40OTQnKUhtdhXCyQEb?= =?us-ascii?Q?lLgpIUBjov1BAlIau9uaohpGYQq+nWnVPaqUVK0+6oWvAGBxtcRhg5hf9t4n?= =?us-ascii?Q?Cm50ksxy9FaI02w3uJzeTKf8xdsM0reZvrpC48I71hZ4uoXXxnCyqcrtNySj?= =?us-ascii?Q?1/VrXvkRezqUQO+KLksmmbDesjJPFLaes58wvSp8nNJ087UCo4w5cciLu16c?= =?us-ascii?Q?U13cSDE4otcQYHXMmQqk9xAAxtce5Eu0fqnaeP5cvGT2VvHJsrwnODR2jXkB?= =?us-ascii?Q?L6am9gU3+uGmDp3eQ2SE3u80tCp4iGftWXr6WBOY3HRi4hieDVObdJsfdm+Y?= =?us-ascii?Q?NWAQGP3wOtQlsjfoaIqY3ZN4AgnbrSgvLyOy4d9ILknn+6ysKG5iHeZgyORt?= =?us-ascii?Q?5xyDcUXMhbDN7Nv8CAwTdFNREXunlHywxymkHgBZiz9RfYJVFXHBcc5d43ZM?= =?us-ascii?Q?Tjzb5lm2jYbovM0ACfXw1hjwrHt6S4Vl79CG88zGIHd4WyMb+73mIFfDqn25?= =?us-ascii?Q?WHUybapmgnlf1wMjgmAWjR9YtKcN3lLq3xD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jYpossb1rhdU1WvQi9KC00/q5Y8wnFo0aRwlx5iT X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2018 00:07:44.5143 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fb1a355-d767-42ee-bf16-08d5daf8d7bf X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - Change the indentation of the function body from 7 spaces to one tab. - Move initialization of weights_ratio up so that it can be referenced from the error message about packet difference being zero. - Move |'s consistently to continuation line, which reindent. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- tools/testing/selftests/net/forwarding/lib.sh | 74 ++++++++++++++------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 7fae805147ae..911d753c4ff0 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -559,41 +559,45 @@ tests_run() multipath_eval() { - local desc="$1" - local weight_rp12=$2 - local weight_rp13=$3 - local packets_rp12=$4 - local packets_rp13=$5 - local weights_ratio packets_ratio diff - - RET=0 - - if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then - check_err 1 "Packet difference is 0" - log_test "Multipath" - log_info "Expected ratio $weights_ratio" - return - fi - - if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then - weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \ - | bc -l) - packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \ - | bc -l) - else - weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" | \ - bc -l) - packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" | \ - bc -l) - fi - - diff=$(echo $weights_ratio - $packets_ratio | bc -l) - diff=${diff#-} - - test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0 - check_err $? "Too large discrepancy between expected and measured ratios" - log_test "$desc" - log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio" + local desc="$1" + local weight_rp12=$2 + local weight_rp13=$3 + local packets_rp12=$4 + local packets_rp13=$5 + local weights_ratio packets_ratio diff + + RET=0 + + if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then + weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \ + | bc -l) + else + weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" \ + | bc -l) + fi + + if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then + check_err 1 "Packet difference is 0" + log_test "Multipath" + log_info "Expected ratio $weights_ratio" + return + fi + + if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then + packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \ + | bc -l) + else + packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" \ + | bc -l) + fi + + diff=$(echo $weights_ratio - $packets_ratio | bc -l) + diff=${diff#-} + + test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0 + check_err $? "Too large discrepancy between expected and measured ratios" + log_test "$desc" + log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio" } ##############################################################################