]> arthur.barton.de Git - bup.git/blob - t/test.sh
7c5cd31a952c7df8747bc9118fb5e5ddb048123c
[bup.git] / t / test.sh
1 #!/bin/bash
2 . wvtest.sh
3 #set -e
4
5 TOP="$(pwd)"
6 export BUP_DIR="$TOP/buptest.tmp"
7
8 bup()
9 {
10     "$TOP/bup" "$@"
11 }
12
13 WVSTART "init"
14
15 #set -x
16 rm -rf "$BUP_DIR"
17 WVPASS bup init
18
19 WVSTART "index"
20 D=bupdata.tmp
21 rm -rf $D
22 mkdir $D
23 WVPASSEQ "$(bup index --check -p)" ""
24 WVPASSEQ "$(bup index --check -p $D)" ""
25 WVFAIL [ -e $D.fake ]
26 WVFAIL bup index --check -u $D.fake
27 WVPASS bup index --check -u $D
28 WVPASSEQ "$(bup index --check -p $D)" "$D/"
29 touch $D/a $D/b $D/f
30 mkdir $D/d $D/d/e
31 WVPASSEQ "$(bup index -s $D/)" "A $D/"
32 WVPASSEQ "$(bup index -s $D/b)" ""
33 bup tick
34 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
35 WVPASSEQ "$(bup index --check -us $D/b $D/d)" \
36 "A $D/d/e/
37 A $D/d/
38 A $D/b"
39 touch $D/d/z
40 WVPASSEQ "$(bup index --check -usx $D)" \
41 "A $D/f
42 A $D/d/z
43 A $D/d/e/
44 A $D/d/
45 A $D/b
46 A $D/a
47 A $D/"
48 WVPASSEQ "$(bup index --check -us $D/a $D/b --fake-valid)" \
49 "  $D/b
50   $D/a"
51 WVPASSEQ "$(bup index --check -us $D/a)" "  $D/a"  # stays unmodified
52 touch $D/a
53 WVPASS bup index -u $D/a  # becomes modified
54 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
55 "A $D/f
56 A $D/d/z
57 A $D/d/e/
58 A $D/d/
59   $D/b
60 M $D/a
61 A $D/"
62
63 # FIXME: currently directories are never marked unmodified, so -m just skips
64 # them.  Eventually, we should actually store the hashes of completed
65 # directories, at which time the output of -m will change, so we'll have to
66 # change this test too.
67 WVPASSEQ "$(cd $D && bup index -m .)" \
68 "./f
69 ./d/z
70 ./a"
71 WVPASSEQ "$(cd $D && bup index -m)" \
72 "f
73 d/z
74 a"
75 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
76
77
78 WVSTART "split"
79 WVPASS bup split --bench -b <t/testfile1 >tags1.tmp
80 WVPASS bup split -vvvv -b t/testfile2 >tags2.tmp
81 WVPASS bup margin
82 WVPASS bup midx -f
83 WVPASS bup margin
84 WVPASS bup split -t t/testfile2 >tags2t.tmp
85 WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp
86 WVPASS bup split -r "$BUP_DIR" -c t/testfile2 >tags2c.tmp
87 WVPASS ls -lR \
88    | WVPASS bup split -r "$BUP_DIR" -c --fanout 3 --max-pack-objects 3 -n lslr
89 WVPASS bup ls
90 WVFAIL bup ls /does-not-exist
91 WVPASS bup ls /lslr
92 WVPASS bup ls /lslr/1971-01-01   # all dates always exist
93 WVFAIL diff -u tags1.tmp tags2.tmp
94
95 # fanout must be different from non-fanout
96 WVFAIL diff -q tags2t.tmp tags2tf.tmp
97 wc -c t/testfile1 t/testfile2
98 wc -l tags1.tmp tags2.tmp
99
100 WVSTART "join"
101 WVPASS bup join $(cat tags1.tmp) >out1.tmp
102 WVPASS bup join <tags2.tmp >out2.tmp
103 WVPASS bup join <tags2t.tmp >out2t.tmp
104 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
105 WVPASS diff -u t/testfile1 out1.tmp
106 WVPASS diff -u t/testfile2 out2.tmp
107 WVPASS diff -u t/testfile2 out2t.tmp
108 WVPASS diff -u t/testfile2 out2c.tmp
109
110 WVSTART "save/git-fsck"
111 (
112     set -e
113     cd "$BUP_DIR" || exit 1
114     #git repack -Ad
115     #git prune
116     (cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || WVFAIL
117     n=$(git fsck --full --strict 2>&1 | 
118           egrep -v 'dangling (commit|tree)' |
119           tee -a /dev/stderr | 
120           wc -l)
121     WVPASS [ "$n" -eq 0 ]
122 ) || exit 1
123
124 WVSTART "fsck"
125 WVPASS bup fsck
126 if bup fsck --par2-ok; then
127     WVSTART "fsck (par2)"
128 else
129     WVSTART "fsck (PAR2 IS MISSING)"
130 fi
131 WVPASS bup fsck -g
132 WVPASS bup fsck -r
133 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
134 WVFAIL bup fsck
135 WVFAIL bup fsck --disable-par2
136 chmod u+w $BUP_DIR/objects/pack/*.idx
137 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
138 WVFAIL bup fsck -j4
139 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
140 WVFAIL bup fsck
141 WVFAIL bup fsck -rvv -j99   # fails because repairs were needed
142 if bup fsck --par2-ok; then
143     WVPASS bup fsck -r # ok because of repairs from last time
144     WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n201 -s1 --equal -S0
145     WVFAIL bup fsck
146     WVFAIL bup fsck -rvv   # too many errors to be repairable
147     WVFAIL bup fsck -r   # too many errors to be repairable
148 else
149     WVFAIL bup fsck -r # still fails because par2 was missing
150 fi