]> arthur.barton.de Git - bup.git/blob - t/test-split-join.sh
test-restore-map-owner: accommodate python 3 and test there
[bup.git] / t / test-split-join.sh
1 #!/usr/bin/env bash
2 . wvtest.sh
3 . wvtest-bup.sh
4 . t/lib.sh
5
6 set -o pipefail
7
8 top="$(WVPASS pwd)" || exit $?
9 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
11
12 bup() { "$top/bup" "$@"; }
13
14 WVPASS cd "$tmpdir"
15
16 WVPASS bup init
17
18 WVSTART "split --noop"
19 WVPASS bup split --noop <"$top/t/testfile1" >noop.tmp
20 WVPASSEQ '' "$(<noop.tmp)"
21 WVPASS bup split --noop -b <"$top/t/testfile1" >tags1n.tmp
22 WVPASS bup split --noop -t <"$top/t/testfile2" >tags2tn.tmp
23 WVPASSEQ $(find "$BUP_DIR/objects/pack" -name '*.pack' | wc -l) 0
24
25 WVSTART "split"
26 WVPASS echo a >a.tmp
27 WVPASS echo b >b.tmp
28 WVPASS bup split -b a.tmp >taga.tmp
29 WVPASS bup split -b b.tmp >tagb.tmp
30 WVPASS cat a.tmp b.tmp | WVPASS bup split -b >tagab.tmp
31 WVPASSEQ $(cat taga.tmp | wc -l) 1
32 WVPASSEQ $(cat tagb.tmp | wc -l) 1
33 WVPASSEQ $(cat tagab.tmp | wc -l) 1
34 WVPASSEQ $(cat tag[ab].tmp | wc -l) 2
35 WVPASSEQ "$(bup split -b a.tmp b.tmp)" "$(cat tagab.tmp)"
36 WVPASSEQ "$(bup split -b --keep-boundaries a.tmp b.tmp)" "$(cat tag[ab].tmp)"
37 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --keep-boundaries --git-ids)" \
38          "$(cat tag[ab].tmp)"
39 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --git-ids)" \
40          "$(cat tagab.tmp)"
41 WVPASS bup split --bench -b <"$top/t/testfile1" >tags1.tmp
42 WVPASS bup split -vvvv -b "$top/t/testfile2" >tags2.tmp
43 WVPASS echo -n "" | WVPASS bup split -n split_empty_string.tmp
44 WVPASS bup margin
45 WVPASS bup midx -f
46 WVPASS bup midx --check -a
47 WVPASS bup midx -o "$BUP_DIR/objects/pack/test1.midx" \
48         "$BUP_DIR"/objects/pack/*.idx
49 WVPASS bup midx --check -a
50 WVPASS bup midx -o "$BUP_DIR"/objects/pack/test1.midx \
51         "$BUP_DIR"/objects/pack/*.idx \
52         "$BUP_DIR"/objects/pack/*.idx
53 WVPASS bup midx --check -a
54 all=$(echo "$BUP_DIR"/objects/pack/*.idx "$BUP_DIR"/objects/pack/*.midx)
55 WVPASS bup midx -o "$BUP_DIR"/objects/pack/zzz.midx $all
56 WVPASS bup tick
57 WVPASS bup midx -o "$BUP_DIR"/objects/pack/yyy.midx $all
58 WVPASS bup midx -a
59 WVPASSEQ "$(echo "$BUP_DIR"/objects/pack/*.midx)" \
60         ""$BUP_DIR"/objects/pack/yyy.midx"
61 WVPASS bup margin
62 WVPASS bup split -t "$top/t/testfile2" >tags2t.tmp
63 WVPASS bup split -t "$top/t/testfile2" --fanout 3 >tags2tf.tmp
64 WVPASS bup split -r "$BUP_DIR" -c "$top/t/testfile2" >tags2c.tmp
65 WVPASS bup split -r ":$BUP_DIR" -c "$top/t/testfile2" >tags2c.tmp
66 WVPASS ls -lR \
67     | WVPASS bup split -r ":$BUP_DIR" -c --fanout 3 --max-pack-objects 3 -n lslr \
68     || exit $?
69 WVPASS bup ls
70 WVFAIL bup ls /does-not-exist
71 WVPASS bup ls /lslr
72 WVPASS bup ls /lslr/latest
73 WVPASS bup ls /lslr/latest/
74 #WVPASS bup ls /lslr/1971-01-01   # all dates always exist
75 WVFAIL diff -u tags1.tmp tags2.tmp
76 WVPASS diff -u tags1.tmp tags1n.tmp
77 WVPASS diff -u tags2t.tmp tags2tn.tmp
78
79 # fanout must be different from non-fanout
80 WVFAIL diff tags2t.tmp tags2tf.tmp
81 WVPASS wc -c "$top/t/testfile1" "$top/t/testfile2"
82 WVPASS wc -l tags1.tmp tags2.tmp
83
84 WVSTART "join"
85 WVPASS bup join $(cat tags1.tmp) >out1.tmp
86 WVPASS bup join <tags2.tmp >out2.tmp
87 WVPASS bup join <tags2t.tmp -o out2t.tmp
88 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
89 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
90 WVPASS diff -u "$top/t/testfile1" out1.tmp
91 WVPASS diff -u "$top/t/testfile2" out2.tmp
92 WVPASS diff -u "$top/t/testfile2" out2t.tmp
93 WVPASS diff -u "$top/t/testfile2" out2c.tmp
94 WVPASSEQ "$(bup join split_empty_string.tmp)" ""
95
96 WVPASS rm -rf "$tmpdir"