btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for tests
[platform/upstream/btrfs-progs.git] / tests / convert-tests / 015-no-rollback-after-balance / test.sh
1 #!/bin/bash
2 # Check if btrfs-convert refuses to rollback the filesystem, and leave the fs
3 # and the convert image untouched
4
5 source "$TEST_TOP/common"
6 source "$TEST_TOP/common.convert"
7
8 setup_root_helper
9 prepare_test_dev
10 check_prereq btrfs-convert
11 check_global_prereq mke2fs
12
13 # convert_test_prep_fs() will create large enough file inside the test device,
14 # that's good enough for us to test rollback failure.
15 convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096
16 run_check_umount_test_dev
17 convert_test_do_convert "" 4096
18
19 run_check_mount_test_dev
20
21 # Now the fs is converted, balance it so later rollback should fail
22 run_check $SUDO_HELPER "$TOP/btrfs" balance start --full-balance "$TEST_MNT"
23 run_check_umount_test_dev
24
25 # rollback should fail
26 run_mustfail "rollback fs after balance" "$TOP/btrfs-convert" -r "$TEST_DEV"
27
28 # Ensure the fs and convert image can pass the check
29 run_check "$TOP/btrfs" check "$TEST_DEV"
30
31 run_check_mount_test_dev
32 run_check $SUDO_HELPER e2fsck -fn "$TEST_MNT/ext2_saved/image"
33 run_check_umount_test_dev