From patchwork Fri Mar 9 14:22:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harsha Sharma X-Patchwork-Id: 883661 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ptyRkZBl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zyV3L3Lf7z9sbX for ; Sat, 10 Mar 2018 01:23:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751120AbeCIOXJ (ORCPT ); Fri, 9 Mar 2018 09:23:09 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33725 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbeCIOXI (ORCPT ); Fri, 9 Mar 2018 09:23:08 -0500 Received: by mail-pf0-f195.google.com with SMTP id q13so1338845pff.0 for ; Fri, 09 Mar 2018 06:23:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xHciSrU4MWqBGq1eBKXKQCSYVb0ICdRn4hUt2p20tao=; b=ptyRkZBlW4xsVEIw3O4mSf9qKEuRGUUqy6vLZ77VZgY7LFzhywOPqE6pjCCv2F+GYB m4zN426Tz5xKSdKjNy61keO00Oii7HoVzxsaiRQGblggeZjIAfylHmk4ZH4QGRmHdlA5 MLfo+FgW0sAd50wrrwelLjpdr+CcIPfiFChBd7FDTgsjzbGsI+5hDwCIint3E19sz40t ber8jALMBELoQn2zSp3m9KNLfVM/SX6AN7bbXaU70BUy14W0YjGdSytU7tzOBRXFPNoh NBZn8BmcJMdV/u7QIaNlAAqVvefqoUEELS/m//qiuNlctsH+VuELQyOMAvFxtBw8Xc+J vMNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xHciSrU4MWqBGq1eBKXKQCSYVb0ICdRn4hUt2p20tao=; b=ELAOeGSUixyhm2apzJfBc1eguWcO+Qw/zX79e6Yzazmex11JeQQR1BdiclMM2LONV5 3YA7XMzj0FSBujZ3zi501ncDOJpvJBLY1Bun0yQ9CNg86Xtbv5tg4En3NZCRHLwq2St+ wluQl/JL5QLiDeB1pX/M+7Smh9Mid7BCoGcwMhvUmDDgqrY3I9cGjk1PaJ7AuemYYqSn 57dUT+LAcv/z+nK4Ol6Z7qP+aADMppehIBRb2JxFS9hErflHfwFQ9OgU4O9ccChIxys1 9st3tF1o7IQq2wDjFoLLD8FQOx0WNDjfb2yS4L0Psh5OxXjvYNsU73bukCzAIjyHjqd/ YcOg== X-Gm-Message-State: APf1xPDXQJ3+RLodVow8KN16cpehNoGe+FyoWNo+hhmadeXf/IOTgqHN RfPhmCI6xefOQOfB5KNhMKg= X-Google-Smtp-Source: AG47ELtBq5JdMb/LnLsda+A2FJQb2KB3uLkO/bwVbVlIN+DPi3zIe3BQzPZAH1QOOWPKgjOQIs70lA== X-Received: by 10.99.173.3 with SMTP id g3mr25180326pgf.213.1520605387875; Fri, 09 Mar 2018 06:23:07 -0800 (PST) Received: from XDDDDD.iitr.ernet.in ([103.37.201.27]) by smtp.gmail.com with ESMTPSA id t14sm3513848pfa.178.2018.03.09.06.23.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 06:23:07 -0800 (PST) From: Harsha Sharma To: pablo@netfilter.org, harshasharmaiitr@gmail.com Cc: netfilter-devel@vger.kernel.org Subject: [PATCH] tests: shell: fix tests for deletion via handle attribute Date: Fri, 9 Mar 2018 19:52:28 +0530 Message-Id: <20180309142228.9686-1-harshasharmaiitr@gmail.com> X-Mailer: git-send-email 2.14.1 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Fetch object, chain and set handles and with '-a' option and then delete them. Signed-off-by: Harsha Sharma --- tests/shell/testcases/chains/0016delete_handle_0 | 20 ++++++----- .../testcases/optionals/delete_object_handles_0 | 39 ++++++++++++---------- tests/shell/testcases/sets/0028delete_handle_0 | 12 ++++--- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/tests/shell/testcases/chains/0016delete_handle_0 b/tests/shell/testcases/chains/0016delete_handle_0 index cf11da8..32f36e5 100755 --- a/tests/shell/testcases/chains/0016delete_handle_0 +++ b/tests/shell/testcases/chains/0016delete_handle_0 @@ -2,15 +2,19 @@ set -e $NFT add table test-ip -$NFT add chain test-ip x # should have handle 1 -$NFT add chain test-ip y # should have handle 2 -$NFT add chain test-ip z # should have handle 3 +$NFT add chain test-ip x +$NFT add chain test-ip y +$NFT add chain test-ip z $NFT add table ip6 test-ip6 -$NFT add chain ip6 test-ip6 x # should have handle 1 -$NFT add chain ip6 test-ip6 y # should have handle 2 -$NFT add chain ip6 test-ip6 z # should have handle 3 -$NFT delete chain test-ip handle 2 -$NFT delete chain ip6 test-ip6 handle 3 +$NFT add chain ip6 test-ip6 x +$NFT add chain ip6 test-ip6 y +$NFT add chain ip6 test-ip6 z + +chain_y_handle=$($NFT list ruleset -a | awk -v n=1 '/chain y/ && !--n {print $NF; exit}'); +chain_z_handle=$($NFT list ruleset -a | awk -v n=2 '/chain z/ && !--n {print $NF; exit}'); + +$NFT delete chain test-ip handle $chain_y_handle +$NFT delete chain ip6 test-ip6 handle $chain_z_handle EXPECTED="table ip test-ip { chain x { diff --git a/tests/shell/testcases/optionals/delete_object_handles_0 b/tests/shell/testcases/optionals/delete_object_handles_0 index 355de5f..d5d9654 100755 --- a/tests/shell/testcases/optionals/delete_object_handles_0 +++ b/tests/shell/testcases/optionals/delete_object_handles_0 @@ -2,36 +2,39 @@ set -e $NFT add table test-ip -$NFT add counter test-ip https-traffic # should have handle 1 -$NFT add quota test-ip https-quota 25 mbytes # should have handle 2 -$NFT add map test-ip ports { type inet_service : quota \; } # should have handle 3 +$NFT add counter test-ip https-traffic +$NFT add quota test-ip https-quota 25 mbytes +$NFT add map test-ip ports { type inet_service : quota \; } $NFT add table ip6 test-ip6 -$NFT add quota ip6 test-ip6 http-quota over 25 mbytes # should have handle 1 -$NFT add counter ip6 test-ip6 http-traffic # should have handle 2 -$NFT add quota ip6 test-ip6 ssh-quota 10 mbytes # should have handle 3 -$NFT delete counter test-ip handle 1 -$NFT delete quota ip6 test-ip6 handle 3 +$NFT add quota ip6 test-ip6 http-quota over 25 mbytes +$NFT add counter ip6 test-ip6 http-traffic +$NFT add quota ip6 test-ip6 ssh-quota 10 mbytes + +counter_handle=$($NFT list ruleset -a | awk '/https-traffic/{print $NF}') +quota_handle=$($NFT list ruleset -a | awk '/ssh-quota/{print $NF}') +$NFT delete counter test-ip handle $counter_handle +$NFT delete quota ip6 test-ip6 handle $quota_handle EXPECTED="table ip test-ip { quota https-quota { - 25 mbytes used 2 bytes - } # handle 2 + 25 mbytes + } map ports { type inet_service : quota - } # handle 3 -} # handle 1 + } +} table ip6 test-ip6 { quota http-quota { - over 25 mbytes used 1 bytes - } # handle 1 + over 25 mbytes + } counter http-traffic { - packets 0 bytes 2 - } # handle 2 -} # handle 2" + packets 0 bytes 0 + } +}" -GET="$($NFT list ruleset -a)" +GET="$($NFT list ruleset)" if [ "$EXPECTED" != "$GET" ] ; then DIFF="$(which diff)" diff --git a/tests/shell/testcases/sets/0028delete_handle_0 b/tests/shell/testcases/sets/0028delete_handle_0 index 215323c..ce24093 100755 --- a/tests/shell/testcases/sets/0028delete_handle_0 +++ b/tests/shell/testcases/sets/0028delete_handle_0 @@ -2,11 +2,13 @@ set -e $NFT add table test-ip -$NFT add set test-ip x { type ipv4_addr\; } # should have handle 1 -$NFT add set test-ip y { type inet_service \; timeout 3h45s \;} # should have handle 2 -$NFT add set test-ip z { type ipv4_addr\; flags constant , interval\;} # should have handle 3 -$NFT add set test-ip c {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;} #should have handle 4 -$NFT delete set test-ip handle 4 +$NFT add set test-ip x { type ipv4_addr\; } +$NFT add set test-ip y { type inet_service \; timeout 3h45s \;} +$NFT add set test-ip z { type ipv4_addr\; flags constant , interval\;} +$NFT add set test-ip c {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;} + +set_handle=$($NFT list ruleset -a | awk '/set\ c/{print $NF)') +$NFT delete set test-ip handle $set_handle EXPECTED="table ip test-ip { set x {