common/rc: skip atime related tests on CIFS
[xfstests-dev.git] / common / rc
index 9ffab7fd0907d1a7132f6d65abbd3df4cb527fd4..f04c9ea2fd89db90256a2f11e0dddc09d42249aa 100644 (file)
--- a/common/rc
+++ b/common/rc
 #  Mountain View, CA 94043, USA, or: http://www.sgi.com
 #-----------------------------------------------------------------------
 
-BC=$(which bc 2> /dev/null) || BC=
+. common/config
 
-# Valid test names start with 3 digits "NNN":
-#  "[0-9]\{3\}"
-# followed by an optional "-":
-#  "-\?"
-# followed by an optional combination of alphanumeric and "-" chars:
-#  "[[:alnum:]-]*"
-# e.g. 999-the-mark-of-fstests
-#
-VALID_TEST_ID="[0-9]\{3\}"
-VALID_TEST_NAME="$VALID_TEST_ID-\?[[:alnum:]-]*"
+BC=$(which bc 2> /dev/null) || BC=
 
 # Some tests are not relevant or functional when testing XFS realtime
 # subvolumes along with the rtinherit=1 mkfs option.  In these cases,
@@ -110,22 +101,18 @@ _ls_l()
        ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /" | grep -v 'lost+found'
 }
 
-# we need common/config
-if [ "$iam" != "check" ]
-then
-    if ! . ./common/config
-        then
-        echo "$iam: failed to source common/config"
-        exit 1
-    fi
-fi
-
 _dump_err()
 {
     _err_msg="$*"
     echo "$_err_msg"
 }
 
+_dump_err_cont()
+{
+    _err_msg="$*"
+    echo -n "$_err_msg"
+}
+
 _dump_err2()
 {
     _err_msg="$*"
@@ -1169,27 +1156,6 @@ _get_pids_by_name()
        -e "/[0-9]:[0-9][0-9]  *$1 /s/ .*//p"
 }
 
-# fix malloc libs output
-#
-_fix_malloc()
-{
-    # filter out the Electric Fence notice
-    $PERL_PROG -e '
-        while (<>) {
-            if (defined $o && /^\s+Electric Fence/) {
-                chomp($o);
-                print "$o";
-                undef $o;
-                next;
-            }
-            print $o if (defined $o);
-
-            $o=$_;
-        }
-        print $o if (defined $o);
-    '
-}
-
 #
 # _df_device : get an IRIX style df line for a given device
 #
@@ -1372,7 +1338,7 @@ _do()
     (eval "echo '---' \"$cmd\"") >>$seqres.full
     (eval "$cmd") >$tmp._out 2>&1
     local ret=$?
-    cat $tmp._out | _fix_malloc >>$seqres.full
+    cat $tmp._out >>$seqres.full
     rm -f $tmp._out
     if [ $# -eq 2 ]; then
        if [ $ret -eq 0 ]; then
@@ -2147,17 +2113,27 @@ _require_xfs_io_command()
                        -c "fiemap -v $param" $testfile 2>&1`
                param_checked=1
                ;;
-       "flink" )
-               testio=`$XFS_IO_PROG -T -F -c "flink $testfile" \
-                       $TEST_DIR 2>&1`
+       "flink")
+               local testlink=$TEST_DIR/$$.link.xfs_io
+               testio=`$XFS_IO_PROG -F -f -c "flink $testlink" $testfile 2>&1`
+               rm -f $testlink > /dev/null 2>&1
+               ;;
+       "-T")
+               # Check O_TMPFILE support in xfs_io, kernel and fs
+               testio=`$XFS_IO_PROG -T -c quit $TEST_DIR 2>&1`
                echo $testio | egrep -q "invalid option|Is a directory" && \
                        _notrun "xfs_io $command support is missing"
+               echo $testio | grep -q "Operation not supported" && \
+                       _notrun "O_TMPFILE is not supported"
                ;;
-       "fsmap" )
+       "fsmap")
                testio=`$XFS_IO_PROG -f -c "fsmap" $testfile 2>&1`
                echo $testio | grep -q "Inappropriate ioctl" && \
                        _notrun "xfs_io $command support is missing"
                ;;
+       "label")
+               testio=`$XFS_IO_PROG -c "label" $TEST_DIR 2>&1`
+               ;;
        "open")
                # -c "open $f" is broken in xfs_io <= 4.8. Along with the fix,
                # a new -C flag was introduced to execute one shot commands.
@@ -2178,7 +2154,7 @@ _require_xfs_io_command()
                param_checked=1
                ;;
        "scrub"|"repair")
-               testio=`$XFS_IO_PROG -x -c "$command probe 0" $TEST_DIR 2>&1`
+               testio=`$XFS_IO_PROG -x -c "$command probe" $TEST_DIR 2>&1`
                echo $testio | grep -q "Inappropriate ioctl" && \
                        _notrun "xfs_io $command support is missing"
                ;;
@@ -2196,7 +2172,7 @@ _require_xfs_io_command()
        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" && \
+       echo $testio | grep -q "Operation not supported\|Inappropriate ioctl" && \
                _notrun "xfs_io $command failed (old kernel/wrong fs?)"
        echo $testio | grep -q "Invalid" && \
                _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)"
@@ -2236,6 +2212,19 @@ _require_odirect()
        rm -f $testfile 2>&1 > /dev/null
 }
 
+_format_swapfile() {
+       local fname="$1"
+       local sz="$2"
+
+       rm -f "$fname"
+       touch "$fname"
+       chmod 0600 "$fname"
+       # Swap files must be nocow on Btrfs.
+       $CHATTR_PROG +C "$fname" > /dev/null 2>&1
+       _pwrite_byte 0x61 0 "$sz" "$fname" >> $seqres.full
+       mkswap "$fname" >> $seqres.full
+}
+
 # Check that the filesystem supports swapfiles
 _require_scratch_swapfile()
 {
@@ -2245,10 +2234,8 @@ _require_scratch_swapfile()
        _scratch_mount
 
        # Minimum size for mkswap is 10 pages
-       local size=$(($(get_page_size) * 10))
+       _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
 
-       _pwrite_byte 0x61 0 "$size" "$SCRATCH_MNT/swap" >/dev/null 2>&1
-       mkswap "$SCRATCH_MNT/swap" >/dev/null 2>&1
        if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
                _scratch_unmount
                _notrun "swapfiles are not supported"
@@ -3256,9 +3243,12 @@ _exclude_scratch_mount_option()
 _require_atime()
 {
        _exclude_scratch_mount_option "noatime"
-       if [ "$FSTYP" == "nfs" ]; then
-               _notrun "atime related mount options have no effect on NFS"
-       fi
+       case $FSTYP in
+       nfs|cifs)
+               _notrun "atime related mount options have no effect on $FSTYP"
+               ;;
+       esac
+
 }
 
 _require_relatime()
@@ -3574,10 +3564,6 @@ _disable_dmesg_check()
 
 init_rc()
 {
-       if [ "$iam" == new ]
-       then
-               return
-       fi
        # make some further configuration checks here
        if [ "$TEST_DEV" = ""  ]
        then
@@ -3802,6 +3788,29 @@ _require_scratch_feature()
        esac
 }
 
+# The maximum filesystem label length, /not/ including terminating NULL
+_label_get_max()
+{
+       case $FSTYP in
+       xfs)
+               echo 12
+               ;;
+       btrfs)
+               echo 255
+               ;;
+       *)
+               _notrun "$FSTYP does not define maximum label length"
+               ;;
+       esac
+}
+
+# Helper to check above early in a script
+_require_label_get_max()
+{
+       # Just call _label_get_max which will notrun if appropriate
+       dummy=$(_label_get_max)
+}
+
 init_rc
 
 ################################################################################