summaryrefslogtreecommitdiff
path: root/tests/convert-tests/014-reiserfs-tail-handling/test.sh
blob: 335c0091ac09bfddaf03275d1f9f292d36b7ed67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Check the various combinations of real blocks, holes, and tails
# Since it's possible to have a valid extent layout that check will
# happily accept AND have garbage in the output, compare the results
# as well.
# We use separate inputs for tails and real blocks so we can determine
# if there was a failure in copying either.

source "$TOP/tests/common"
source "$TOP/tests/common.convert"

if ! check_kernel_support_reiserfs >/dev/null; then
	_not_run "no reiserfs support"
fi

setup_root_helper
prepare_test_dev
check_prereq btrfs-convert
check_global_prereq md5sum
check_global_prereq mkreiserfs
check_global_prereq perl

perl -e "print 'a'x8192;" > input
perl -e "print 'b'x8192;" > input2

default_mkfs="mkreiserfs -b 4096"
convert_test_preamble '' 'tail conversion test' 16k "$default_mkfs"
convert_test_prep_fs reiserfs $default_mkfs

# Hole alone
run_check $SUDO_HELPER truncate -s 81920 "$TEST_MNT/hole"

# Tail alone
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/1k" bs=1k count=1 \
                      > /dev/null 2>&1

# Single indirect block
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k" bs=1k count=4 \
                      > /dev/null 2>&1

# Indirect block + tail
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/5k" bs=1k count=4 \
                      > /dev/null 2>&1
run_check $SUDO_HELPER dd if=input2 of="$TEST_MNT/5k" bs=1k count=1 \
                         seek=4 > /dev/null 2>&1

# Hole followed by tail
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/hole-1k" bs=1k count=1 \
                         seek=4 > /dev/null 2>&1

# Indirect block followed by hole
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k-hole" bs=1k count=4 \
                      > /dev/null 2>&1
run_check $SUDO_HELPER truncate -s 81920 "$TEST_MNT/4k-hole"

# Indirect block followed by hole followed by tail
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k-hole-1k" bs=1k count=4 \
                      > /dev/null 2>&1
run_check $SUDO_HELPER truncate -s 8192 "$TEST_MNT/4k-hole-1k"
run_check $SUDO_HELPER dd if=input2 of="$TEST_MNT/4k-hole-1k" bs=1k count=1 \
                         seek=8 > /dev/null 2>&1

rm -f input input2

declare -A SUMS
for file in "$TEST_MNT"/*; do
       SUM=$(md5sum "$file")
       SUMS["$file"]=$SUM
done

run_check_umount_test_dev
convert_test_do_convert

run_check_mount_test_dev
for file in "${!SUMS[@]}"; do
       SUM=$(md5sum "$file")
       run_check test "$SUM" = "${SUMS[$file]}"
done
run_check_umount_test_dev