]> arthur.barton.de Git - bup.git/blob - t/test.sh
fsck: add a -j# (run multiple threads) option.
[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 -p)" ""
24 WVPASSEQ "$(bup index -p $D)" ""
25 WVFAIL [ -e $D.fake ]
26 WVFAIL bup index -u $D.fake
27 WVPASS bup index -u $D
28 WVPASSEQ "$(bup index -p $D)" "$D/"
29 touch $D/a $D/b
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 -us $D/b)" "A $D/b"
35 WVPASSEQ "$(bup index -us $D)" \
36 "A $D/d/e/
37 A $D/d/
38 A $D/b
39 A $D/a
40 A $D/"
41 WVPASSEQ "$(bup index -us $D/a $D/b --fake-valid)" \
42 "  $D/b
43   $D/a"
44 WVPASSEQ "$(bup index -us $D/a)" "  $D/a"  # stays unmodified
45 touch $D/a
46 WVPASS bup index -u $D/a  # becomes modified
47 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
48 "A $D/d/e/
49 A $D/d/
50   $D/b
51 M $D/a
52 A $D/"
53
54 # FIXME: currently directories are never marked unmodified, so -m just skips
55 # them.  Eventually, we should actually store the hashes of completed
56 # directories, at which time the output of -m will change, so we'll have to
57 # change this test too.
58 WVPASSEQ "$(cd $D && bup index -m .)" \
59 "./a"
60 WVPASSEQ "$(cd $D && bup index -m)" \
61 "a"
62 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
63
64
65 WVSTART "split"
66 WVPASS bup split --bench -b <testfile1 >tags1.tmp
67 WVPASS bup split -vvvv -b testfile2 >tags2.tmp
68 WVPASS bup split -t testfile2 >tags2t.tmp
69 WVPASS bup split -t testfile2 --fanout 3 >tags2tf.tmp
70 WVPASS bup split -r "$BUP_DIR" -c testfile2 >tags2c.tmp
71 WVPASS ls -lR \
72    | WVPASS bup split -r "$BUP_DIR" -c --fanout 3 --max-pack-objects 3 -n lslr
73 WVFAIL diff -u tags1.tmp tags2.tmp
74
75 # fanout must be different from non-fanout
76 WVFAIL diff -q tags2t.tmp tags2tf.tmp
77 wc -c testfile1 testfile2
78 wc -l tags1.tmp tags2.tmp
79
80 WVSTART "join"
81 WVPASS bup join $(cat tags1.tmp) >out1.tmp
82 WVPASS bup join <tags2.tmp >out2.tmp
83 WVPASS bup join <tags2t.tmp >out2t.tmp
84 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
85 WVPASS diff -u testfile1 out1.tmp
86 WVPASS diff -u testfile2 out2.tmp
87 WVPASS diff -u testfile2 out2t.tmp
88 WVPASS diff -u testfile2 out2c.tmp
89
90 WVSTART "save/git-fsck"
91 (
92     set -e
93     cd "$BUP_DIR" || exit 1
94     #git repack -Ad
95     #git prune
96     (cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || WVFAIL
97     n=$(git fsck --full --strict 2>&1 | 
98           egrep -v 'dangling (commit|tree)' |
99           tee -a /dev/stderr | 
100           wc -l)
101     WVPASS [ "$n" -eq 0 ]
102 ) || exit 1
103
104 WVSTART "fsck"
105 WVPASS bup fsck
106 if bup fsck --par2-ok; then
107     WVSTART "fsck (par2)"
108 else
109     WVSTART "fsck (PAR2 IS MISSING)"
110 fi
111 WVPASS bup fsck -g
112 WVPASS bup fsck -r
113 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
114 WVFAIL bup fsck
115 WVFAIL bup fsck --disable-par2
116 chmod u+w $BUP_DIR/objects/pack/*.idx
117 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
118 WVFAIL bup fsck -j4
119 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
120 WVFAIL bup fsck
121 WVFAIL bup fsck -rvv -j99   # fails because repairs were needed
122 if bup fsck --par2-ok; then
123     WVPASS bup fsck -r # ok because of repairs from last time
124     WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n201 -s1 --equal -S0
125     WVFAIL bup fsck
126     WVFAIL bup fsck -rvv   # too many errors to be repairable
127     WVFAIL bup fsck -r   # too many errors to be repairable
128 else
129     WVFAIL bup fsck -r # still fails because par2 was missing
130 fi