]> arthur.barton.de Git - bup.git/blob - t/test.sh
Merge branch 'indexrewrite'
[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 midx -a
82 WVPASS bup split -t t/testfile2 >tags2t.tmp
83 WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp
84 WVPASS bup split -r "$BUP_DIR" -c t/testfile2 >tags2c.tmp
85 WVPASS ls -lR \
86    | WVPASS bup split -r "$BUP_DIR" -c --fanout 3 --max-pack-objects 3 -n lslr
87 WVFAIL diff -u tags1.tmp tags2.tmp
88
89 # fanout must be different from non-fanout
90 WVFAIL diff -q tags2t.tmp tags2tf.tmp
91 wc -c t/testfile1 t/testfile2
92 wc -l tags1.tmp tags2.tmp
93
94 WVSTART "join"
95 WVPASS bup join $(cat tags1.tmp) >out1.tmp
96 WVPASS bup join <tags2.tmp >out2.tmp
97 WVPASS bup join <tags2t.tmp >out2t.tmp
98 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
99 WVPASS diff -u t/testfile1 out1.tmp
100 WVPASS diff -u t/testfile2 out2.tmp
101 WVPASS diff -u t/testfile2 out2t.tmp
102 WVPASS diff -u t/testfile2 out2c.tmp
103
104 WVSTART "save/git-fsck"
105 (
106     set -e
107     cd "$BUP_DIR" || exit 1
108     #git repack -Ad
109     #git prune
110     (cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || WVFAIL
111     n=$(git fsck --full --strict 2>&1 | 
112           egrep -v 'dangling (commit|tree)' |
113           tee -a /dev/stderr | 
114           wc -l)
115     WVPASS [ "$n" -eq 0 ]
116 ) || exit 1
117
118 WVSTART "fsck"
119 WVPASS bup fsck
120 if bup fsck --par2-ok; then
121     WVSTART "fsck (par2)"
122 else
123     WVSTART "fsck (PAR2 IS MISSING)"
124 fi
125 WVPASS bup fsck -g
126 WVPASS bup fsck -r
127 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
128 WVFAIL bup fsck
129 WVFAIL bup fsck --disable-par2
130 chmod u+w $BUP_DIR/objects/pack/*.idx
131 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
132 WVFAIL bup fsck -j4
133 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
134 WVFAIL bup fsck
135 WVFAIL bup fsck -rvv -j99   # fails because repairs were needed
136 if bup fsck --par2-ok; then
137     WVPASS bup fsck -r # ok because of repairs from last time
138     WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n201 -s1 --equal -S0
139     WVFAIL bup fsck
140     WVFAIL bup fsck -rvv   # too many errors to be repairable
141     WVFAIL bup fsck -r   # too many errors to be repairable
142 else
143     WVFAIL bup fsck -r # still fails because par2 was missing
144 fi