Add a helper to check that both btrfs-progs and kernel support the v2 send
stream, so that we can have tests specific for send v2 stream.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
{
_require_command "$BTRFS_CORRUPT_BLOCK_PROG" btrfs-corrupt-block
}
+
+_require_btrfs_send_v2()
+{
+ # Check first if btrfs-progs supports the v2 stream.
+ _require_btrfs_command send --compressed-data
+
+ # Now check the kernel support. If send_stream_version does not exists,
+ # then it's a kernel that only supports v1.
+ [ -f /sys/fs/btrfs/features/send_stream_version ] || \
+ _notrun "kernel does not support send stream v2"
+
+ [ $(cat /sys/fs/btrfs/features/send_stream_version) -gt 1 ] || \
+ _notrun "kernel does not support send stream v2"
+}