2 . ./wvtest-bup.sh || exit $?
7 readonly top="$(WVPASS pwd)" || exit $?
8 readonly tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
11 export GIT_DIR="$tmpdir/bup"
13 bup() { "$top/bup" "$@"; }
17 WVPASS dd if=/dev/zero of=test-sparse seek=$((1024 * 256)) bs=1 count=1
18 restore_size=$(WVPASS du -k -s test-sparse | WVPASS cut -f1) || exit $?
19 if ! [ "$restore_size" -lt 256 ]; then
20 WVSTART "no sparse support detected -- skipping tests"
27 WVPASS dd if=/dev/zero of=src/foo seek=$mb bs=1 count=1
29 WVPASS bup save -n src src
31 WVSTART "sparse file restore (all sparse)"
32 WVPASS bup restore -C restore "src/latest/$(pwd)/"
33 restore_size=$(WVPASS du -k -s restore | WVPASS cut -f1) || exit $?
34 WVPASS [ "$restore_size" -gt 1000 ]
35 WVPASS "$top/t/compare-trees" -c src/ restore/src/
37 WVSTART "sparse file restore --no-sparse (all sparse)"
39 WVPASS bup restore --no-sparse -C restore "src/latest/$(pwd)/"
40 restore_size=$(WVPASS du -k -s restore | WVPASS cut -f1) || exit $?
41 WVPASS [ "$restore_size" -gt 1000 ]
42 WVPASS "$top/t/compare-trees" -c src/ restore/src/
44 WVSTART "sparse file restore --sparse (all sparse)"
46 WVPASS bup restore --sparse -C restore "src/latest/$(pwd)/"
47 restore_size=$(WVPASS du -k -s restore | WVPASS cut -f1) || exit $?
48 WVPASS [ "$restore_size" -lt 100 ]
49 WVPASS "$top/t/compare-trees" -c src/ restore/src/
51 WVSTART "sparse file restore --sparse (sparse end)"
52 WVPASS echo "start" > src/foo
53 WVPASS dd if=/dev/zero of=src/foo seek=$mb bs=1 count=1 conv=notrunc
55 WVPASS bup save -n src src
57 WVPASS bup restore --sparse -C restore "src/latest/$(pwd)/"
58 restore_size=$(WVPASS du -k -s restore | WVPASS cut -f1) || exit $?
59 WVPASS [ "$restore_size" -lt 100 ]
60 WVPASS "$top/t/compare-trees" -c src/ restore/src/
62 WVSTART "sparse file restore --sparse (sparse middle)"
63 WVPASS echo "end" >> src/foo
65 WVPASS bup save -n src src
67 WVPASS bup restore --sparse -C restore "src/latest/$(pwd)/"
68 restore_size=$(WVPASS du -k -s restore | WVPASS cut -f1) || exit $?
69 WVPASS [ "$restore_size" -lt 100 ]
70 WVPASS "$top/t/compare-trees" -c src/ restore/src/
72 WVSTART "sparse file restore --sparse (bracketed zero run in buf)"
73 WVPASS echo 'x' > src/foo
74 WVPASS dd if=/dev/zero bs=1 count=512 >> src/foo
75 WVPASS echo 'y' >> src/foo
77 WVPASS bup save -n src src
79 WVPASS bup restore --sparse -C restore "src/latest/$(pwd)/"
80 WVPASS "$top/t/compare-trees" -c src/ restore/src/
82 WVSTART "sparse file restore --sparse (sparse start)"
83 WVPASS dd if=/dev/zero of=src/foo seek=$mb bs=1 count=1
84 WVPASS echo "end" >> src/foo
86 WVPASS bup save -n src src
88 WVPASS bup restore --sparse -C restore "src/latest/$(pwd)/"
89 restore_size=$(WVPASS du -k -s restore | WVPASS cut -f1) || exit $?
90 WVPASS [ "$restore_size" -lt 100 ]
91 WVPASS "$top/t/compare-trees" -c src/ restore/src/
93 WVSTART "sparse file restore --sparse (sparse start and end)"
94 WVPASS dd if=/dev/zero of=src/foo seek=$mb bs=1 count=1
95 WVPASS echo "middle" >> src/foo
96 WVPASS dd if=/dev/zero of=src/foo seek=$((2 * mb)) bs=1 count=1 conv=notrunc
98 WVPASS bup save -n src src
100 WVPASS bup restore --sparse -C restore "src/latest/$(pwd)/"
101 restore_size=$(WVPASS du -k -s restore | WVPASS cut -f1) || exit $?
102 WVPASS [ "$restore_size" -lt 100 ]
103 WVPASS "$top/t/compare-trees" -c src/ restore/src/
105 WVSTART "sparse file restore --sparse (random)"
106 WVPASS bup random 512k > src/foo
108 WVPASS bup save -n src src
110 WVPASS bup restore --sparse -C restore "src/latest/$(pwd)/"
111 WVPASS "$top/t/compare-trees" -c src/ restore/src/
113 WVPASS rm -rf "$tmpdir"