]> arthur.barton.de Git - bup.git/blob - t/test-fuse.sh
e25f3f21d4f4c4ee7e62eff1eb0241442a7dd3d7
[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 # Some versions of bash's printf don't support the relevant date expansion.
32 savename()
33 {
34     readonly secs="$1"
35     WVPASS python -c "from time import strftime, localtime; \
36        print strftime('%Y-%m-%d-%H%M%S', localtime($secs))"
37 }
38
39 WVPASS bup init
40 WVPASS cd "$tmpdir"
41
42 savestamp1=$(WVPASS python -c 'import time; print int(time.time())') || exit $?
43 savestamp2=$(($savestamp1 + 1))
44 savename1="$(savename "$savestamp1")" || exit $?
45 savename2="$(savename "$savestamp2")" || exit $?
46
47 WVPASS mkdir src
48 WVPASS echo content > src/foo
49 WVPASS chmod 644 src/foo
50 WVPASS touch -t 201111111111 src/foo
51 # FUSE, python-fuse, something, can't handle negative epoch times.
52 # Use pre-epoch to make sure bup properly "bottoms out" at 0 for now.
53 WVPASS echo content > src/pre-epoch
54 WVPASS chmod 644 src/pre-epoch
55 WVPASS touch -t 196907202018 src/pre-epoch
56 WVPASS bup index src
57 WVPASS bup save -n src -d "$savestamp1" --strip src
58
59 WVSTART "basics"
60 WVPASS mkdir mnt
61 WVPASS bup fuse mnt
62
63 result=$(WVPASS ls mnt) || exit $?
64 WVPASSEQ src "$result"
65
66 result=$(WVPASS ls mnt/src) || exit $?
67 WVPASSEQ "$result" "$savename1
68 latest"
69
70 result=$(WVPASS ls mnt/src/latest) || exit $?
71 WVPASSEQ "$result" "foo
72 pre-epoch"
73
74 # Right now we don't detect new saves.
75 WVPASS bup save -n src -d "$savestamp2" --strip src
76 result=$(WVPASS ls mnt/src) || exit $?
77 WVPASSEQ "$result" "$savename1
78 latest"
79
80 WVPASS fusermount -uz mnt
81
82 WVSTART "extended metadata"
83 WVPASS bup fuse --meta mnt
84 result=$(TZ=UTC LC_ALL=C WVPASS ls -l mnt/src/latest/) || exit $?
85 readonly user=$(WVPASS id -un) || $?
86 readonly group=$(WVPASS id -gn) || $?
87 WVPASSEQ "$result" "total 0
88 -rw-r--r-- 1 $user $group 8 Nov 11  2011 foo
89 -rw-r--r-- 1 $user $group 8 Jan  1  1970 pre-epoch"
90
91 WVPASS fusermount -uz mnt
92 WVPASS rm -rf "$tmpdir"