netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH 4/9] tests: shell: Extend zero counters test a bit further
Date: Wed,  8 Jun 2022 18:27:07 +0200	[thread overview]
Message-ID: <20220608162712.31202-5-phil@nwl.cc> (raw)
In-Reply-To: <20220608162712.31202-1-phil@nwl.cc>

Test zeroing a single rule's counters as well.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 .../shell/testcases/iptables/0007-zero-counters_0 | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/iptables/tests/shell/testcases/iptables/0007-zero-counters_0 b/iptables/tests/shell/testcases/iptables/0007-zero-counters_0
index 36da1907e3b22..2179347200854 100755
--- a/iptables/tests/shell/testcases/iptables/0007-zero-counters_0
+++ b/iptables/tests/shell/testcases/iptables/0007-zero-counters_0
@@ -10,6 +10,7 @@ $XT_MULTI iptables-restore -c <<EOF
 [12:345] -A INPUT -i lo -p icmp -m comment --comment "$COUNTR"
 [22:123] -A FOO -m comment --comment one
 [44:123] -A FOO -m comment --comment two
+[66:123] -A FOO -m comment --comment three
 COMMIT
 EOF
 EXPECT="*filter
@@ -20,6 +21,7 @@ EXPECT="*filter
 [0:0] -A INPUT -i lo -p icmp -m comment --comment "$COUNTR"
 [0:0] -A FOO -m comment --comment one
 [0:0] -A FOO -m comment --comment two
+[0:0] -A FOO -m comment --comment three
 COMMIT"
 
 COUNTER=$($XT_MULTI iptables-save -c |grep "comment $COUNTR"| cut -f 1 -d " ")
@@ -28,6 +30,18 @@ if [ $COUNTER != "[12:345]" ]; then
 	RC=1
 fi
 
+$XT_MULTI iptables -Z FOO 2
+COUNTER=$($XT_MULTI iptables-save -c | grep "comment two"| cut -f 1 -d " ")
+if [ $COUNTER != "[0:0]" ]; then
+	echo "Counter $COUNTER is wrong, should have been zeroed"
+	RC=1
+fi
+COUNTER=$($XT_MULTI iptables-save -c | grep "comment three"| cut -f 1 -d " ")
+if [ $COUNTER != "[66:123]" ]; then
+	echo "Counter $COUNTER is wrong, should not have been zeroed"
+	RC=1
+fi
+
 $XT_MULTI iptables -Z FOO
 COUNTER=$($XT_MULTI iptables-save -c |grep "comment $COUNTR"| cut -f 1 -d " ")
 if [ $COUNTER = "[0:0]" ]; then
@@ -60,5 +74,6 @@ fi
 $XT_MULTI iptables -D INPUT -i lo -p icmp -m comment --comment "$COUNTR"
 $XT_MULTI iptables -D FOO -m comment --comment one
 $XT_MULTI iptables -D FOO -m comment --comment two
+$XT_MULTI iptables -D FOO -m comment --comment three
 $XT_MULTI iptables -X FOO
 exit $RC
-- 
2.34.1


  parent reply	other threads:[~2022-06-08 16:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 16:27 [iptables PATCH 0/9] Improve testsuites' code coverage Phil Sutter
2022-06-08 16:27 ` [iptables PATCH 1/9] Makefile: Add --enable-profiling configure option Phil Sutter
2022-06-08 16:27 ` [iptables PATCH 2/9] tests: shell: Add some more rules to 0002-verbose-output_0 Phil Sutter
2022-06-08 16:27 ` [iptables PATCH 3/9] tests: shell: Extend iptables-xml test a bit Phil Sutter
2022-06-08 16:27 ` Phil Sutter [this message]
2022-06-08 16:27 ` [iptables PATCH 5/9] extensions: libebt_standard.t: Test logical-{in,out} as well Phil Sutter
2022-06-08 16:27 ` [iptables PATCH 6/9] ebtables-restore: Deny --init-table Phil Sutter
2022-06-08 16:27 ` [iptables PATCH 7/9] extensions: string: Do not print default --to value Phil Sutter
2022-06-08 16:27 ` [iptables PATCH 8/9] extensions: string: Review parse_string() function Phil Sutter
2022-06-08 16:27 ` [iptables PATCH 9/9] extensions: string: Fix and enable tests Phil Sutter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608162712.31202-5-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).