1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
#!/usr/bin/env bash
. wvtest.sh
. wvtest-bup.sh
. dev/lib.sh
set -o pipefail
top="$(WVPASS pwd)" || exit $?
tmpdir="$(WVPASS wvmktempdir)" || exit $?
export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$tmpdir/bup"
bup() { "$top/bup" "$@"; }
sha1sum() { "$top/dev/checksum" -t sha1 "$@"; }
with-tty() { "$top/dev/with-tty" "$@"; }
WVPASS cd "$tmpdir"
WVSTART "init"
WVPASS bup init
# Be independent of git defaults or a configured defaultBranch
git --git-dir "$BUP_DIR" symbolic-ref HEAD refs/heads/main
D=bupdata.tmp
WVPASS force-delete $D
WVPASS mkdir $D
WVPASS touch $D/a
WVPASS bup random 128k >$D/b
WVPASS mkdir $D/d $D/d/e
WVPASS bup random 512 >$D/f
WVPASS touch $D/d/z
WVPASS touch $D/d/z
WVPASS bup index $D
WVPASS bup save -t $D
WVSTART "bloom"
WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
WVPASS rm "$BUP_DIR"/objects/pack/bup.bloom
WVPASS bup bloom -k 4
WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
WVPASS bup bloom -d "$BUP_DIR"/objects/pack --ruin --force
WVFAIL bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
WVPASS bup bloom --force -k 5
WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
WVSTART "memtest"
WVPASS bup memtest -c1 -n100
WVPASS bup memtest -c1 -n100 --existing
WVSTART "save/git-fsck"
(
WVPASS cd "$BUP_DIR"
#git repack -Ad
#git prune
WVPASS bup random 4k | WVPASS bup split -b
(WVPASS cd "$top/test/sampledata" && WVPASS bup save -vvn main /) || exit $?
result="$(LC_ALL=C git fsck --full --strict 2>&1)" || exit $?
n=$(echo "$result" |
WVFAIL egrep -v 'dangling (commit|tree|blob)' |
WVPASS tee -a /dev/stderr |
WVPASS wc -l) || exit $?
WVPASS [ "$n" -eq 0 ]
) || exit $?
WVSTART "pack name and idx same as git"
(
# reuse packs from previous test
WVPASS cd "$BUP_DIR"/objects/pack/
WVPASS ls *.pack
for pack in *.pack ; do
bup_idx_sha=$(sha1sum $(basename $pack .pack).idx) || exit $?
gitname=$(git index-pack $pack) || exit $?
# make sure we named it correctly (like git)
WVPASSEQ pack-$gitname.pack $pack
# make sure we wrote the index correctly
git_idx_sha=$(sha1sum $(basename $pack .pack).idx) || exit $?
WVPASSEQ "$bup_idx_sha" "$git_idx_sha"
done
) || exit $?
WVSTART "ftp"
WVPASS bup ftp "cat /main/latest/$tmpdir/$D/b" >$D/b.new
WVPASS bup ftp "cat /main/latest/$tmpdir/$D/f" >$D/f.new
WVPASS bup ftp "cat /main/latest/$tmpdir/$D/f"{,} >$D/f2.new
WVPASS bup ftp "cat /main/latest/$tmpdir/$D/a" >$D/a.new
WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
WVSTART "tag"
WVFAIL bup tag -d v0.n 2>/dev/null
WVFAIL bup tag v0.n non-existant 2>/dev/null
WVPASSEQ "$(bup tag)" ""
WVPASS bup tag v0.1 main
WVPASSEQ "$(bup tag)" "v0.1"
WVFAIL bup tag v0.1 main
WVPASS bup tag -f v0.1 main
WVPASS bup tag -d v0.1
WVPASS bup tag -f -d v0.1
WVFAIL bup tag -d v0.1
WVSTART "indexfile"
D=indexfile.tmp
INDEXFILE=tmpindexfile.tmp
WVPASS rm -f $INDEXFILE
WVPASS force-delete $D
WVPASS mkdir $D
export BUP_DIR="$D/.bup"
WVPASS bup init
WVPASS touch $D/a
WVPASS touch $D/b
WVPASS mkdir $D/c
WVPASS bup index -ux $D
WVPASS bup save --strip -n bupdir $D
WVPASSEQ "$(bup ls -F bupdir/latest/)" "a
b
c/"
WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
WVPASS bup save --strip -n indexfile -f $INDEXFILE $D
WVPASSEQ "$(bup ls indexfile/latest/)" "a
b"
WVSTART "import-rsnapshot"
# NOTE: if this test is made optional, say if it eventually depends on
# rsnapshot being installed, we might want to add other "interactive
# external command" tests (see script below) to maintain coverage.
export BUP_DIR="$tmpdir/rsnapshot/.bup"
WVPASS rm -rf rsnapshot
WVPASS mkdir rsnapshot
WVPASS bup init
WVPASS mkdir -p rsnapshot/hourly.0/buptest/a
WVPASS touch rsnapshot/hourly.0/buptest/a/b
WVPASS mkdir -p rsnapshot/hourly.0/buptest/c/d
WVPASS touch rsnapshot/hourly.0/buptest/c/d/e
WVPASS bup import-rsnapshot rsnapshot/
WVPASSEQ "$(bup ls -F buptest/latest/)" "a/
c/"
if ! with-tty true; then
WVSKIP 'Skipping interactive import-snapshot test (no script command)'
else
WVPASS rm -rf "$BUP_DIR"
WVPASS bup init
WVPASS with-tty "$top/bup" import-rsnapshot rsnapshot/
WVPASSEQ "$(bup ls -F buptest/latest/)" "a/
c/"
fi
WVPASS rm -rf rsnapshot
WVSTART features
expect_py_ver=$(LC_CTYPE=C "$top/dev/python" \
-c 'import platform; print(platform.python_version())') \
|| exit $?
actual_py_ver=$(bup features | grep Python: | sed -Ee 's/ +Python: //') || exit $?
WVPASSEQ "$expect_py_ver" "$actual_py_ver"
WVSTART id-other-than
result=$("$top/dev/id-other-than" --user 0) || exit $?
WVPASS echo "$result" | WVPASS grep -qE '.*:[0-9]+$'
result=$("$top/dev/id-other-than" --group 0) || exit $?
WVPASS echo "$result" | WVPASS grep -qE '.*:[0-9]+$'
WVPASS rm -rf "$tmpdir"
|