]> arthur.barton.de Git - bup.git/blob - t/test-on.sh
test-restore-map-owner: accommodate python 3 and test there
[bup.git] / t / test-on.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3 . ./t/lib.sh || exit $?
4
5 set -o pipefail
6
7 top="$(WVPASS pwd)" || exit $?
8 tmpdir="$(WVPASS wvmktempdir)" || exit $?
9
10 export BUP_DIR="$tmpdir/bup"
11 export GIT_DIR="$tmpdir/bup"
12
13 bup() { "$top/bup" "$@"; }
14 compare-trees() { "$top/t/compare-trees" "$@"; }
15
16 WVPASS bup init
17 WVPASS cd "$tmpdir"
18
19 WVSTART "index/save"
20 WVPASS mkdir src src/foo
21 WVPASS date > src/bar
22 WVPASS bup random 1k > src/baz
23 WVPASS bup on - index src
24 WVPASS bup on - save -ctn src src > get.log
25 WVPASSEQ $(WVPASS cat get.log | WVPASS wc -l) 2
26 tree_id=$(WVPASS awk 'FNR == 1' get.log) || exit $?
27 commit_id=$(WVPASS awk 'FNR == 2' get.log) || exit $?
28 WVPASS git ls-tree "$tree_id"
29 WVPASS git cat-file commit "$commit_id" | head -n 1 \
30     | WVPASS grep "^tree $tree_id\$"
31
32 WVPASS bup restore -C restore "src/latest/$(pwd)/src/."
33 WVPASS compare-trees src/ restore/
34 WVPASS rm -r restore
35
36 WVSTART "split"
37 WVPASS bup on - split -ctn baz src/baz > get.log
38 tree_id=$(WVPASS awk 'FNR == 1' get.log) || exit $?
39 commit_id=$(WVPASS awk 'FNR == 2' get.log) || exit $?
40 WVPASS git ls-tree "$tree_id"
41 WVPASS git cat-file commit "$commit_id" | head -n 1 \
42     | WVPASS grep "^tree $tree_id\$"
43 WVPASS bup join baz > restore-baz
44 WVPASS cmp src/baz restore-baz
45
46 WVSTART "index-cache"
47 # the 'a-zA-Z0-9_' is '\w' from python,
48 # the trailing _ is because there's no dir specified
49 # and that should thus be empty
50 hostname=$(bup python -c "from bup import helpers ; print(helpers.hostname().decode('iso8859-1'))")
51 idxcache=$(echo "$hostname" | sed 's/[^@a-zA-Z0-9_]/_/g')_
52 # there should be an index-cache now
53 for idx in "$tmpdir"/bup/objects/pack/*.idx ; do
54     cachedidx="$tmpdir/bup/index-cache/$idxcache/$(basename "$idx")"
55     WVPASS cmp "$idx" "$cachedidx"
56 done
57
58 WVPASS rm -rf "$tmpdir"