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