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