btrfs-progs: tests: check if kernel has btrfs support
[platform/upstream/btrfs-progs.git] / tests / common
index 264424d..c20fec8 100644 (file)
@@ -128,6 +128,7 @@ check_image()
 # - dtto compressed by XZ, suffix .raw.xz
 # - meta-dump images with suffix .img
 # - dtto compressed by XZ, suffix .img.xz
+# - compressed send stream, .stream.xz
 extract_image()
 {
        local image
@@ -154,6 +155,12 @@ extract_image()
                image=${image%%.xz}
                mv "$image" "$image".restored
                ;;
+       *.stream.xz)
+               xz --decompress --keep "$image" || \
+                       _fail "failed to decompress file $image" >&2
+               image=${image%%.xz}
+               mv "$image" "$image".restored
+               ;;
        esac
 
        if ! [ -f $image.restored ]; then
@@ -273,10 +280,20 @@ run_check_umount_test_dev()
        run_check $SUDO_HELPER umount "$@" "$TEST_DEV"
 }
 
+check_kernel_support()
+{
+       if ! grep -iq 'btrfs' /proc/filesystems; then
+               echo "WARNING: btrfs filesystem not listed in /proc/filesystems, some tests might fail"
+               return 1
+       fi
+       return 0
+}
+
 init_env()
 {
        TEST_MNT="${TEST_MNT:-$TOP/tests/mnt}"
        export TEST_MNT
        mkdir -p "$TEST_MNT" || { echo "Failed mkdir -p $TEST_MNT"; exit 1; }
+
 }
 init_env