linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org,
	Lukas Czerner <lczerner@redhat.com>
Subject: [PATCH 2/8] xfstests: create _test_block_boundaries in common/punch
Date: Fri, 28 Feb 2014 17:10:59 +0100	[thread overview]
Message-ID: <1393603865-26198-2-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1393603865-26198-1-git-send-email-lczerner@redhat.com>

Create new function _test_block_boundaries() which is testing content of
the blocks after the operation such as zero, or punch hole. The test is
doing the operation around block boundaries to assure correct behaviour
of the operation on block unaligned ranges.

This has been based on test xfs/290 which has been changed to use this
new function. A small change to the output file was required.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 common/punch      | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/290     |  40 ++-------------------
 tests/xfs/290.out |  13 +++++--
 3 files changed, 119 insertions(+), 40 deletions(-)

diff --git a/common/punch b/common/punch
index 9340d3b..f2d538c 100644
--- a/common/punch
+++ b/common/punch
@@ -566,3 +566,109 @@ _test_generic_punch()
 	[ $? -ne 0 ] && die_now
 	od -x $testfile | head -n -1
 }
+
+_test_block_boundaries()
+{
+
+	remove_testfile=1
+	sync_cmd="-c fsync"
+	unwritten_tests=1
+	OPTIND=1
+	while getopts 'dk' OPTION
+	do
+		case $OPTION in
+		k)	remove_testfile=
+		;;
+		d)	sync_cmd=
+		;;
+		?)	echo Invalid flag
+		exit 1
+		;;
+		esac
+	done
+	shift $(($OPTIND - 1))
+
+	bs=$1
+	zero_cmd=$2
+	filter_cmd=$3
+	testfile=$4
+
+	# Block size plus 1
+	bs_p1=$(($bs + 1))
+	# Block size plus 2
+	bs_p2=$(($bs + 2))
+
+	# Block size minus 1
+	bs_m1=$(($bs - 1))
+
+	# Block size multiplied by 2
+	bs_t2=$(($bs * 2))
+
+	# Block size divided by 2
+	bs_d2=$(($bs / 2))
+
+	echo "zero 0, 1"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd 0 1" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+
+	echo "zero 0, $bs_m1"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd 0 $bs_m1" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+
+	echo "zero 0, $bs"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd 0 $bs" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+
+	echo "zero 0, $bs_p1"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd 0 $bs_p1" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+
+	echo "zero $bs_m1, $bs"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd $bs_m1 $bs" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+
+	echo "zero $bs_m1, $bs_p1"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd $bs_m1 $bs_p1" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+
+	echo "zero $bs_m1, $bs_p2"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd $bs_m1 $bs_p2" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+
+
+	echo "zero $bs, $bs"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd $bs $bs" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+
+
+	echo "zero $bs_d2 , $bs"
+	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 $bs" \
+			   -c "pwrite -S 0x42 $bs $bs" \
+			   -c "$zero_cmd $bs_d2 $bs" \
+			   -c "pread -v 0 $bs_t2" \
+			   $testfile | $filter_cmd
+}
diff --git a/tests/xfs/290 b/tests/xfs/290
index 547a0ba..cbe7108 100755
--- a/tests/xfs/290
+++ b/tests/xfs/290
@@ -38,6 +38,7 @@ trap "exit \$status" 0 1 2 3 15
 # get standard environment, filters and checks
 . ./common/rc
 . ./common/filter
+. ./common/punch
 
 # real QA test starts here
 
@@ -49,44 +50,7 @@ _require_xfs_io_zero
 
 testfile=$TEST_DIR/290.$$
 
-test_zero()
-{
-	zero_start=$1
-	zero_len=$2
-
-	$XFS_IO_PROG -f -t -c "pwrite -S 0x41 0 4096" \
-                      -c "pwrite -S 0x42 4096 4096" \
-                      -c "zero $zero_start $zero_len" \
-                      -c "pread -v 0 8192" \
-                      $testfile | _filter_xfs_io_unique
-}
-
-# [0,1] -- Shouldn't toss anything
-test_zero    0    1
-
-#[0,4095] -- Shouldn't toss anything
-test_zero    0 4095
-
-#[0,4096] -- Should toss first page
-test_zero    0 4096
-
-#[0,4097] -- Should toss first page
-test_zero    0 4097
-
-#[4095,8191] -- Should toss last byte of first page
-test_zero 4095 4096
-
-#[4095,8192] -- Should toss second page & last byte of first page
-test_zero 4095 4097
-
-#[4095,8193] -- Should toss second page & last byte of first page
-test_zero 4095 4098
-
-#[4096,8192] -- Should toss second page
-test_zero 4096 4096
-
-#[1024,5120] -- Should toss from 1024 to end of first page
-test_zero 1024 4096
+_test_block_boundaries 4096 zero _filter_xfs_io_unique $testfile
 
 # success, all done
 status=0
diff --git a/tests/xfs/290.out b/tests/xfs/290.out
index 229c2b3..2487a93 100644
--- a/tests/xfs/290.out
+++ b/tests/xfs/290.out
@@ -1,4 +1,5 @@
 QA output created by 290
+zero 0, 1
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
@@ -10,6 +11,7 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+zero 0, 4095
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
@@ -21,6 +23,7 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+zero 0, 4096
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
@@ -31,6 +34,7 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+zero 0, 4097
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
@@ -42,6 +46,7 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+zero 4095, 4096
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
@@ -54,6 +59,7 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 00001ff0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42  ...............B
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+zero 4095, 4097
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
@@ -65,6 +71,7 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+zero 4095, 4098
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
@@ -76,6 +83,7 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+zero 4096, 4096
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
@@ -86,15 +94,16 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+zero 2048 , 4096
 wrote 4096/4096 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 4096/4096 bytes at offset 4096
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 00000000:  41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA
 *
-00000400:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
+00000800:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 *
-00001400:  42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42  BBBBBBBBBBBBBBBB
+00001800:  42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42  BBBBBBBBBBBBBBBB
 *
 read 8192/8192 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-- 
1.8.3.1


  reply	other threads:[~2014-02-28 16:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 16:10 [PATCH 1/8] xfstests: Create single function for testing xfs_io commands Lukas Czerner
2014-02-28 16:10 ` Lukas Czerner [this message]
2014-02-28 16:11 ` [PATCH 3/8] generic/008: Add test for fallocate zero range at block boundary Lukas Czerner
2014-02-28 16:11 ` [PATCH 4/8] xfstests: Move fallocate include into global.h Lukas Czerner
2014-02-28 17:17   ` Eric Sandeen
2014-02-28 22:31     ` Dave Chinner
2014-02-28 16:11 ` [PATCH 5/8] xfstests: Add fallocate zero range operation to fsstress Lukas Czerner
2014-02-28 17:40   ` Eric Sandeen
2014-03-03 12:16     ` Lukáš Czerner
2014-02-28 16:11 ` [PATCH 6/8] fsstress: translate flags in fiemap_f Lukas Czerner
2014-02-28 17:55   ` Eric Sandeen
2014-02-28 16:11 ` [PATCH 7/8] xfstests: Add fallocate zero range operation to fsx Lukas Czerner
2014-02-28 18:11   ` Eric Sandeen
2014-02-28 19:08   ` Andreas Dilger
2014-03-03 12:21     ` Lukáš Czerner
2014-02-28 16:11 ` [PATCH 8/8] ext4/001: Add ext4 specific test for fallocate zero range Lukas Czerner
2014-02-28 16:40 ` [PATCH 1/8] xfstests: Create single function for testing xfs_io commands Eric Sandeen
2014-02-28 16:51   ` Lukáš Czerner

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=1393603865-26198-2-git-send-email-lczerner@redhat.com \
    --to=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /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).