From patchwork Thu Mar 29 23:31:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 893062 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 40C1HL6g46z9s0t for ; Fri, 30 Mar 2018 10:31:56 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D5E5D3E61F5 for ; Fri, 30 Mar 2018 01:31:53 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 583603E619F for ; Fri, 30 Mar 2018 01:31:50 +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-7.smtp.seeweb.it (Postfix) with ESMTPS id E22FC200B35 for ; Fri, 30 Mar 2018 01:31:49 +0200 (CEST) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7B860AEFB; Thu, 29 Mar 2018 23:31:49 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 30 Mar 2018 01:31:33 +0200 Message-Id: <20180329233134.24151-3-pvorel@suse.cz> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329233134.24151-1-pvorel@suse.cz> References: <20180329233134.24151-1-pvorel@suse.cz> X-Virus-Scanned: clamav-milter 0.99.2 at in-7.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-7.smtp.seeweb.it Subject: [LTP] [RFC PATCH v2 2/3] network/interface: Cleanup if4-addr-change 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" Wrap test code into function. This is preparation for next commit. Signed-off-by: Petr Vorel --- testcases/network/stress/interface/if4-addr-change | 60 ++++++++++++---------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/testcases/network/stress/interface/if4-addr-change b/testcases/network/stress/interface/if4-addr-change index dbb3d3356..30f3bbbb4 100644 --- a/testcases/network/stress/interface/if4-addr-change +++ b/testcases/network/stress/interface/if4-addr-change @@ -36,42 +36,48 @@ do_cleanup() trap "tst_brkm TBROK 'test interrupted'" INT -tst_check_cmds ifconfig +test_body() +{ + local cnt=0 + local num=1 + local add_to_net= + + tst_resm TINFO "ifconfig changes IPv4 address $NS_TIMES times" -tst_resm TINFO "ifconfig changes IPv4 address $NS_TIMES times" + while [ $cnt -lt $NS_TIMES ]; do + # Define the network portion + num=$(($num + 1)) + [ $num -gt $LHOST_IPV4_HOST_MAX ] && num=1 -cnt=0 -num=1 -while [ $cnt -lt $NS_TIMES ]; do - # Define the network portion - num=$(($num + 1)) - [ $num -gt $LHOST_IPV4_HOST_MAX ] && num=1 + [ $num -eq $RHOST_IPV4_HOST ] && continue - [ $num -eq $RHOST_IPV4_HOST ] && continue + # check prefix and fix values for prefix != 24 + add_to_net= + if [ $IPV4_LPREFIX -lt 8 -o $IPV4_LPREFIX -ge 32 ] ; then + tst_brkm TCONF "test must be with prefix >= 8 and prefix < 32 ($IPV4_LPREFIX)" + elif [ $IPV4_LPREFIX -lt 16 ]; then # N.x.x.num + add_to_net=".0.1" + elif [ $IPV4_LPREFIX -lt 24 ]; then # N.N.x.num + add_to_net=".1" + fi - # check prefix and fix values for prefix != 24 - add_to_net= - if [ $IPV4_LPREFIX -lt 8 -o $IPV4_LPREFIX -ge 32 ] ; then - tst_brkm TCONF "test must be with prefix >= 8 and prefix < 32 ($IPV4_LPREFIX)" - elif [ $IPV4_LPREFIX -lt 16 ]; then # N.x.x.num - add_to_net=".0.1" - elif [ $IPV4_LPREFIX -lt 24 ]; then # N.N.x.num - add_to_net=".1" - fi + # Change IPv4 address + ROD ifconfig $(tst_iface) ${IPV4_LNETWORK}${add_to_net}.${num} netmask \ + $IPV4_LNETMASK broadcast $IPV4_LBROADCAST - # Change IPv4 address - ROD ifconfig $(tst_iface) ${IPV4_LNETWORK}${add_to_net}.${num} netmask \ - $IPV4_LNETMASK broadcast $IPV4_LBROADCAST + cnt=$(($cnt + 1)) - cnt=$(($cnt + 1)) + [ $CHECK_INTERVAL -eq 0 ] && continue + [ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue - [ $CHECK_INTERVAL -eq 0 ] && continue - [ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue + tst_resm TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES" + tst_ping + done - tst_resm TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES" tst_ping -done +} -tst_ping +tst_check_cmds ifconfig +test_body tst_exit