From patchwork Mon Jun 18 17:37:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 931108 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=2001:1418:10:5::2; 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 [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418db3077Kz9ryk for ; Tue, 19 Jun 2018 03:37:34 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E51503E7098 for ; Mon, 18 Jun 2018 19:37:31 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id A46B53E716D for ; Mon, 18 Jun 2018 19:37:26 +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-4.smtp.seeweb.it (Postfix) with ESMTPS id 92D231000C4B for ; Mon, 18 Jun 2018 19:37:25 +0200 (CEST) Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 182AFAF7F; Mon, 18 Jun 2018 17:37:25 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Mon, 18 Jun 2018 19:37:04 +0200 Message-Id: <20180618173707.30351-4-pvorel@suse.cz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618173707.30351-1-pvorel@suse.cz> References: <20180618173707.30351-1-pvorel@suse.cz> X-Virus-Scanned: clamav-milter 0.99.2 at in-4.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-4.smtp.seeweb.it Subject: [LTP] [PATCH 3/6] 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"