]> arthur.barton.de Git - bup.git/commitdiff
Return integers, not strings from get_commit_dates()
authorRob Browning <rlb@defaultvalue.org>
Wed, 30 Apr 2014 01:16:54 +0000 (20:16 -0500)
committerRob Browning <rlb@defaultvalue.org>
Mon, 12 May 2014 18:19:21 +0000 (13:19 -0500)
Returning strings broke bup fuse (surprising that it worked
elsewhere), and since we have no fuse tests, it wasn't immediately
apparent.

So fix the bug and add some initial (trivial) fuse tests so that at
least this particular problem doesn't happen again.

To cleanup after the fuse tests, detect fuse mounts in
t/cleanup-mounts-under, and try to unmount them.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Makefile
lib/bup/git.py
t/cleanup-mounts-under
t/test-fuse.sh [new file with mode: 0755]

index d8b19b55c8d00dfb3be3a94a77a8e3f38798e54a..8989838bd1ed3591df3f67d50ef0e8dab79557d2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -88,6 +88,7 @@ runtests-python: all
 
 runtests-cmdline: all
        test -e t/tmp || mkdir t/tmp
+       TMPDIR="$(test_tmp)" t/test-fuse.sh
        TMPDIR="$(test_tmp)" t/test-drecurse.sh
        TMPDIR="$(test_tmp)" t/test-cat-file.sh
        TMPDIR="$(test_tmp)" t/test-compression.sh
index 2552c45fdcac4321b0b9f9718192b3353e4b2eb7..1e2364aaf3b924e114eb6e264c34cd0eceb943db 100644 (file)
@@ -764,7 +764,7 @@ def get_commit_dates(refs):
     result = []
     cmd = ['git', 'show', '-s', '--pretty=format:%ct']
     for chunk in batchpipe(cmd, refs, preexec_fn=_gitenv):
-        result += chunk.splitlines()
+        result += [int(x) for x in chunk.splitlines()]
     return result
 
 
index 6d5cb873e5c704a5d497df75236a53bcece53244..a8ba61158cb528b4c53f536243e6a071354baaf5 100755 (executable)
@@ -23,10 +23,14 @@ for target in targets:
     top = os.path.realpath(target)
     proc_mounts = open('/proc/mounts', 'r')
     for line in proc_mounts:
-        _, point, _ = line.split(' ', 2)
+        _, point, fstype, _ = line.split(' ', 3)
         point = mntent_unescape(point)
         if top == point or os.path.commonprefix((top + '/', point)) == top + '/':
-            if subprocess.call(['umount', point]) != 0:
-                exit_status = 1
+            if fstype.startswith('fuse'):
+                if subprocess.call(['fusermount', '-uz', point]) != 0:
+                    exit_status = 1
+            else:
+                if subprocess.call(['umount', '-l', point]) != 0:
+                    exit_status = 1
 
 sys.exit(exit_status)
diff --git a/t/test-fuse.sh b/t/test-fuse.sh
new file mode 100755 (executable)
index 0000000..33567f9
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+. ./wvtest-bup.sh
+
+set -o pipefail
+
+if ! fusermount -V; then
+    echo 'skipping FUSE tests: fusermount does not appear to work'
+    exit 0
+fi
+
+if ! groups | grep -q fuse && test "$(t/root-status)" != root; then
+    echo 'skipping FUSE tests: you are not root and not in the fuse group'
+    exit 0
+fi
+
+top="$(WVPASS pwd)" || exit $?
+tmpdir="$(WVPASS wvmktempdir)" || exit $?
+
+export BUP_DIR="$tmpdir/bup"
+export GIT_DIR="$tmpdir/bup"
+
+bup() { "$top/bup" "$@"; }
+
+WVPASS bup init
+WVPASS cd "$tmpdir"
+
+savestamp1=$(WVPASS python -c 'import time; print int(time.time())') || exit $?
+savestamp2=$(($savestamp1 + 1))
+savename1="$(printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp1")" || exit $?
+savename2="$(printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp2")" || exit $?
+
+WVPASS mkdir src
+WVPASS date > src/foo
+WVPASS bup index src
+WVPASS bup save -n src -d "$savestamp1" --strip src
+
+WVSTART "basics"
+WVPASS mkdir mnt
+WVPASS bup fuse mnt
+
+result=$(WVPASS ls mnt) || exit $?
+WVPASSEQ src "$result"
+
+result=$(WVPASS ls mnt/src) || exit $?
+WVPASSEQ "$result" "$savename1
+latest"
+
+result=$(WVPASS ls mnt/src/latest) || exit $?
+WVPASSEQ "$result" "foo"
+
+# Right now we don't detect new saves.
+WVPASS bup save -n src -d "$savestamp2" --strip src
+result=$(WVPASS ls mnt/src) || exit $?
+savename="$(WVPASS printf '%(%Y-%m-%d-%H%M%S)T' "$savestamp1")" || exit $?
+WVPASSEQ "$result" "$savename1
+latest"
+
+WVPASS fusermount -uz mnt
+WVPASS rm -rf "$tmpdir"