Skip to contentSkip to conversation

xfstests: introduce 280 for SEEK_DATA/SEEK_HOLE copy test

PATCH In review Jeff Liu 1 participant 1 message Feb 19, 2012

lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH v3 2/2 xfstests: introduce 280 for SEEK_DATA/SEEK_HOLE copy test

Introduce 280 for SEEK_DATA/SEEK_HOLE copy tests.

Thanks Dave's suggestions for V2. :)

Changes to v3:
--------------
* Using xfs_io(8) to create sparse file, seek_copy_test was modified to only do extents copy accordingly.
* Redirect xfs_io(8) output to 280.full.
* Supplied two test cases for now. The first test case is focus on copy a sparse file with written data and hole extents. The 2nd test case is focus on copy a sparse file with written, unwritten data as well as hole extents. I would continue to improve this tests when implementing the unwritten extents probe routine.

---
 280                  |  114 +++++++++++++++++++++++
 280.full             |   70 ++++++++++++++
 280.out              |    1 +
 group                |    1 +
 src/Makefile         |    3 +-
 src/seek_copy_test.c |  252 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 440 insertions(+), 1 deletions(-)
 create mode 100755 280
 create mode 100644 280.full
 create mode 100644 280.out
 create mode 100644 src/seek_copy_test.c
280 new file +114 -0
new file mode 100755
index 0000000..0cbe5fe
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FS QA Test No. 280
+#
+# SEEK_DATA/SEEK_HOLE copy tests.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2011 Oracle Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+#-----------------------------------------------------------------------
+#
+# creator
[email protected]
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+src=$TEST_DIR/seek_copy_testfile
+dest=$TEST_DIR/seek_copy_testfile.dest
+
+[ -x $here/src/seek_copy_test ] || _notrun "seek_copy_test not built"
+
+_cleanup()
+{
+	rm -f $src $dest
+}
+
+# seek_copy_test_01: tests file with holes and written data extents.
+# verify results:
+# 1. file size is identical.
+# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
+test01()
+{
+	rm -f $src $dest
+
+	write_cmd="-c \"truncate 100m\""
+	for i in $(seq 0 5 100); do
+		offset=$(($i * $((1 << 20))))
+		write_cmd="$write_cmd -c \"pwrite $offset 1m\""
+	done
+
+	echo "*** test01() create sparse file ***" >>$seq.full
+	eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
+		_fail "create sparse file failed!"
+	echo "*** test01() create sparse file done ***" >>$seq.full
+	echo >>$seq.full
+
+	$here/src/seek_copy_test $src $dest
+	
+	test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
+		_fail "TEST01: file size check failed"
+
+	cmp $src $dest || _fail "TEST01: file bytes check failed"
+}
+
+# seek_copy_test_02 - tests file with holes, written and unwritten extents.
+# verify results:
+# 1. file size is identical.
+# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
+test02()
+{
+	rm -rf $src $dest
+
+	write_cmd="-c \"truncate 200m\""
+	for i in $(seq 0 10 100); do
+		offset=$(($((6 << 20)) + $i * $((1 << 20))))
+		write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
+	done
+
+	echo "*** test02() create sparse file ***" >>$seq.full
+	eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
+		_fail "create sparse file failed!"
+	echo "*** test02() create sparse file done ***" >>$seq.full
+	echo >>$seq.full
+
+	$here/src/seek_copy_test $src $dest
+
+	test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
+		_fail "TEST02: file size check failed"
+
+	cmp $src $dest || _fail "TEST02: file bytes check failed"
+}
+
+rm -f $seq.full
+
+test01
+test02
+
+status=0
+exit
280.full new file +70 -0

70 lines not on this page · raw message

280.out new file +1 -0
new file mode 100644
index 0000000..fb29270
@@ -0,0 +1 @@
+QA output created by 280
group +1 -0
index 02c6743..5d197ee 100644
@@ -390,3 +390,4 @@ deprecated
 274 auto rw
 275 auto rw
 279 auto rw
+280 other
src/Makefile +2 -1
index 1c6e717..d269e91 100644
@@ -17,7 +17,8 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
 	locktest unwritten_mmap bulkstat_unlink_test t_stripealign \
 	bulkstat_unlink_test_modified t_dir_offset t_futimens t_immutable \
-	stale_handle pwrite_mmap_blocked fstrim t_dir_offset2 seek_sanity_test
+	stale_handle pwrite_mmap_blocked fstrim t_dir_offset2 seek_sanity_test \
+	seek_copy_test
 
 SUBDIRS =
 
src/seek_copy_test.c new file +252 -0

252 lines not on this page · raw message

Signature · 6 lines
1.7.9

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs