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