btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for tests
[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 "$TEST_TOP/common"
14
15 check_prereq btrfs-convert
16 check_prereq btrfs
17 check_global_prereq e2fsck
18 check_global_prereq xzcat
19
20 setup_root_helper
21 prepare_test_dev
22
23 # override common function
24 function check_image() {
25         TEST_DEV="$1"
26         run_check e2fsck -n -f "$TEST_DEV"
27         run_check "$TOP/btrfs-convert" "$TEST_DEV"
28         run_check "$TOP/btrfs" check "$TEST_DEV"
29         run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV"
30
31         run_check_mount_test_dev
32         run_check $SUDO_HELPER e2fsck -n -f "$TEST_MNT/ext2_saved/image"
33         run_check $SUDO_HELPER umount "$TEST_MNT"
34
35         run_check "$TOP/btrfs" check "$TEST_DEV"
36         run_check "$TOP/btrfs-convert" -r "$TEST_DEV"
37         run_check e2fsck -n -f "$TEST_DEV"
38
39         rm -f "$TEST_DEV"
40 }
41
42 check_all_images