]> arthur.barton.de Git - bup.git/blob - t/test-redundant-saves.sh
test-restore-map-owner: accommodate python 3 and test there
[bup.git] / t / test-redundant-saves.sh
1 #!/usr/bin/env bash
2
3 # Test that running save more than once with no other changes produces
4 # the exact same tree.
5
6 # Note: we can't compare the top-level hash (i.e. the output of "save
7 # -t" because that currently pulls the metadata for unindexed parent
8 # directories directly from the filesystem, and the relevant atimes
9 # may change between runs.  So instead we extract the roots of the
10 # indexed trees for comparison via t/subtree-hash.
11
12 . ./wvtest-bup.sh || exit $?
13
14 set -o pipefail
15
16 WVSTART 'all'
17
18 top="$(pwd)"
19 tmpdir="$(WVPASS wvmktempdir)" || exit $?
20
21 export BUP_DIR="$tmpdir/bup"
22 export GIT_DIR="$BUP_DIR"
23
24 bup() { "$top/bup" "$@"; }
25
26 WVPASS mkdir -p "$tmpdir/src"
27 WVPASS mkdir -p "$tmpdir/src/d"
28 WVPASS mkdir -p "$tmpdir/src/d/e"
29 WVPASS touch "$tmpdir/src/"{f,b,a,d}
30 WVPASS touch "$tmpdir/src/d/z"
31
32 WVPASS bup init
33 WVPASS bup index -u "$tmpdir/src"
34
35 declare -a indexed_top
36 IFS=/
37 indexed_top="${tmpdir##/}"
38 indexed_top=(${indexed_top%%/})
39 unset IFS
40
41 tree1=$(WVPASS bup save -t "$tmpdir/src") || exit $?
42 indexed_tree1="$(WVPASS t/subtree-hash "$tree1" "${indexed_top[@]}" src)" \
43     || exit $?
44
45 result="$(WVPASS cd "$tmpdir/src"; WVPASS bup index -m)" || exit $?
46 WVPASSEQ "$result" ""
47
48 tree2=$(WVPASS bup save -t "$tmpdir/src") || exit $?
49 indexed_tree2="$(WVPASS t/subtree-hash "$tree2" "${indexed_top[@]}" src)" \
50     || exit $?
51
52 WVPASSEQ "$indexed_tree1" "$indexed_tree2"
53
54 result="$(WVPASS bup index -s / | WVFAIL grep ^D)" || exit $?
55 WVPASSEQ "$result" ""
56
57 tree3=$(WVPASS bup save -t /) || exit $?
58 indexed_tree3="$(WVPASS t/subtree-hash "$tree3" "${indexed_top[@]}" src)" || exit $?
59 WVPASSEQ "$indexed_tree1" "$indexed_tree3"
60
61 WVPASS rm -rf "$tmpdir"