All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: kadlec@netfilter.org
Cc: <netfilter-devel@vger.kernel.org>, Florian Westphal <fw@strlen.de>
Subject: [PATCH ipset 3/5] tests: prefer diff -u to cmp
Date: Thu, 23 Jul 2026 12:35:02 +0200	[thread overview]
Message-ID: <20260723103504.3175-4-fw@strlen.de> (raw)
In-Reply-To: <20260723103504.3175-1-fw@strlen.de>

Irrelevant when things are working as expected, but is beneficial when they
are not: diff -u is much easier to decipher than: "differ, byte x line y"

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 tests/iphash.t  | 8 ++++----
 tests/restore.t | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/iphash.t b/tests/iphash.t
index c7c0b081e34a..e4386bbf6f52 100644
--- a/tests/iphash.t
+++ b/tests/iphash.t
@@ -33,13 +33,13 @@
 # IP: Restore values so that rehashing is triggered, old format
 0 ipset -R < iphash.t.restore.old
 # IP: Check that all values are restored
-0 (grep add iphash.t.restore | sort > "$IPSET_TMP/.foo.1") && (ipset -S test | grep add | sort > "$IPSET_TMP/.foo.2") && cmp "$IPSET_TMP/"{.foo.1,.foo.2}
+0 (grep add iphash.t.restore | sort > "$IPSET_TMP/.foo.1") && (ipset -S test | grep add | sort > "$IPSET_TMP/.foo.2") && diff -u "$IPSET_TMP/"{.foo.1,.foo.2}
 # IP: Delete test set
 0 ipset -X test
 # IP: Restore values so that rehashing is triggered
 0 ipset -R < iphash.t.restore
 # IP: Check that all values are restored
-0 (grep add iphash.t.restore | sort > "$IPSET_TMP/.foo.1") && (ipset -S test | grep add | sort > "$IPSET_TMP/.foo.2") && cmp "$IPSET_TMP/"{.foo.1,.foo.2}
+0 (grep add iphash.t.restore | sort > "$IPSET_TMP/.foo.1") && (ipset -S test | grep add | sort > "$IPSET_TMP/.foo.2") && diff -u "$IPSET_TMP/"{.foo.1,.foo.2}
 # IP: Flush test set
 0 ipset -F test
 # IP: Delete test set
@@ -55,7 +55,7 @@
 # IP: Save sets
 0 ipset -s -f "$IPSET_TMP/.foo0" save && ./ignore.sh "$IPSET_TMP/.foo0"
 # IP: Compare sorted save and restore
-0 cmp "$IPSET_TMP/.foo" iphash.t.restore.sorted
+0 diff -u "$IPSET_TMP/.foo" iphash.t.restore.sorted
 # IP: Delete test set
 0 ipset x test
 # IP: Delete test2 set
@@ -65,7 +65,7 @@
 # IP: Save the restored set
 0 (ipset save test | sort > "$IPSET_TMP/.foo.1") && ./ignore.sh "$IPSET_TMP/.foo.1"
 # IP: Compare save and restore
-0 (sort iphash.t.large > "$IPSET_TMP/.foo.2") && (cmp "$IPSET_TMP/.foo" "$IPSET_TMP/.foo.2")
+0 (sort iphash.t.large > "$IPSET_TMP/.foo.2") && (diff -u "$IPSET_TMP/.foo" "$IPSET_TMP/.foo.2")
 # IP: Delete all elements, one by one
 0 ipset list test | sed '1,/Members/d' | xargs -n1 ipset del test
 # IP: Delete test set
diff --git a/tests/restore.t b/tests/restore.t
index 02da4465af94..dddd72481784 100644
--- a/tests/restore.t
+++ b/tests/restore.t
@@ -1,7 +1,7 @@
 # Check multi-set restore
 0 ipset restore < restore.t.multi
 # Save sets and compare
-0 ipset save > "$IPSET_TMP/.foo" && diff restore.t.multi.saved "$IPSET_TMP/.foo"
+0 ipset save > "$IPSET_TMP/.foo" && diff -u restore.t.multi.saved "$IPSET_TMP/.foo"
 # Delete all sets
 0 ipset x
 # Check auto-increasing maximal number of sets
-- 
2.54.0


  parent reply	other threads:[~2026-07-23 10:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 10:34 [PATCH ipset 0/5] ipset test updates Florian Westphal
2026-07-23 10:35 ` [PATCH ipset 1/5] tests: check_extensions: introduce and use IPSET_MACHINE_SLOW Florian Westphal
2026-07-23 10:35 ` [PATCH ipset 2/5] tests: hash:net.t: prefer tail -n Florian Westphal
2026-07-23 10:35 ` Florian Westphal [this message]
2026-07-23 10:35 ` [PATCH ipset 4/5] tests: hash:net,iface.t: add reproducer for UaF Florian Westphal
2026-07-23 10:35 ` [PATCH ipset 5/5] tests: match_target.t check for proper cidr matching Florian Westphal

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=20260723103504.3175-4-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.