]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs/048: extend _filter_btrfs_prop_error to handle additional errors
authorJeff Mahoney <jeffm@suse.com>
Mon, 27 Jun 2016 20:14:11 +0000 (16:14 -0400)
committerEryu Guan <eguan@redhat.com>
Fri, 1 Jul 2016 03:17:08 +0000 (11:17 +0800)
btrfsprogs v4.5.3 changed the formatting of some error messages.
This patch extends the filter for btrfs prop to handle those.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/filter.btrfs
tests/btrfs/048
tests/btrfs/048.out

index 9970f4d42fcea2353fb511a1c63e454789d01ad7..0cf7f0d3f8b0a90994285600fda524a2ee487c6f 100644 (file)
@@ -72,15 +72,19 @@ _filter_btrfs_compress_property()
        sed -e "s/compression=\(lzo\|zlib\)/COMPRESSION=XXX/g"
 }
 
-# filter name of the property from the output, optionally verify against $1
+# filter error messages from btrfs prop, optionally verify against $1
 # recognized message(s):
 #  "object is not compatible with property: label"
+#  "invalid value for property:{, value}"
+#  "failed to {get,set} compression for $PATH[.:]: Invalid argument"
 _filter_btrfs_prop_error()
 {
        if ! [ -z "$1" ]; then
-               sed -e "s/\(compatible with property\): $1/\1/"
+               sed -e "s#\(compatible with property\): $1#\1#" \
+                   -e "s#^\(.*failed to [sg]et compression for $1\)[:.] \(.*\)#\1: \2#"
        else
-               sed -e "s/^\(.*compatible with property\).*/\1/"
+               sed -e "s#^\(.*compatible with property\).*#\1#" \
+                   -e "s#^\(.*invalid value for property\)[:.].*#\1#"
        fi
 }
 
index 4a36303632ebaee602f7aa5196742850177e60f8..0b907b0300c922a406fc2707ce509bd16ba68c64 100755 (executable)
@@ -79,7 +79,8 @@ echo -e "\nTesting subvolume ro property"
 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/sv1
 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1 ro
 echo "***"
-$BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro foo
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro foo 2>&1 |
+       _filter_btrfs_prop_error
 echo "***"
 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro true
 echo "***"
@@ -99,7 +100,8 @@ $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
 echo "***"
 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression \
-       foo 2>&1 | _filter_scratch
+       foo 2>&1 | _filter_scratch |
+       _filter_btrfs_prop_error SCRATCH_MNT/testdir/file1
 echo "***"
 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression lzo
 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
index 0b20d0b5976cb5743de43ee300c4733162dee005..3e4e3d28950adbfbf08abc6c3027e08f70586a25 100644 (file)
@@ -15,7 +15,7 @@ ERROR: object is not compatible with property
 Testing subvolume ro property
 ro=false
 ***
-ERROR: invalid value for property.
+ERROR: invalid value for property
 ***
 ***
 ro=true
@@ -27,7 +27,7 @@ ro=false
 
 Testing compression property
 ***
-ERROR: failed to set compression for SCRATCH_MNT/testdir/file1. Invalid argument
+ERROR: failed to set compression for SCRATCH_MNT/testdir/file1: Invalid argument
 ***
 compression=lzo
 compression=lzo