From patchwork Fri Jun 22 15:10:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 933438 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41C28J6ZFzz9ryk for ; Sat, 23 Jun 2018 01:11:12 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4D40A3E6102 for ; Fri, 22 Jun 2018 17:11:10 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 862063E60A8 for ; Fri, 22 Jun 2018 17:11:04 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 7FC581400B88 for ; Fri, 22 Jun 2018 17:11:03 +0200 (CEST) Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D0836AC69; Fri, 22 Jun 2018 15:11:02 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 22 Jun 2018 17:10:42 +0200 Message-Id: <20180622151047.13002-4-pvorel@suse.cz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622151047.13002-1-pvorel@suse.cz> References: <20180622151047.13002-1-pvorel@suse.cz> X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v2 3/8] tst_net.sh: Harden against multiple loading X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Some tests (macsec0{1,2}.sh) load tst_net.sh twice via loading from ipsec_lib.sh and virt_lib.sh. That brings duplicity in some variables (TST_OPTS) and create infinite loop, as tst_net_setup calls itself. Signed-off-by: Petr Vorel --- testcases/lib/tst_net.sh | 42 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh index aad701952..ac61dfab8 100644 --- a/testcases/lib/tst_net.sh +++ b/testcases/lib/tst_net.sh @@ -19,14 +19,6 @@ # Author: Alexey Kodanev # -TST_OPTS="6$TST_OPTS" -TST_PARSE_ARGS_CALLER="$TST_PARSE_ARGS" -TST_PARSE_ARGS="tst_net_parse_args" -TST_USAGE_CALLER="$TST_USAGE" -TST_USAGE="tst_net_usage" -TST_SETUP_CALLER="$TST_SETUP" -TST_SETUP="tst_net_setup" - # Blank for an IPV4 test; 6 for an IPV6 test. TST_IPV6=${TST_IPV6:-} TST_IPVER=${TST_IPV6:-4} @@ -73,14 +65,6 @@ tst_net_setup() [ -n "$TST_SETUP_CALLER" ] && $TST_SETUP_CALLER } -if [ -z "$TST_LIB_LOADED" ]; then - [ -n "$TST_USE_LEGACY_API" ] && . test.sh || . tst_test.sh -fi - -if [ -n "$TST_USE_LEGACY_API" ]; then - tst_net_read_opts "$@" -fi - # old vs. new API compatibility layer tst_res_() { @@ -659,6 +643,32 @@ tst_cleanup_rhost() tst_rhost_run -c "rm -rf $TST_TMPDIR" } +if [ -z "$TST_LIB_LOADED" ]; then + TST_OPTS="6$TST_OPTS" + TST_PARSE_ARGS_CALLER="$TST_PARSE_ARGS" + TST_PARSE_ARGS="tst_net_parse_args" + TST_USAGE_CALLER="$TST_USAGE" + TST_USAGE="tst_net_usage" + TST_SETUP_CALLER="$TST_SETUP" + TST_SETUP="tst_net_setup" + + if [ "$TST_PARSE_ARGS_CALLER" = "$TST_PARSE_ARGS" ]; then + unset TST_PARSE_ARGS_CALLER + fi + if [ "$TST_USAGE_CALLER" = "$TST_USAGE" ]; then + unset TST_USAGE_CALLER + fi + if [ "$TST_PARSE_ARGS_CALLER" = "$TST_PARSE_ARGS" ]; then + unset TST_PARSE_ARGS_CALLER + fi + + [ -n "$TST_USE_LEGACY_API" ] && . test.sh || . tst_test.sh +fi + +if [ -n "$TST_USE_LEGACY_API" ]; then + tst_net_read_opts "$@" +fi + # Management Link [ -z "$RHOST" ] && TST_USE_NETNS="yes" export RHOST="$RHOST"