From f195461b0e75907a199c05ba4a16b822d5bd05ec Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 24 Oct 2023 13:52:36 +0200 Subject: [PATCH] btrfs-progs: tests: add basic test for ntrfs conversion The ntfs2btrfs tool recently found a bug in 'check', add the conversion test support to our testsuite. It's optional and depends on kernel support of the 'ntfs3' driver and the availability of mkntfs and ntfs2btrfs, which might not be available everywhere. Signed-off-by: David Sterba --- tests/common.convert | 18 ++++++++++++++++++ tests/convert-tests/024-ntfs-basic/test.sh | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 tests/convert-tests/024-ntfs-basic/test.sh diff --git a/tests/common.convert b/tests/common.convert index 160909eb..9b498ef2 100644 --- a/tests/common.convert +++ b/tests/common.convert @@ -83,6 +83,8 @@ convert_test_prep_fs() { reiserfs) force=-ff mountopts="-o acl,user_xattr,attrs" ;; + ntfs) + force=-F ;; *) _fail "unknown filesystem to convert: $fstype" esac @@ -235,6 +237,7 @@ convert_test_post_rollback() { case "$1" in ext[234]) types=ext2,ext3,ext4 ;; reiserfs) types=reiserfs ;; + ntfs) types=ntfs ;; *) _fail "unknown filesystem type to check: $1" ;; esac @@ -295,3 +298,18 @@ check_kernel_support_reiserfs() fi return 0 } + +load_module_ntfs() +{ + # Load NTFS3 that has write support + $SUDO_HELPER modprobe ntfs3 +} + +check_kernel_support_ntfs() +{ + if ! grep -iq 'ntfs' /proc/filesystems; then + echo "WARNING: ntfs filesystem not listed in /proc/filesystems, some tests might be skipped" + return 1 + fi + return 0 +} diff --git a/tests/convert-tests/024-ntfs-basic/test.sh b/tests/convert-tests/024-ntfs-basic/test.sh new file mode 100755 index 00000000..d2e1be79 --- /dev/null +++ b/tests/convert-tests/024-ntfs-basic/test.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Really basic test of ntfs2btrfs conversion + +source "$TEST_TOP/common" || exit +source "$TEST_TOP/common.convert" || exit + +if ! check_kernel_support_ntfs >/dev/null; then + _not_run "no NTFS support" +fi + +check_prereq btrfs-convert +check_global_prereq mkfs.ntfs +check_global_prereq ntfs2btrfs + +setup_root_helper +prepare_test_dev + +# Iterate over defaults and options that are not tied to hardware capabilities +# or number of devices. Test only 4K block size as minimum. +for feature in '' 'block-group-tree' ; do + convert_test ntfs "$feature" "ntfs 4k nodesize" 4096 mkfs.ntfs -s 4096 +done