X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=t%2Ftest-fuse.sh;h=1ed35542473f09db017633c4b04317d7bfd68c0e;hb=bf67f94dd4f4096de4eee07a7dc377d6c889a016;hp=33567f9126fc4290c06db179b821f20871451336;hpb=c3052e6825c5501e5faaaf7137334513e9a172ed;p=bup.git diff --git a/t/test-fuse.sh b/t/test-fuse.sh index 33567f9..1ed3554 100755 --- a/t/test-fuse.sh +++ b/t/test-fuse.sh @@ -1,14 +1,29 @@ #!/usr/bin/env bash -. ./wvtest-bup.sh +. ./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 +fi + if ! fusermount -V; then echo 'skipping FUSE tests: fusermount does not appear to work' 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 @@ -21,16 +36,34 @@ 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)))" +} + +export TZ=UTC + 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 date > src/foo +WVPASS echo content > src/foo +WVPASS chmod 644 src/foo +WVPASS touch -t 201111111111 src/foo +# FUSE, python-fuse, something, can't handle negative epoch times. +# Use pre-epoch to make sure bup properly "bottoms out" at 0 for now. +WVPASS echo content > src/pre-epoch +WVPASS chmod 644 src/pre-epoch +WVPASS touch -t 196907202018 src/pre-epoch WVPASS bup index src WVPASS bup save -n src -d "$savestamp1" --strip src @@ -46,14 +79,28 @@ WVPASSEQ "$result" "$savename1 latest" result=$(WVPASS ls mnt/src/latest) || exit $? -WVPASSEQ "$result" "foo" +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" +WVPASS fusermount -uz mnt + +WVSTART "extended metadata" +WVPASS bup fuse --meta mnt +readonly user=$(WVPASS id -un) || $? +readonly group=$(WVPASS id -gn) || $? +result="$(stat --format='%A %U %G %x' mnt/src/latest/foo)" +WVPASSEQ "$result" "-rw-r--r-- $user $group 2011-11-11 11:11:00.000000000 +0000" +result="$(stat --format='%A %U %G %x' mnt/src/latest/pre-epoch)" +WVPASSEQ "$result" "-rw-r--r-- $user $group 1970-01-01 00:00:00.000000000 +0000" + WVPASS fusermount -uz mnt WVPASS rm -rf "$tmpdir"