]> arthur.barton.de Git - bup.git/blob - t/test-fuse.sh
Merge pull request #13 from Farioko/patch-1
[bup.git] / t / test-fuse.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3
4 set -o pipefail
5
6 unset BLOCKSIZE BLOCK_SIZE DF_BLOCK_SIZE
7
8 if test -n "$(type -p modprobe)" && ! modprobe fuse; then
9     echo 'Unable to load fuse module; skipping dependent tests.' 1>&2
10     exit 0
11 fi
12
13 if ! fusermount -V; then
14     echo 'skipping FUSE tests: fusermount does not appear to work'
15     exit 0
16 fi
17
18 if ! groups | grep -q fuse && test "$(t/root-status)" != root; then
19     echo 'skipping FUSE tests: you are not root and not in the fuse group'
20     exit 0
21 fi
22
23 top="$(WVPASS pwd)" || exit $?
24 tmpdir="$(WVPASS wvmktempdir)" || exit $?
25
26 export BUP_DIR="$tmpdir/bup"
27 export GIT_DIR="$tmpdir/bup"
28
29 bup() { "$top/bup" "$@"; }
30
31 WVPASS bup init
32 WVPASS cd "$tmpdir"
33
34 savestamp1=$(WVPASS python -c 'import time; print int(time.time())') || exit $?
35 savestamp2=$(($savestamp1 + 1))
36 savename1="$(printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp1")" || exit $?
37 savename2="$(printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp2")" || exit $?
38
39 WVPASS mkdir src
40 WVPASS echo content > src/foo
41 WVPASS chmod 644 src/foo
42 WVPASS touch -t 201111111111 src/foo
43 # FUSE, python-fuse, something, can't handle negative epoch times.
44 # Use pre-epoch to make sure bup properly "bottoms out" at 0 for now.
45 WVPASS echo content > src/pre-epoch
46 WVPASS chmod 644 src/pre-epoch
47 WVPASS touch -t 196907202018 src/pre-epoch
48 WVPASS bup index src
49 WVPASS bup save -n src -d "$savestamp1" --strip src
50
51 WVSTART "basics"
52 WVPASS mkdir mnt
53 WVPASS bup fuse mnt
54
55 result=$(WVPASS ls mnt) || exit $?
56 WVPASSEQ src "$result"
57
58 result=$(WVPASS ls mnt/src) || exit $?
59 WVPASSEQ "$result" "$savename1
60 latest"
61
62 result=$(WVPASS ls mnt/src/latest) || exit $?
63 WVPASSEQ "$result" "foo
64 pre-epoch"
65
66 # Right now we don't detect new saves.
67 WVPASS bup save -n src -d "$savestamp2" --strip src
68 result=$(WVPASS ls mnt/src) || exit $?
69 savename="$(WVPASS printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp1")" || exit $?
70 WVPASSEQ "$result" "$savename1
71 latest"
72
73 WVPASS fusermount -uz mnt
74
75 WVSTART "extended metadata"
76 WVPASS bup fuse --meta mnt
77 result=$(TZ=UTC LC_ALL=C WVPASS ls -l mnt/src/latest/) || exit $?
78 readonly user=$(WVPASS id -un) || $?
79 readonly group=$(WVPASS id -gn) || $?
80 WVPASSEQ "$result" "total 0
81 -rw-r--r-- 1 $user $group 8 Nov 11  2011 foo
82 -rw-r--r-- 1 $user $group 8 Jan  1  1970 pre-epoch"
83
84 WVPASS fusermount -uz mnt
85 WVPASS rm -rf "$tmpdir"