]> arthur.barton.de Git - bup.git/blob - test/ext/test-misc
34d65eb5d657658bf90bf150719a169cbb1c5f33
[bup.git] / test / ext / test-misc
1 #!/usr/bin/env bash
2 . wvtest.sh
3 . wvtest-bup.sh
4 . dev/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 sha1sum() { "$top/dev/checksum" -t sha1 "$@"; }
14
15 WVPASS cd "$tmpdir"
16
17 WVSTART "init"
18 WVPASS bup init
19 D=bupdata.tmp
20 WVPASS force-delete $D
21 WVPASS mkdir $D
22 WVPASS touch $D/a
23 WVPASS bup random 128k >$D/b
24 WVPASS mkdir $D/d $D/d/e
25 WVPASS bup random 512 >$D/f
26 WVPASS touch $D/d/z
27 WVPASS touch $D/d/z
28 WVPASS bup index $D
29 WVPASS bup save -t $D
30
31
32 WVSTART "bloom"
33 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
34 WVPASS rm "$BUP_DIR"/objects/pack/bup.bloom
35 WVPASS bup bloom -k 4
36 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
37 WVPASS bup bloom -d "$BUP_DIR"/objects/pack --ruin --force
38 WVFAIL bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
39 WVPASS bup bloom --force -k 5
40 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
41
42
43 WVSTART "memtest"
44 WVPASS bup memtest -c1 -n100
45 WVPASS bup memtest -c1 -n100 --existing
46
47
48 WVSTART "save/git-fsck"
49 (
50     WVPASS cd "$BUP_DIR"
51     #git repack -Ad
52     #git prune
53     WVPASS bup random 4k | WVPASS bup split -b
54     (WVPASS cd "$top/test/sampledata" && WVPASS bup save -vvn master /) || exit $?
55     result="$(LC_ALL=C git fsck --full --strict 2>&1)" || exit $?
56     n=$(echo "$result" |
57         WVFAIL egrep -v 'dangling (commit|tree|blob)' |
58         WVPASS tee -a /dev/stderr |
59         WVPASS wc -l) || exit $?
60     WVPASS [ "$n" -eq 0 ]
61 ) || exit $?
62
63
64 WVSTART "pack name and idx same as git"
65 (
66     # reuse packs from previous test
67     WVPASS cd "$BUP_DIR"/objects/pack/
68     WVPASS ls *.pack
69     for pack in *.pack ; do
70        bup_idx_sha=$(sha1sum $(basename $pack .pack).idx) || exit $?
71        gitname=$(git index-pack $pack) || exit $?
72        # make sure we named it correctly (like git)
73        WVPASSEQ pack-$gitname.pack $pack
74        # make sure we wrote the index correctly
75        git_idx_sha=$(sha1sum $(basename $pack .pack).idx) || exit $?
76        WVPASSEQ "$bup_idx_sha" "$git_idx_sha"
77     done
78 ) || exit $?
79
80
81 WVSTART "ftp"
82 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/b" >$D/b.new
83 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/f" >$D/f.new
84 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/f"{,} >$D/f2.new
85 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/a" >$D/a.new
86 WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
87 WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
88 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
89 WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
90
91
92 WVSTART "tag"
93 WVFAIL bup tag -d v0.n 2>/dev/null
94 WVFAIL bup tag v0.n non-existant 2>/dev/null
95 WVPASSEQ "$(bup tag)" ""
96 WVPASS bup tag v0.1 master
97 WVPASSEQ "$(bup tag)" "v0.1"
98 WVFAIL bup tag v0.1 master
99 WVPASS bup tag -f v0.1 master
100 WVPASS bup tag -d v0.1
101 WVPASS bup tag -f -d v0.1
102 WVFAIL bup tag -d v0.1
103
104
105 WVSTART "indexfile"
106 D=indexfile.tmp
107 INDEXFILE=tmpindexfile.tmp
108 WVPASS rm -f $INDEXFILE
109 WVPASS force-delete $D
110 WVPASS mkdir $D
111 export BUP_DIR="$D/.bup"
112 WVPASS bup init
113 WVPASS touch $D/a
114 WVPASS touch $D/b
115 WVPASS mkdir $D/c
116 WVPASS bup index -ux $D
117 WVPASS bup save --strip -n bupdir $D
118 WVPASSEQ "$(bup ls -F bupdir/latest/)" "a
119 b
120 c/"
121 WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
122 WVPASS bup save --strip -n indexfile -f $INDEXFILE $D
123 WVPASSEQ "$(bup ls indexfile/latest/)" "a
124 b"
125
126
127 WVSTART "import-rsnapshot"
128 D=rsnapshot.tmp
129 export BUP_DIR="$tmpdir/$D/.bup"
130 WVPASS force-delete $D
131 WVPASS mkdir $D
132 WVPASS bup init
133 WVPASS mkdir -p $D/hourly.0/buptest/a
134 WVPASS touch $D/hourly.0/buptest/a/b
135 WVPASS mkdir -p $D/hourly.0/buptest/c/d
136 WVPASS touch $D/hourly.0/buptest/c/d/e
137 WVPASS true
138 WVPASS bup import-rsnapshot $D/
139 WVPASSEQ "$(bup ls -F buptest/latest/)" "a/
140 c/"
141
142
143 WVSTART features
144 expect_py_ver=$(LC_CTYPE=C "$top/dev/python" \
145                         -c 'import platform; print(platform.python_version())') \
146     || exit $?
147 actual_py_ver=$(bup features | grep Python: | sed -Ee 's/ +Python: //') || exit $?
148 WVPASSEQ "$expect_py_ver" "$actual_py_ver"
149
150
151 WVSTART id-other-than
152 result=$("$top/dev/id-other-than" --user 0) ||  exit $?
153 WVPASS echo "$result" | WVPASS grep -qE '.*:[0-9]+$'
154 result=$("$top/dev/id-other-than" --group 0) ||  exit $?
155 WVPASS echo "$result" | WVPASS grep -qE '.*:[0-9]+$'
156
157
158 WVPASS rm -rf "$tmpdir"