diff mbox

[v2,1/8] xfstests: Create single function for testing xfs_io commands

Message ID 1394034699-21187-2-git-send-email-lczerner@redhat.com
State Not Applicable, archived
Headers show

Commit Message

Lukas Czerner March 5, 2014, 3:51 p.m. UTC
Currently there are several function testing various xfs_io commands.
This commit creates _require_xfs_io_command() to test any xfs_command.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 common/rc | 72 +++++++++++++++++++++++++++++++++------------------------------
 1 file changed, 38 insertions(+), 34 deletions(-)

Comments

Christoph Hellwig March 6, 2014, 5:44 p.m. UTC | #1
On Wed, Mar 05, 2014 at 04:51:32PM +0100, Lukas Czerner wrote:
> Currently there are several function testing various xfs_io commands.
> This commit creates _require_xfs_io_command() to test any xfs_command.

Looks good.  Do you plan to keep the wrappers around
_require_xfs_io_command in the long run or just for a transitional
period?

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukas Czerner March 6, 2014, 5:57 p.m. UTC | #2
On Thu, 6 Mar 2014, Christoph Hellwig wrote:

> Date: Thu, 6 Mar 2014 09:44:20 -0800
> From: Christoph Hellwig <hch@infradead.org>
> To: Lukas Czerner <lczerner@redhat.com>
> Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com
> Subject: Re: [PATCH v2 1/8] xfstests: Create single function for testing
>     xfs_io commands
> 
> On Wed, Mar 05, 2014 at 04:51:32PM +0100, Lukas Czerner wrote:
> > Currently there are several function testing various xfs_io commands.
> > This commit creates _require_xfs_io_command() to test any xfs_command.
> 
> Looks good.  Do you plan to keep the wrappers around
> _require_xfs_io_command in the long run or just for a transitional
> period?

I didn't really want to go back and change all the callers, but it
can be done eventually. I do not have any strong opinions either
way.

> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks!
-Lukas

> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/common/rc b/common/rc
index f2c3c3a..7f530d0 100644
--- a/common/rc
+++ b/common/rc
@@ -1296,12 +1296,43 @@  _user_do()
     fi
 }
 
+_require_xfs_io_command()
+{
+	if [ $# -ne 1 ]
+	then
+		echo "Usage: _require_xfs_io_command command" 1>&2
+		exit 1
+	fi
+	command=$1
+
+	testfile=$TEST_DIR/$$.xfs_io
+	case $command in
+	"falloc" )
+		testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
+		;;
+	"fpunch" | "fcollapse" | "zero" )
+		testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
+			-c "$command 4k 8k" $testfile 2>&1`
+		;;
+	"fiemap")
+		testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
+			-c "fiemap -v" $testfile 2>&1`
+		;;
+	*)
+		testio=`$XFS_IO_PROG -c "$command help" 2>&1`
+	esac
+
+	rm -f $testfile 2>&1 > /dev/null
+	echo $testio | grep -q "not found" && \
+		_notrun "xfs_io $command support is missing"
+	echo $testio | grep -q "Operation not supported" && \
+		_notrun "xfs_io $command failed (old kernel/wrong fs?)"
+}
+
 # check that xfs_io, kernel, and filesystem all support zero
 _require_xfs_io_zero()
 {
-	testio=`$XFS_IO_PROG -c "zero help" 2>&1`
-	echo $testio | grep -q 'command "zero" not found' && \
-		_notrun "zero command not supported"
+	_require_xfs_io_command "zero"
 }
 
 # check that xfs_io, glibc, kernel, and filesystem all (!) support
@@ -1309,54 +1340,27 @@  _require_xfs_io_zero()
 #
 _require_xfs_io_falloc()
 {
-	testfile=$TEST_DIR/$$.falloc
-	testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
-	rm -f $testfile 2>&1 > /dev/null
-	echo $testio | grep -q "not found" && \
-		_notrun "xfs_io fallocate support is missing"
-	echo $testio | grep -q "Operation not supported" && \
-		_notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
+	_require_xfs_io_command "falloc"
 }
 
 # check that xfs_io, kernel and filesystem all support fallocate with hole
 # punching
 _require_xfs_io_falloc_punch()
 {
-	testfile=$TEST_DIR/$$.falloc
-	testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
-		-c "fpunch 4k 8k" $testfile 2>&1`
-	rm -f $testfile 2>&1 > /dev/null
-	echo $testio | grep -q "not found" && \
-		_notrun "xfs_io fallocate punch support is missing"
-	echo $testio | grep -q "Operation not supported" && \
-		_notrun "xfs_io fallocate punch command failed (no fs support?)"
+	_require_xfs_io_command "fpunch"
 }
 
 # check that xfs_io, kernel and filesystem all support fallocate with collapse
 # range
 _require_xfs_io_falloc_collapse()
 {
-	testfile=$TEST_DIR/$$.falloc
-	testio=`$XFS_IO_PROG -f -c "pwrite 0 20k" -c "fsync" \
-		-c "fcollapse 4k 8k" $testfile 2>&1`
-	rm -f $testfile 2>&1 > /dev/null
-	echo $testio | grep -q "not found" && \
-		_notrun "xfs_io fallocate collapse range support is missing"
-	echo $testio | grep -q "Operation not supported" && \
-		_notrun "xfs_io fallocate collapse range failed (no fs support?)"
+	_require_xfs_io_command "fcollapse"
 }
 
 # check that xfs_io, kernel and filesystem support fiemap
 _require_xfs_io_fiemap()
 {
-	testfile=$TEST_DIR/$$.fiemap
-	testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
-		-c "fiemap -v" $testfile 2>&1`
-	rm -f $testfile 2>&1 > /dev/null
-	echo $testio | grep -q "not found" && \
-		_notrun "xfs_io fiemap support is missing"
-	echo $testio | grep -q "Operation not supported" && \
-		_notrun "xfs_io fiemap command failed (no fs support?)"
+	_require_xfs_io_command "fiemap"
 }
 
 # Check that a fs has enough free space (in 1024b blocks)