btrfs-progs: tests: 004-ext2-backup-superblock-ranges, use common helpers for image...
[platform/upstream/btrfs-progs.git] / tests / convert-tests / 004-ext2-backup-superblock-ranges / test.sh
1 #!/bin/bash
2
3 # Specially created e2image dump to test backup superblock migration for
4 # new convert.
5 # These images will cause the following problems if convert doesn't handle
6 # backup superblock migration well:
7 # 1) Assert while building free space tree
8 # 2) Error copying inodes
9 # 3) Discontinuous file extents after convert
10 # 4) Overlap file extents
11 # 5) Unable to rollback
12
13 source $TOP/tests/common
14
15 check_prereq btrfs-convert
16 check_prereq btrfs
17 check_prereq btrfs-show-super
18 check_global_prereq e2fsck
19 check_global_prereq xzcat
20
21 setup_root_helper
22 prepare_test_dev 512M
23
24 # override common function
25 function check_image() {
26         TEST_DEV="$1"
27         run_check e2fsck -n -f $TEST_DEV
28         run_check $TOP/btrfs-convert $TEST_DEV
29         run_check $TOP/btrfs check $TEST_DEV
30         run_check $TOP/btrfs-show-super $TEST_DEV
31
32         run_check_mount_test_dev
33         run_check $SUDO_HELPER e2fsck -n -f $TEST_MNT/ext2_saved/image
34         run_check $SUDO_HELPER umount $TEST_MNT
35
36         run_check $TOP/btrfs check $TEST_DEV
37         run_check $TOP/btrfs-convert -r $TEST_DEV
38         run_check e2fsck -n -f $TEST_DEV
39
40         rm -f $TEST_DEV
41 }
42
43 check_all_images