generic: xattr enospc cleanup test
[xfstests-dev.git] / common / rc
index 610045eab304b823d95564a279957045a7d621b3..5e83c809160f8ac60fa9d2c403ecbc7b9f480654 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -1449,6 +1449,18 @@ _require_xfs_sysfs()
        fi
 }
 
+# this test requires the xfs sparse inode feature
+#
+_require_xfs_sparse_inodes()
+{
+       _scratch_mkfs_xfs_supported -m crc=1 -i sparse > /dev/null 2>&1 \
+               || _notrun "mkfs.xfs does not support sparse inodes"
+       _scratch_mkfs_xfs -m crc=1 -i sparse > /dev/null 2>&1
+       _scratch_mount >/dev/null 2>&1 \
+               || _notrun "kernel does not support sparse inodes"
+       umount $SCRATCH_MNT
+}
+
 # this test requires that external log/realtime devices are not in use
 #
 _require_nonexternal()
@@ -2724,6 +2736,18 @@ _get_used_inode()
        echo $nr_inode
 }
 
+_get_used_inode_percent()
+{
+       if [ -z "$1" ]; then
+               echo "Usage: _get_used_inode_percent <mnt>"
+               exit 1
+       fi
+       local pct_inode;
+       pct_inode=`$DF_PROG -i $1 | tail -1 | awk '{ print $6 }' | \
+                  sed -e 's/%//'`
+       echo $pct_inode
+}
+
 _get_free_inode()
 {
        if [ -z "$1" ]; then
@@ -2735,6 +2759,19 @@ _get_free_inode()
        echo $nr_inode
 }
 
+# get the available space in bytes
+#
+_get_available_space()
+{
+       if [ -z "$1" ]; then
+               echo "Usage: _get_available_space <mnt>"
+               exit 1
+       fi
+       local avail_kb;
+       avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
+       echo $((avail_kb * 1024))
+}
+
 # get btrfs profile configs being tested
 #
 # A set of pre-set profile configs are exported via _btrfs_profile_configs
@@ -2936,6 +2973,39 @@ _get_device_size()
        grep `_short_dev $1` /proc/partitions | awk '{print $3}'
 }
 
+# check dmesg log for WARNING/Oops/etc.
+_check_dmesg()
+{
+       if [ ! -f ${RESULT_DIR}/check_dmesg ]; then
+               return 0
+       fi
+       rm -f ${RESULT_DIR}/check_dmesg
+
+       # default filter is a simple cat command, caller could provide a
+       # customized filter and pass the name through the first argument, to
+       # filter out intentional WARNINGs or Oopses
+       filter=${1:-cat}
+
+       # search the dmesg log of last run of $seqnum for possible failures
+       # use sed \cregexpc address type, since $seqnum contains "/"
+       dmesg | tac | sed -ne "0,\#run fstests $seqnum at $date_time#p" | \
+               tac | $filter >$seqres.dmesg
+       grep -q -e "kernel BUG at" \
+            -e "WARNING:" \
+            -e "BUG:" \
+            -e "Oops:" \
+            -e "possible recursive locking detected" \
+            -e "Internal error" \
+            $seqres.dmesg
+       if [ $? -eq 0 ]; then
+               echo "_check_dmesg: something found in dmesg (see $seqres.dmesg)"
+               return 1
+       else
+               rm -f $seqres.dmesg
+               return 0
+       fi
+}
+
 # don't check dmesg log after test
 _disable_dmesg_check()
 {