From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F673C28CC5 for ; Wed, 5 Jun 2019 23:15:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E83682075B for ; Wed, 5 Jun 2019 23:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559776535; bh=XZMdw6bawNXq9CrWS8caCSn4zATtXzv+tZODYwnIyKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bpoe6/Kmatabh30G/BCXzrQFPyGCU5FtEg1/9KqJW/36jHM1LlCtYKXRhJO9ahpMA LTAYMGp5C9TO4I2yfMC1i32Ud81DXCq/ECc4f7KXUUbdkso8n2+jkjIWm4rEkOHY4+ F0w7+RfsIpBOLXLsuki77AiZg6fvoKQXkPfiGiiY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbfFEXPd (ORCPT ); Wed, 5 Jun 2019 19:15:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:59530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726671AbfFEXP3 (ORCPT ); Wed, 5 Jun 2019 19:15:29 -0400 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27FC3212F5; Wed, 5 Jun 2019 23:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559776529; bh=XZMdw6bawNXq9CrWS8caCSn4zATtXzv+tZODYwnIyKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vRfdJLB7glI9gF2CpBk0Cloa/SmFvGrgbYia60H8ClZf4naAyhDoMumKHpJehytK6 O/skyN6icBLJSckY7arGD/FHk5pjimciAvDneO/tz20joYWhjacreb2W8/FNV6ldKb BvGTDmnfpUWmqkQ24eXcamlAmsL/BUeYGyNfWJ7w= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, kafai@fb.com, weiwan@google.com, sbrivio@redhat.com, David Ahern Subject: [PATCH net-next 15/19] selftests: pmtu: Move running of test into a new function Date: Wed, 5 Jun 2019 16:15:19 -0700 Message-Id: <20190605231523.18424-16-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190605231523.18424-1-dsahern@kernel.org> References: <20190605231523.18424-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Move the block of code that runs a test and prints the verdict to a new function, run_test. Signed-off-by: David Ahern --- tools/testing/selftests/net/pmtu.sh | 63 +++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 4a1275990d7e..3d6b21c4b1db 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -1090,6 +1090,41 @@ test_cleanup_ipv4_exception() { test_cleanup_vxlanX_exception 4 } +run_test() { + ( + tname="$1" + tdesc="$2" + + unset IFS + + if [ "$VERBOSE" = "1" ]; then + printf "\n##########################################################################\n\n" + fi + + eval test_${tname} + ret=$? + + if [ $ret -eq 0 ]; then + printf "TEST: %-60s [ OK ]\n" "${tdesc}" + elif [ $ret -eq 1 ]; then + printf "TEST: %-60s [FAIL]\n" "${tdesc}" + if [ "${PAUSE_ON_FAIL}" = "yes" ]; then + echo + echo "Pausing. Hit enter to continue" + read a + fi + err_flush + exit 1 + elif [ $ret -eq 2 ]; then + printf "TEST: %-60s [SKIP]\n" "${tdesc}" + err_flush + fi + + return $ret + ) + [ $? -ne 0 ] && exitcode=1 +} + usage() { echo echo "$0 [OPTIONS] [TEST]..." @@ -1147,33 +1182,7 @@ for t in ${tests}; do done [ $run_this -eq 0 ] && continue - ( - unset IFS - - if [ "$VERBOSE" = "1" ]; then - printf "\n##########################################################################\n\n" - fi - - eval test_${name} - ret=$? - - if [ $ret -eq 0 ]; then - printf "TEST: %-60s [ OK ]\n" "${t}" - elif [ $ret -eq 1 ]; then - printf "TEST: %-60s [FAIL]\n" "${t}" - if [ "${PAUSE_ON_FAIL}" = "yes" ]; then - echo - echo "Pausing. Hit enter to continue" - read a - fi - err_flush - exit 1 - elif [ $ret -eq 2 ]; then - printf "TEST: %-60s [SKIP]\n" "${t}" - err_flush - fi - ) - [ $? -ne 0 ] && exitcode=1 + run_test "${name}" "${t}" done exit ${exitcode} -- 2.11.0