btrfs-progs: tests: add variable quotation to convert-tests
[platform/upstream/btrfs-progs.git] / tests / convert-tests / 005-delete-all-rollback / test.sh
1 #!/bin/bash
2 # create a base image, convert to btrfs, remove all files, rollback the ext4 image
3 # note: ext4 only
4
5 source "$TOP/tests/common"
6 source "$TOP/tests/common.convert"
7
8 setup_root_helper
9 prepare_test_dev 512M
10 check_prereq btrfs-convert
11
12 # simple wrapper for a convert test
13 # $1: btrfs features, argument to -O
14 # $2: message
15 # $3: nodesize value
16 # $4 + rest: command to create the ext2 image
17 do_test() {
18         local features
19         local msg
20         local nodesize
21         local CHECKSUMTMP
22         local here
23
24         features="$1"
25         msg="$2"
26         nodesize="$3"
27         shift 3
28         convert_test_preamble "$features" "$msg" "$nodesize" "$@"
29         convert_test_prep_fs "$@"
30         populate_fs
31         CHECKSUMTMP=$(mktemp --tmpdir btrfs-progs-convert.XXXXXXXXXX)
32         convert_test_gen_checksums "$CHECKSUMTMP"
33
34         run_check_umount_test_dev
35
36         convert_test_do_convert "$features" "$nodesize"
37
38         run_check_mount_test_dev
39         convert_test_post_check_checksums "$CHECKSUMTMP"
40
41         here=$(pwd)
42         cd "$TEST_MNT" || _fail "cannot cd to TEST_MNT"
43         # ext2_saved/image must not be deleted
44         run_mayfail $SUDO_HELPER find "$TEST_MNT"/ -mindepth 1 -path '*ext2_saved' -prune -o -exec rm -vrf "{}" \;
45         cd "$here"
46         run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
47         run_check_umount_test_dev
48         convert_test_post_rollback
49
50         run_check_mount_test_dev
51         convert_test_post_check_checksums "$CHECKSUMTMP"
52         run_check_umount_test_dev
53
54         # mount again and verify checksums
55         run_check_mount_test_dev
56         convert_test_post_check_checksums "$CHECKSUMTMP"
57         run_check_umount_test_dev
58
59         rm "$CHECKSUMTMP"
60 }
61
62 for feature in '' 'extref' 'skinny-metadata' 'no-holes'; do
63         do_test "$feature" "ext4 4k nodesize" 4096 mke2fs -t ext4 -b 4096
64         do_test "$feature" "ext4 8k nodesize" 8192 mke2fs -t ext4 -b 4096
65         do_test "$feature" "ext4 16k nodesize" 16384 mke2fs -t ext4 -b 4096
66         do_test "$feature" "ext4 32k nodesize" 32768 mke2fs -t ext4 -b 4096
67         do_test "$feature" "ext4 64k nodesize" 65536 mke2fs -t ext4 -b 4096
68 done