]> arthur.barton.de Git - bup.git/blob - t/test.sh
512ddb6455c3c93853e07b29f67468dac8097f9a
[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 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
34 WVPASSEQ "$(bup index --check -us $D/b $D/d)" \
35 "A $D/d/e/
36 A $D/d/
37 A $D/b"
38 touch $D/d/z
39 bup tick
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 WVPASSEQ "$(bup index --check -us $D/d --fake-valid)" \
53 "  $D/d/z
54   $D/d/e/
55   $D/d/"
56 touch $D/d/z
57 WVPASS bup index -u $D/d/z  # becomes modified
58 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
59 "A $D/f
60 M $D/d/z
61   $D/d/e/
62 M $D/d/
63   $D/b
64   $D/a
65 A $D/"
66
67 WVPASS bup index -u $D/d/e $D/a --fake-invalid
68 WVPASSEQ "$(cd $D && bup index -m .)" \
69 "./f
70 ./d/z
71 ./d/e/
72 ./d/
73 ./a
74 ./"
75 WVPASSEQ "$(cd $D && bup index -m)" \
76 "f
77 d/z
78 d/e/
79 d/
80 a
81 ./"
82 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
83
84 WVPASS bup save -t $D/d/e
85 WVPASSEQ "$(cd $D && bup index -m)" \
86 "f
87 d/z
88 d/
89 a
90 ./"
91 WVPASS bup save -t $D/d
92 WVPASSEQ "$(cd $D && bup index -m)" \
93 "f
94 a
95 ./"
96 tree1=$(bup save -t $D)
97 WVPASSEQ "$(cd $D && bup index -m)" ""
98 tree2=$(bup save -t $D)
99 WVPASSEQ "$tree1" "$tree2"
100 WVPASSEQ "$(bup index -s / | grep ^D)" ""
101 tree3=$(bup save -t /)
102 WVPASSEQ "$tree1" "$tree3"
103
104 WVSTART "split"
105 WVPASS bup split --bench -b <t/testfile1 >tags1.tmp
106 WVPASS bup split -vvvv -b t/testfile2 >tags2.tmp
107 WVPASS bup margin
108 WVPASS bup midx -f
109 WVPASS bup margin
110 WVPASS bup split -t t/testfile2 >tags2t.tmp
111 WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp
112 WVPASS bup split -r "$BUP_DIR" -c t/testfile2 >tags2c.tmp
113 WVPASS ls -lR \
114    | WVPASS bup split -r "$BUP_DIR" -c --fanout 3 --max-pack-objects 3 -n lslr
115 WVPASS bup ls
116 WVFAIL bup ls /does-not-exist
117 WVPASS bup ls /lslr
118 #WVPASS bup ls /lslr/1971-01-01   # all dates always exist
119 WVFAIL diff -u tags1.tmp tags2.tmp
120
121 # fanout must be different from non-fanout
122 WVFAIL diff -q tags2t.tmp tags2tf.tmp
123 wc -c t/testfile1 t/testfile2
124 wc -l tags1.tmp tags2.tmp
125
126 WVSTART "join"
127 WVPASS bup join $(cat tags1.tmp) >out1.tmp
128 WVPASS bup join <tags2.tmp >out2.tmp
129 WVPASS bup join <tags2t.tmp >out2t.tmp
130 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
131 WVPASS diff -u t/testfile1 out1.tmp
132 WVPASS diff -u t/testfile2 out2.tmp
133 WVPASS diff -u t/testfile2 out2t.tmp
134 WVPASS diff -u t/testfile2 out2c.tmp
135
136 WVSTART "save/git-fsck"
137 (
138     set -e
139     cd "$BUP_DIR" || exit 1
140     #git repack -Ad
141     #git prune
142     (cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || WVFAIL
143     n=$(git fsck --full --strict 2>&1 | 
144           egrep -v 'dangling (commit|tree)' |
145           tee -a /dev/stderr | 
146           wc -l)
147     WVPASS [ "$n" -eq 0 ]
148 ) || exit 1
149
150 WVSTART "fsck"
151 WVPASS bup fsck
152 WVPASS bup fsck --quick
153 if bup fsck --par2-ok; then
154     WVSTART "fsck (par2)"
155 else
156     WVSTART "fsck (PAR2 IS MISSING)"
157 fi
158 WVPASS bup fsck -g
159 WVPASS bup fsck -r
160 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
161 WVFAIL bup fsck --quick
162 WVFAIL bup fsck --quick --disable-par2
163 chmod u+w $BUP_DIR/objects/pack/*.idx
164 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
165 WVFAIL bup fsck --quick -j4
166 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
167 WVFAIL bup fsck --quick
168 WVFAIL bup fsck --quick -rvv -j99   # fails because repairs were needed
169 if bup fsck --par2-ok; then
170     WVPASS bup fsck -r # ok because of repairs from last time
171     WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n202 -s1 --equal -S0
172     WVFAIL bup fsck
173     WVFAIL bup fsck -rvv   # too many errors to be repairable
174     WVFAIL bup fsck -r   # too many errors to be repairable
175 else
176     WVFAIL bup fsck --quick -r # still fails because par2 was missing
177 fi