public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Eryu Guan <eguan@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH v3 1/7] overlay/018: re-factor and add to hardlink group
Date: Wed,  5 Jul 2017 15:02:00 +0300	[thread overview]
Message-ID: <1499256126-21866-2-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1499256126-21866-1-git-send-email-amir73il@gmail.com>

Use helpers to records and check inode numbers so we can repeat
the same test after each hardlink copy up and mount cycle.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/overlay/018   | 33 +++++++++++++++++++++++++--------
 tests/overlay/group |  2 +-
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/tests/overlay/018 b/tests/overlay/018
index 7e47732..527b9d1 100755
--- a/tests/overlay/018
+++ b/tests/overlay/018
@@ -61,25 +61,42 @@ echo "patient zero" >> $lowerdir/foo
 ln $lowerdir/foo $lowerdir/bar
 
 
+# Record inode numbers in format <ino> <nlink>
+function record_ino_nlink()
+{
+	ls -li $FILES | awk '{ print $1, $3 }' > $1
+}
+
+# Check inode numbers match recorded inode numbers
+function check_ino_nlink()
+{
+	before=$1
+	after=$2
+
+	record_ino_nlink $after
+
+	# Test constant stat(2) st_ino/st_nlink -
+	#   Compare before..after - expect silence
+	# We use diff -u so out.bad will tell us which stage failed
+	diff -u $before $after
+}
+
 _scratch_mount
 
 
-rm -f $tmp.before $tmp.after
+rm -f $tmp.*
 
 foo=$SCRATCH_MNT/foo
 bar=$SCRATCH_MNT/bar
 
-# Record inode number and nlink before copy up
-ls -li $foo $bar | awk '{ print $1, $3 }' > $tmp.before
+FILES="$foo $bar"
+
+record_ino_nlink $tmp.before
 
 # Modify content of one of the hardlinks
 echo "mutated" >> $foo
 
-# Record inode number and nlink after copy up
-ls -li $foo $bar | awk '{ print $1, $3 }' > $tmp.after
-
-# Compare ino/nlink before..after - expect silence
-diff $tmp.before $tmp.after
+check_ino_nlink $tmp.before $tmp.after
 
 # Compare content of files - expect silence
 diff $foo $bar
diff --git a/tests/overlay/group b/tests/overlay/group
index 64d200c..28df5b6 100644
--- a/tests/overlay/group
+++ b/tests/overlay/group
@@ -20,7 +20,7 @@
 015 auto quick whiteout
 016 auto quick copyup
 017 auto quick copyup
-018 auto quick copyup
+018 auto quick copyup hardlink
 019 auto stress
 020 auto quick copyup perms
 021 auto quick copyup
-- 
2.7.4


  reply	other threads:[~2017-07-05 12:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 12:01 [PATCH v3 0/7] overlay hardlink tests Amir Goldstein
2017-07-05 12:02 ` Amir Goldstein [this message]
2017-07-05 12:02 ` [PATCH v3 2/7] overlay/018: print hardlink content to golden output Amir Goldstein
2017-07-05 12:02 ` [PATCH v3 3/7] overlay/018: test broken hardlinks after mount cycle Amir Goldstein
2017-07-05 12:02 ` [PATCH v3 4/7] overlay/018: test lower hardlinks re-unite on copy up Amir Goldstein
2017-07-05 12:02 ` [PATCH v3 5/7] overlay: test concurrent copy up of lower hardlinks Amir Goldstein
2017-07-05 12:02 ` [PATCH v3 6/7] overlay: test nlink accounting of overlay hardlinks Amir Goldstein
2017-07-05 12:02 ` [PATCH v3 7/7] overlay: test dropping nlink below zero Amir Goldstein

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=1499256126-21866-2-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=eguan@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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