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