]> arthur.barton.de Git - bup.git/commitdiff
Add current-filesystem and path-filesystems to t/lib.sh; use to guard test.
authorRob Browning <rlb@defaultvalue.org>
Tue, 5 Nov 2013 22:29:53 +0000 (16:29 -0600)
committerRob Browning <rlb@defaultvalue.org>
Tue, 5 Nov 2013 22:52:42 +0000 (16:52 -0600)
Add current-filesystem which reports the current filesystem type, and
path-filesystems which reports all the filesystems back up to the
root, and use the latter to skip the "save --strip-path (no match)"
test whenever all the filesystems involved aren't the same type.

This issue was discovered while testing on
/some/ext4/tree/containing/a/btrfs/tree.  When the test indexes/saves,
it picks up the metadata for the parents above the btrfs, which may
have (for example) linux +e attrs.  Then when it tries to restore the
tree fully within the btrfs, the restore defers an error when it tries
to restore the +e, which isn't valid for btrfs.

Normally we can avoid this problem via --strip, but this particular
test is actually checking the behavior when --strip doesn't apply.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
t/lib.sh
t/test.sh

index 464037932c295ff3dd587388a43ca97be15e3b21..c0a62783878c35523d6d2ac3ce424bf154206373 100644 (file)
--- a/t/lib.sh
+++ b/t/lib.sh
@@ -1,4 +1,4 @@
-# Assumes shell is Bash.
+# Assumes shell is Bash, and pipefail is set.
 
 force-delete()
 {
@@ -35,3 +35,24 @@ realpath()
         "import sys, bup.helpers; print bup.helpers.realpath(sys.stdin.readline())" \
         || return $?
 }
+
+current-filesystem()
+{
+    df -T . | awk 'END{print $2}'
+}
+
+path-filesystems()
+(
+    # Return filesystem for each dir from $1 to /.
+    # Perhaps for /foo/bar, "ext4\next4\nbtrfs\n".
+    test "$#" -eq 1 || exit $?
+    cd "$1" || exit $?
+    current-filesystem || exit $?
+    dir="$(pwd)" || exit $?
+    while test "$dir" != /; do
+        cd .. || exit $?
+        dir="$(pwd)" || exit $?
+        current-filesystem || exit $?
+    done
+    exit 0
+)
index 8cadb083527f937b573b7d0263a4e318d00b241c..98b3ef3124780eb41e7ca0affd66afa0a9af514d 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -459,6 +459,16 @@ WVSTART "save --strip-path (absolute)"
 
 WVSTART "save --strip-path (no match)"
 (
+    if test $(WVPASS path-filesystems . | WVPASS sort -u | WVPASS wc -l) -ne 1
+    then
+        # Skip the test because the attempt to restore parent dirs to
+        # the current filesystem may fail -- i.e. running from
+        # /foo/ext4/bar/btrfs will fail when bup tries to restore
+        # linux attrs above btrfs to the restore tree *inside* btrfs.
+        echo "(running from tree with mixed filesystems; skipping test)" 1>&2
+        exit 0
+    fi
+
     tmp=graft-points.tmp
     WVPASS force-delete $tmp
     WVPASS mkdir $tmp