File: test-redundant-saves.sh

package info (click to toggle)
bup 0.29-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,028 kB
  • sloc: sh: 8,287; python: 7,077; ansic: 1,415; pascal: 664; makefile: 239; perl: 219
file content (61 lines) | stat: -rwxr-xr-x 1,663 bytes parent folder | download
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
#!/usr/bin/env bash

# Test that running save more than once with no other changes produces
# the exact same tree.

# Note: we can't compare the top-level hash (i.e. the output of "save
# -t" because that currently pulls the metadata for unindexed parent
# directories directly from the filesystem, and the relevant atimes
# may change between runs.  So instead we extract the roots of the
# indexed trees for comparison via t/subtree-hash.

. ./wvtest-bup.sh || exit $?

set -o pipefail

WVSTART 'all'

top="$(pwd)"
tmpdir="$(WVPASS wvmktempdir)" || exit $?

export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$BUP_DIR"

bup() { "$top/bup" "$@"; }

WVPASS mkdir -p "$tmpdir/src"
WVPASS mkdir -p "$tmpdir/src/d"
WVPASS mkdir -p "$tmpdir/src/d/e"
WVPASS touch "$tmpdir/src/"{f,b,a,d}
WVPASS touch "$tmpdir/src/d/z"

WVPASS bup init
WVPASS bup index -u "$tmpdir/src"

declare -a indexed_top
IFS=/
indexed_top="${tmpdir##/}"
indexed_top=(${indexed_top%%/})
unset IFS

tree1=$(WVPASS bup save -t "$tmpdir/src") || exit $?
indexed_tree1="$(WVPASS t/subtree-hash "$tree1" "${indexed_top[@]}" src)" \
    || exit $?

result="$(WVPASS cd "$tmpdir/src"; WVPASS bup index -m)" || exit $?
WVPASSEQ "$result" ""

tree2=$(WVPASS bup save -t "$tmpdir/src") || exit $?
indexed_tree2="$(WVPASS t/subtree-hash "$tree2" "${indexed_top[@]}" src)" \
    || exit $?

WVPASSEQ "$indexed_tree1" "$indexed_tree2"

result="$(WVPASS bup index -s / | WVFAIL grep ^D)" || exit $?
WVPASSEQ "$result" ""

tree3=$(WVPASS bup save -t /) || exit $?
indexed_tree3="$(WVPASS t/subtree-hash "$tree3" "${indexed_top[@]}" src)" || exit $?
WVPASSEQ "$indexed_tree1" "$indexed_tree3"

WVPASS rm -rf "$tmpdir"