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