X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=t%2Ftest-fuse.sh;h=4603e80f79e3b3a57a3073c440fd38d41302ed94;hb=2b27df29f67103f333f52a0888f89f589c5f135f;hp=c19918284cc30d2e401b81d2348b5b00a95c9c41;hpb=c7139a3fae51633f0f290ebf73f0cf5e4864e547;p=bup.git diff --git a/t/test-fuse.sh b/t/test-fuse.sh index c199182..4603e80 100755 --- a/t/test-fuse.sh +++ b/t/test-fuse.sh @@ -1,10 +1,18 @@ #!/usr/bin/env bash . ./wvtest-bup.sh || exit $? +. t/lib.sh || exit $? set -o pipefail unset BLOCKSIZE BLOCK_SIZE DF_BLOCK_SIZE +root_status="$(t/root-status)" || exit $? + +if ! bup-python -c 'import fuse' 2> /dev/null; then + WVSTART 'unable to import fuse; skipping test' + exit 0 +fi + if test -n "$(type -p modprobe)" && ! modprobe fuse; then echo 'Unable to load fuse module; skipping dependent tests.' 1>&2 exit 0 @@ -15,7 +23,7 @@ if ! fusermount -V; then exit 0 fi -if ! groups | grep -q fuse && test "$(t/root-status)" != root; then +if ! groups | grep -q fuse && test "$root_status" != root; then echo 'skipping FUSE tests: you are not root and not in the fuse group' exit 0 fi @@ -28,13 +36,22 @@ export GIT_DIR="$tmpdir/bup" bup() { "$top/bup" "$@"; } +# Some versions of bash's printf don't support the relevant date expansion. +savename() +{ + readonly secs="$1" + WVPASS bup-python -c "from time import strftime, localtime; \ + print strftime('%Y-%m-%d-%H%M%S', localtime($secs))" +} + WVPASS bup init WVPASS cd "$tmpdir" -savestamp1=$(WVPASS python -c 'import time; print int(time.time())') || exit $? +savestamp1=$(WVPASS bup-python -c 'import time; print int(time.time())') || exit $? savestamp2=$(($savestamp1 + 1)) -savename1="$(printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp1")" || exit $? -savename2="$(printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp2")" || exit $? + +savename1="$(savename "$savestamp1")" || exit $? +savename2="$(savename "$savestamp2")" || exit $? WVPASS mkdir src WVPASS echo content > src/foo @@ -63,10 +80,12 @@ result=$(WVPASS ls mnt/src/latest) || exit $? WVPASSEQ "$result" "foo pre-epoch" +result=$(WVPASS cat mnt/src/latest/foo) || exit $? +WVPASSEQ "$result" "content" + # Right now we don't detect new saves. WVPASS bup save -n src -d "$savestamp2" --strip src result=$(WVPASS ls mnt/src) || exit $? -savename="$(WVPASS printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp1")" || exit $? WVPASSEQ "$result" "$savename1 latest" @@ -77,7 +96,7 @@ WVPASS bup fuse --meta mnt result=$(TZ=UTC LC_ALL=C WVPASS ls -l mnt/src/latest/) || exit $? readonly user=$(WVPASS id -un) || $? readonly group=$(WVPASS id -gn) || $? -WVPASSEQ "$result" "total 0 +WVPASSEQ "$result" "total 1 -rw-r--r-- 1 $user $group 8 Nov 11 2011 foo -rw-r--r-- 1 $user $group 8 Jan 1 1970 pre-epoch"