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