7 top="$(WVPASS pwd)" || exit $?
8 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
11 export GIT_DIR="$tmpdir/bup"
13 bup() { "$top/bup" "$@"; }
14 compare-trees() { "$top/t/compare-trees" "$@"; }
19 WVSTART "save --strip"
20 WVPASS force-delete "$BUP_DIR" src restore
22 WVPASS mkdir -p src/x/y/z
23 WVPASS bup random 8k > src/x/y/random-1
24 WVPASS bup random 8k > src/x/y/z/random-2
25 WVPASS bup index -u src
26 WVPASS bup save --strip -n foo src/x/y
27 WVPASS bup restore -C restore /foo/latest
28 WVPASS compare-trees src/x/y/ restore/latest/
31 WVSTART "save --strip-path (relative)"
32 WVPASS force-delete "$BUP_DIR" src restore
34 WVPASS mkdir -p src/x/y/z
35 WVPASS bup random 8k > src/x/y/random-1
36 WVPASS bup random 8k > src/x/y/z/random-2
37 WVPASS bup index -u src
38 WVPASS bup save --strip-path src -n foo src/x
39 WVPASS bup restore -C restore /foo/latest
40 WVPASS compare-trees src/ restore/latest/
43 WVSTART "save --strip-path (absolute)"
44 WVPASS force-delete "$BUP_DIR" src restore
46 WVPASS mkdir -p src/x/y/z
47 WVPASS bup random 8k > src/x/y/random-1
48 WVPASS bup random 8k > src/x/y/z/random-2
49 WVPASS bup index -u src
50 WVPASS bup save --strip-path "$tmpdir" -n foo src
51 WVPASS bup restore -C restore /foo/latest
52 WVPASS compare-trees src/ "restore/latest/src/"
55 WVSTART "save --strip-path (no match)"
56 if test $(WVPASS path-filesystems . | WVPASS sort -u | WVPASS wc -l) -ne 1
58 # Skip the test because the attempt to restore parent dirs to the
59 # current filesystem may fail -- i.e. running from
60 # /foo/ext4/bar/btrfs will fail when bup tries to restore linux
61 # attrs above btrfs to the restore tree *inside* btrfs.
63 echo "(running from tree with mixed filesystems; skipping test)" 1>&2
66 WVPASS force-delete "$BUP_DIR" src restore
68 WVPASS mkdir -p src/x/y/z
69 WVPASS bup random 8k > src/x/y/random-1
70 WVPASS bup random 8k > src/x/y/z/random-2
71 WVPASS bup index -u src
72 WVPASS bup save --strip-path foo -n foo src/x
73 WVPASS bup restore -C restore /foo/latest
74 WVPASS compare-trees src/ "restore/latest/$tmpdir/src/"
78 WVSTART "save --graft (empty graft points disallowed)"
79 WVPASS force-delete "$BUP_DIR" src restore
82 WVFAIL bup save --graft =/grafted -n graft-point-absolute src 2>&1 \
83 | WVPASS grep 'error: a graft point cannot be empty'
84 WVFAIL bup save --graft $top/$tmp= -n graft-point-absolute src 2>&1 \
85 | WVPASS grep 'error: a graft point cannot be empty'
88 WVSTART "save --graft /x/y=/a/b (relative paths)"
89 WVPASS force-delete "$BUP_DIR" src restore
91 WVPASS mkdir -p src/x/y/z
92 WVPASS bup random 8k > src/x/y/random-1
93 WVPASS bup random 8k > src/x/y/z/random-2
94 WVPASS bup index -u src
95 WVPASS bup save --graft src=x -n foo src
96 WVPASS bup restore -C restore /foo/latest
97 WVPASS compare-trees src/ "restore/latest/$tmpdir/x/"
100 WVSTART "save --graft /x/y=/a/b (matching structure)"
101 WVPASS force-delete "$BUP_DIR" src restore
103 WVPASS mkdir -p src/x/y/z
104 WVPASS bup random 8k > src/x/y/random-1
105 WVPASS bup random 8k > src/x/y/z/random-2
106 WVPASS bup index -u src
107 WVPASS bup save -v --graft "$tmpdir/src/x/y=$tmpdir/src/a/b" -n foo src/x/y
108 WVPASS bup restore -C restore /foo/latest
109 WVPASS compare-trees src/x/y/ "restore/latest/$tmpdir/src/a/b/"
112 WVSTART "save --graft /x/y=/a (shorter target)"
113 WVPASS force-delete "$BUP_DIR" src restore
115 WVPASS mkdir -p src/x/y/z
116 WVPASS bup random 8k > src/x/y/random-1
117 WVPASS bup random 8k > src/x/y/z/random-2
118 WVPASS bup index -u src
119 WVPASS bup save -v --graft "$tmpdir/src/x/y=/a" -n foo src/x/y
120 WVPASS bup restore -C restore /foo/latest
121 WVPASS compare-trees src/x/y/ "restore/latest/a/"
124 WVSTART "save --graft /x=/a/b (longer target)"
125 WVPASS force-delete "$BUP_DIR" src restore
127 WVPASS mkdir -p src/x/y/z
128 WVPASS bup random 8k > src/x/y/random-1
129 WVPASS bup random 8k > src/x/y/z/random-2
130 WVPASS bup index -u src
131 WVPASS bup save -v --graft "$tmpdir/src=$tmpdir/src/a/b/c" -n foo src
132 WVPASS bup restore -C restore /foo/latest
133 WVPASS compare-trees src/ "restore/latest/$tmpdir/src/a/b/c/"
136 WVSTART "save --graft /x=/ (root target)"
137 WVPASS force-delete "$BUP_DIR" src restore
139 WVPASS mkdir -p src/x/y/z
140 WVPASS bup random 8k > src/x/y/random-1
141 WVPASS bup random 8k > src/x/y/z/random-2
142 WVPASS bup index -u src
143 WVPASS bup save -v --graft "$tmpdir/src/x=/" -n foo src/x
144 WVPASS bup restore -C restore /foo/latest
145 WVPASS compare-trees src/x/ "restore/latest/"
148 #WVSTART "save --graft /=/x/ (root source)"
149 # FIXME: Not tested for now -- will require cleverness, or caution as root.
152 WVPASS rm -rf "$tmpdir"