]> arthur.barton.de Git - bup.git/commitdiff
test-meta.sh: move mount points to t/mnt
authorRob Browning <rlb@defaultvalue.org>
Mon, 19 Jan 2015 19:36:32 +0000 (13:36 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sun, 1 Feb 2015 17:55:40 +0000 (11:55 -0600)
When root, don't create test mount points in ./bupmeta.tmp, use
t/wvmkmountpt.

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

index e522355cf21ba7418ed789149b24a7c0aee43699..b129a7e08f1818770d0d213c972bb139498ca80a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -183,12 +183,8 @@ clean: Documentation/clean config/clean
        if test -e t/mnt; then rm -r t/mnt; fi
        if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
         # FIXME: migrate these to t/mnt/
-       if test -e bupmeta.tmp/testfs; \
-         then umount bupmeta.tmp/testfs || true; fi
        if test -e lib/bup/t/testfs; \
          then umount lib/bup/t/testfs || true; fi
-       if test -e bupmeta.tmp/testfs-limited; \
-         then umount bupmeta.tmp/testfs-limited || true; fi
        rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
        if test -e t/tmp; then t/force-delete t/tmp; fi
        t/configure-sampledata --clean
index cfd22e488b481b8c4aa20429d28779bd75afba5b..f4481634dbdbd5ecf142fad44b01db3f9e6dc682 100755 (executable)
@@ -4,6 +4,8 @@
 
 set -o pipefail
 
+root_status="$(t/root-status)" || exit $?
+
 TOP="$(WVPASS pwd)" || exit $?
 tmpdir="$(WVPASS wvmktempdir)" || exit $?
 
@@ -18,8 +20,6 @@ atime_resolution="$(echo $timestamp_resolutions | WVPASS cut -d' ' -f 1)" \
 mtime_resolution="$(echo $timestamp_resolutions | WVPASS cut -d' ' -f 2)" \
     || exit $?
 
-root_status="$(t/root-status)" || exit $?
-
 bup()
 {
     "$TOP/bup" "$@"
@@ -101,16 +101,6 @@ test-src-save-restore()
     )
 }
 
-universal-cleanup()
-{
-    if [ "$root_status" != root ]; then return 0; fi
-    umount "$TOP/bupmeta.tmp/testfs" || true
-    umount "$TOP/bupmeta.tmp/testfs-limited" || true
-}
-
-WVPASS universal-cleanup
-trap universal-cleanup EXIT
-
 setup-test-tree()
 {
     WVPASS force-delete "$BUP_DIR"
@@ -631,11 +621,14 @@ if [ "$root_status" = root ]; then
             exit 0
         fi
 
+        testfs="$(WVPASS wvmkmountpt)" || exit $?
+        testfs_limited="$(WVPASS wvmkmountpt)" || exit $?
+
         WVSTART 'meta - general (as root)'
         WVPASS setup-test-tree
         WVPASS cd "$TOP/bupmeta.tmp"
 
-        umount testfs
+        umount "$testfs"
         WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32
         # Make sure we have all the options the chattr test needs
         # (i.e. create a "normal" ext4 filesystem).
@@ -643,34 +636,32 @@ if [ "$root_status" = root ]; then
             -I 256 \
             -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize \
             testfs.img
-        WVPASS mkdir testfs
-        WVPASS mount -o loop,acl,user_xattr testfs.img testfs
+        WVPASS mount -o loop,acl,user_xattr testfs.img "$testfs"
         # Hide, so that tests can't create risks.
-        WVPASS chown root:root testfs
-        WVPASS chmod 0700 testfs
+        WVPASS chown root:root "$testfs"
+        WVPASS chmod 0700 "$testfs"
 
-        umount testfs-limited
+        umount "$testfs_limited"
         WVPASS dd if=/dev/zero of=testfs-limited.img bs=1M count=32
         WVPASS mkfs -t vfat testfs-limited.img
-        WVPASS mkdir testfs-limited
         WVPASS mount -o loop,uid=root,gid=root,umask=0077 \
-            testfs-limited.img testfs-limited
+            testfs-limited.img "$testfs_limited"
 
-        WVPASS cp -pPR src testfs/src
-        (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
+        WVPASS cp -pPR src "$testfs"/src
+        (WVPASS cd "$testfs"; WVPASS test-src-create-extract) || exit $?
 
         WVSTART 'meta - atime (as root)'
-        WVPASS force-delete testfs/src
-        WVPASS mkdir testfs/src
+        WVPASS force-delete "$testfs"/src
+        WVPASS mkdir "$testfs"/src
         (
-            WVPASS mkdir testfs/src/foo
-            WVPASS touch testfs/src/bar
+            WVPASS mkdir "$testfs"/src/foo
+            WVPASS touch "$testfs"/src/bar
             PYTHONPATH="$TOP/lib" \
                 WVPASS python -c "from bup import xstat; \
                 x = xstat.timespec_to_nsecs((42, 0));\
-                   xstat.utime('testfs/src/foo', (x, x));\
-                   xstat.utime('testfs/src/bar', (x, x));"
-            WVPASS cd testfs
+                   xstat.utime('$testfs/src/foo', (x, x));\
+                   xstat.utime('$testfs/src/bar', (x, x));"
+            WVPASS cd "$testfs"
             WVPASS bup meta -v --create --recurse --file src.meta src
             WVPASS bup meta -tvf src.meta
             # Test extract.
@@ -690,22 +681,22 @@ if [ "$root_status" = root ]; then
         ) || exit $?
 
         WVSTART 'meta - Linux attr (as root)'
-        WVPASS force-delete testfs/src
-        WVPASS mkdir testfs/src
+        WVPASS force-delete "$testfs"/src
+        WVPASS mkdir "$testfs"/src
         (
-            WVPASS touch testfs/src/foo
-            WVPASS mkdir testfs/src/bar
-            WVPASS chattr +acdeijstuADST testfs/src/foo
-            WVPASS chattr +acdeijstuADST testfs/src/bar
-            (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
+            WVPASS touch "$testfs"/src/foo
+            WVPASS mkdir "$testfs"/src/bar
+            WVPASS chattr +acdeijstuADST "$testfs"/src/foo
+            WVPASS chattr +acdeijstuADST "$testfs"/src/bar
+            (WVPASS cd "$testfs"; WVPASS test-src-create-extract) || exit $?
             # Test restoration to a limited filesystem (vfat).
             (
-                WVPASS bup meta --create --recurse --file testfs/src.meta \
-                    testfs/src
-                WVPASS force-delete testfs-limited/src-restore
-                WVPASS mkdir testfs-limited/src-restore
-                WVPASS cd testfs-limited/src-restore
-                WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
+                WVPASS bup meta --create --recurse --file "$testfs"/src.meta \
+                    "$testfs"/src
+                WVPASS force-delete "$testfs_limited"/src-restore
+                WVPASS mkdir "$testfs_limited"/src-restore
+                WVPASS cd "$testfs_limited"/src-restore
+                WVFAIL bup meta --extract --file "$testfs"/src.meta 2>&1 \
                     | WVPASS grep -e '^Linux chattr:' \
                     | WVPASS python -c \
                     'import sys; exit(not len(sys.stdin.readlines()) == 3)'
@@ -713,49 +704,54 @@ if [ "$root_status" = root ]; then
         ) || exit $?
 
         WVSTART 'meta - Linux xattr (as root)'
-        WVPASS force-delete testfs/src
-        WVPASS mkdir testfs/src
-        WVPASS touch testfs/src/foo
-        WVPASS mkdir testfs/src/bar
-        WVPASS attr -s foo -V bar testfs/src/foo
-        WVPASS attr -s foo -V bar testfs/src/bar
-        (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
+        WVPASS force-delete "$testfs"/src
+        WVPASS mkdir "$testfs"/src
+        WVPASS touch "$testfs"/src/foo
+        WVPASS mkdir "$testfs"/src/bar
+        WVPASS attr -s foo -V bar "$testfs"/src/foo
+        WVPASS attr -s foo -V bar "$testfs"/src/bar
+        (WVPASS cd "$testfs"; WVPASS test-src-create-extract) || exit $?
 
         # Test restoration to a limited filesystem (vfat).
         (
-            WVPASS bup meta --create --recurse --file testfs/src.meta \
-                testfs/src
-            WVPASS force-delete testfs-limited/src-restore
-            WVPASS mkdir testfs-limited/src-restore
-            WVPASS cd testfs-limited/src-restore
-            WVFAIL bup meta --extract --file ../../testfs/src.meta
-            WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
+            WVPASS bup meta --create --recurse --file "$testfs"/src.meta \
+                "$testfs"/src
+            WVPASS force-delete "$testfs_limited"/src-restore
+            WVPASS mkdir "$testfs_limited"/src-restore
+            WVPASS cd "$testfs_limited"/src-restore
+            WVFAIL bup meta --extract --file "$testfs"/src.meta
+            WVFAIL bup meta --extract --file "$testfs"/src.meta 2>&1 \
                 | WVPASS grep -e "^xattr\.set '" \
                 | WVPASS python -c \
                 'import sys; exit(not len(sys.stdin.readlines()) == 2)'
         ) || exit $?
 
         WVSTART 'meta - POSIX.1e ACLs (as root)'
-        WVPASS force-delete testfs/src
-        WVPASS mkdir testfs/src
-        WVPASS touch testfs/src/foo
-        WVPASS mkdir testfs/src/bar
-        WVPASS setfacl -m u:root:r testfs/src/foo
-        WVPASS setfacl -m u:root:r testfs/src/bar
-        (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
+        WVPASS force-delete "$testfs"/src
+        WVPASS mkdir "$testfs"/src
+        WVPASS touch "$testfs"/src/foo
+        WVPASS mkdir "$testfs"/src/bar
+        WVPASS setfacl -m u:root:r "$testfs"/src/foo
+        WVPASS setfacl -m u:root:r "$testfs"/src/bar
+        (WVPASS cd "$testfs"; WVPASS test-src-create-extract) || exit $?
 
         # Test restoration to a limited filesystem (vfat).
         (
-            WVPASS bup meta --create --recurse --file testfs/src.meta \
-                testfs/src
-            WVPASS force-delete testfs-limited/src-restore
-            WVPASS mkdir testfs-limited/src-restore
-            WVPASS cd testfs-limited/src-restore
-            WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
+            WVPASS bup meta --create --recurse --file "$testfs"/src.meta \
+                "$testfs"/src
+            WVPASS force-delete "$testfs_limited"/src-restore
+            WVPASS mkdir "$testfs_limited"/src-restore
+            WVPASS cd "$testfs_limited"/src-restore
+            WVFAIL bup meta --extract --file "$testfs"/src.meta 2>&1 \
                 | WVPASS grep -e '^POSIX1e ACL applyto:' \
                 | WVPASS python -c \
                 'import sys; exit(not len(sys.stdin.readlines()) == 2)'
         ) || exit $?
+
+        WVPASS umount "$testfs"
+        WVPASS umount "$testfs_limited"
+        WVPASS rm -r "$testfs" "$testfs_limited"
+
     ) || exit $?
 fi