xfs
[Top] [All Lists]

[PATCH 1/3] xfstests: Add tmpfs support

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/3] xfstests: Add tmpfs support
From: ranto.boris@xxxxxxxxx
Date: Thu, 2 May 2013 16:03:57 +0200
Cc: Boris Ranto <ranto.boris@xxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=r0sUbPCfmtL+2pStHFHUy6vT9GJERgv2RDXheUHr5Lo=; b=EHKlK6JA5CRsd12qZlVkaQG+GXWjcLPFN566CWI/sC/ILgI0dwRPjnmgpFufSgU4Br 5wGcyeJPa05RGVZ4oeWGZWVPgRwyvJgYCpaf1NgVp5pWsYJ07LmtZz3lxtE2pxsBaQc1 E4r+fXC1X/CQB1XA95YHlp80iJ9jgRsbzMWTNM7ZP4IB+5L/bvE4L44B/5jyY0TFw3T5 yKcBdnGP+qXHWxvwOPv4fCZN01w9gx+bjPLAS43rSvE/KCz1cVmSqBvjFQEPPnjxZ0R1 rnFXKHiPNig5OEhIiCNdpkFwuh9dnVe9gJd4lPaWkibJD6RPQKXVE40+HakcnCrgmP0y 2Bsw==
In-reply-to: <1367503439-12827-1-git-send-email-ranto.boris@xxxxxxxxx>
References: <1367503439-12827-1-git-send-email-ranto.boris@xxxxxxxxx>
From: Boris Ranto <ranto.boris@xxxxxxxxx>

This is just a simple patch to get the tmpfs working as a target file
system. The patch copies the way nfs is handled in xfstests.

I didn't change the xfstests logic to recognize a proper SCRATCH_DEV.
Hence, the SCRATCH_DEV for tmpfs should be in nfs form (with ':' sign
in it) in order for this to work properly.

Signed-off-by: Boris Ranto <ranto.boris@xxxxxxxxx>
---
 check     |    2 ++
 common/rc |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/check b/check
index 966fbe5..fc335ec 100755
--- a/check
+++ b/check
@@ -76,6 +76,7 @@ check options
     -xfs                test XFS (default)
     -udf                test UDF
     -nfs                test NFS
+    -tmpfs              test TMPFS
     -l                 line mode diff
     -udiff             show unified diff (default)
     -n                 show me, do not run tests
@@ -162,6 +163,7 @@ while [ $# -gt 0 ]; do
        -udf)   FSTYP=udf ;;
        -xfs)   FSTYP=xfs ;;
        -nfs)   FSTYP=nfs ;;
+       -tmpfs) FSTYP=tmpfs ;;
 
        -g)     group=$2 ; shift ;
                group_list=$(get_group_list $group)
diff --git a/common/rc b/common/rc
index 8e37368..4825371 100644
--- a/common/rc
+++ b/common/rc
@@ -97,6 +97,10 @@ _mount_opts()
        # acls aren't turned on by default on gfs2
        export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
        ;;
+    tmpfs)
+       # We need to specify the size at mount, use 512 MB by default
+       export MOUNT_OPTIONS="-o size=512M $TMPFS_MOUNT_OPTIONS"
+       ;;
     *)
        ;;
     esac
@@ -125,6 +129,9 @@ _mkfs_opts()
     jfs)
        export MKFS_OPTIONS="$JFS_MKFS_OPTIONS -q"
        ;;
+    tmpfs)
+       export MKFS_OPTIONS="$TMPFS_MKFS_OPTIONS"
+       ;;
     *)
        ;;
     esac
@@ -520,6 +527,9 @@ _scratch_mkfs()
     ext4)
        _scratch_mkfs_ext4 $*
        ;;
+    tmpfs)
+       # do nothing for tmpfs
+       ;;
     *)
        yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV
        ;;
@@ -930,6 +940,12 @@ _require_scratch()
                     _notrun "this test requires a valid \$SCRATCH_DEV"
                 fi
                 ;;
+       tmpfs)
+               if [ -z "$SCRATCH_DEV" -o ! -d "$SCRATCH_MNT" ];
+               then
+                   _notrun "this test requires a valid \$SCRATCH_MNT and 
unique $SCRATCH_DEV"
+               fi
+               ;;
        *)
                 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
                 then
@@ -1626,6 +1642,9 @@ _check_test_fs()
     btrfs)
        _check_btrfs_filesystem $TEST_DEV
        ;;
+    tmpfs)
+       # no way to check the consistency of tmpfs
+       ;;
     *)
        _check_generic_filesystem $TEST_DEV
        ;;
@@ -1655,6 +1674,9 @@ _check_scratch_fs()
     btrfs)
        _check_btrfs_filesystem $SCRATCH_DEV
        ;;
+    tmpfs)
+       # No way to check the consistency of tmpfs
+       ;;
     *)
        _check_generic_filesystem $SCRATCH_DEV
        ;;
@@ -1743,6 +1765,32 @@ _setup_nfs_scratchdir()
     testdir=$SCRATCH_MNT
 }
 
+_setup_tmpfs_scratchdir()
+{
+    [ "$FSTYP" != "tmpfs" ] \
+        && _fail "setup_tmpfs_testdir: \$FSTYP is not tmpfs"
+    [ -z "$SCRATCH_DEV" ] \
+       && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
+    [ -z "$SCRATCH_MNT" ] \
+       && _notrun "this test requires a valid \$SCRATCH_MNT"
+
+    # mounted?
+    if _mount | grep -q $SCRATCH_DEV
+    then
+        # if it's mounted, make sure its on $SCRATCH_MNT
+        if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
+        then
+            _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - 
aborting"
+        fi
+        $UMOUNT_PROG $SCRATCH_DEV
+    fi
+
+    _scratch_mkfs
+    _scratch_mount
+
+    testdir=$SCRATCH_MNT
+}
+
 #
 # Warning for UDF and NFS:
 # this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
@@ -1761,6 +1809,9 @@ _setup_testdir()
     nfs*)
        _setup_nfs_scratchdir
        ;;
+    tmpfs)
+       _setup_tmpfs_scratchdir
+       ;;
     *)
        testdir=$TEST_DIR
        ;;
@@ -1778,6 +1829,10 @@ _cleanup_testdir()
        # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
        [ -n "$testdir" ] && $UMOUNT_PROG $testdir
        ;;
+    tmpfs)
+       # umount testdir since it is actually a scrath mount
+       [ -n "$testdir" ] && $UMOUNT_PROG $testdir
+       ;;
     *)
        # do nothing, testdir is $TEST_DIR
        :
-- 
1.7.1

<Prev in Thread] Current Thread [Next in Thread>