From 58bd58870ff64075891321b378f1198da28cae85 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 26 Oct 2013 15:03:12 -0500 Subject: [PATCH] Fix the "set -e" problem in the test-meta.sh chattr tests. Start fixing the "set -e" problem, beginning with the test-meta.sh chattr tests, and add support to the test filesystem for options needed by the chattr calls. To allow us to produce a more digestable sequence of patches for the broader "set -e" problem, temporarily establish BUP_SKIP_BROKEN_TESTS which will do what it says when set, and until we finish repairing everything, it must be set during any testing: BUP_SKIP_BROKEN_TESTS=1 make check The fundamental issue with "set -e" is that it has some unexpected (but documented) semantics. For example: set -e foo() { false; rm -rf /; } # Effectively harmless foo # Erase the filesystem foo || true If nothing else, this behavior appears to have been masking test failures. Better to just avoid "set -e" altogether. Signed-off-by: Rob Browning --- t/test-meta.sh | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/t/test-meta.sh b/t/test-meta.sh index 28b5cfc..384e8c3 100755 --- a/t/test-meta.sh +++ b/t/test-meta.sh @@ -608,7 +608,12 @@ if [ $(t/root-status) == root ]; then umount testfs || true dd if=/dev/zero of=testfs.img bs=1M count=32 - mke2fs -F -j -m 0 testfs.img + # Make sure we have all the options the chattr test needs + # (i.e. create a "normal" ext4 filesystem). + WVPASS mke2fs -F -m 0 \ + -I 256 \ + -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize \ + testfs.img mkdir testfs mount -o loop,acl,user_xattr testfs.img testfs # Hide, so that tests can't create risks. @@ -656,29 +661,34 @@ if [ $(t/root-status) == root ]; then WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42" ) + set +e WVSTART 'meta - Linux attr (as root)' - force-delete testfs/src - mkdir testfs/src + WVPASS force-delete testfs/src + WVPASS mkdir testfs/src ( - touch testfs/src/foo - mkdir testfs/src/bar - chattr +acdeijstuADST testfs/src/foo - chattr +acdeijstuADST testfs/src/bar - (cd testfs && test-src-create-extract) + 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 - force-delete testfs-limited/src-restore - mkdir testfs-limited/src-restore - cd testfs-limited/src-restore + 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()) == 2)' - ) - ) + 'import sys; exit(not len(sys.stdin.readlines()) == 3)' + ) || exit $? + ) || exit $? + # FIXME: skip remaining tests until we fix them. + test "$BUP_SKIP_BROKEN_TESTS" && exit 0 + + set -e WVSTART 'meta - Linux xattr (as root)' force-delete testfs/src mkdir testfs/src @@ -728,5 +738,3 @@ if [ $(t/root-status) == root ]; then ) ) fi - -exit 0 -- 2.39.2