[gparted] Create loop devices for NILFS2 read and write FS interface tests (!49)



commit 8d4f9eac99c06d84f1be74ccbf543ef2b1d2261c
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Oct 14 17:12:37 2019 +0100

    Create loop devices for NILFS2 read and write FS interface tests (!49)
    
    For NILFS2 the read and write tests which use nilfs-tune all fail using
    an image file, even when run as root, however the other tests succeed.
    Selected output from the test program:
    
        # ./test_SupportedFileSystems --gtest_filter='*/nilfs2' | fgrep ' ms'
        [       OK ] My/SupportedFileSystemsTest.Create/nilfs2 (22 ms)
        [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2, where GetParam() = 22 (31 ms)
        [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadLabel/nilfs2, where GetParam() = 22 (30 ms)
        [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUUID/nilfs2, where GetParam() = 22 (30 ms)
        [  FAILED  ] My/SupportedFileSystemsTest.CreateAndWriteLabel/nilfs2, where GetParam() = 22 (37 ms)
        [  FAILED  ] My/SupportedFileSystemsTest.CreateAndWriteUUID/nilfs2, where GetParam() = 22 (39 ms)
        [       OK ] My/SupportedFileSystemsTest.CreateAndCheck/nilfs2 (0 ms)
        [       OK ] My/SupportedFileSystemsTest.CreateAndRemove/nilfs2 (0 ms)
        [       OK ] My/SupportedFileSystemsTest.CreateAndGrow/nilfs2 (386 ms)
        [       OK ] My/SupportedFileSystemsTest.CreateAndShrink/nilfs2 (345 ms)
        [----------] 10 tests from My/SupportedFileSystemsTest (920 ms total)
        [==========] 10 tests from 1 test case ran. (920 ms total)
    
    nilfs-tune fails like this when given an image file:
        # truncate -s 256M test.img
        # mkfs.nilfs2 test.img
        mkfs.nilfs2 (nilfs-utils 2.2.7)
        Start writing file system initial data to the device
               Blocksize:4096  Device:test.img  Device Size:268435456
        File system initialization succeeded !!
        # nilfs-tune -l test.img
        nilfs-tune 2.2.7
        nilfs-tune: test.img: cannot open NILFS
        # echo $?
        1
    
    However using nilfs-tune via a loop device works:
        # losetup --show --find /dev/loop0
        /dev/loop0
        # nilfs-tune -l /dev/loop0
        nilfs-tune 2.2.7
        Filesystem volume name:   (none)
        Filesystem UUID:          fc49912c-4d39-4672-8610-1e1185d0db5f
        Filesystem magic number:  0x3434
        Filesystem revision #:    2.0
        Filesystem features:      (none)
        Filesystem state:         valid
        Filesystem OS type:       Linux
        Block size:               4096
    ...
    
    So nilfs-tune only works with block devices.  Fix by making these tests
    require a loop device and therefore make them root only.  Now these
    tests are skipped as non-root user and pass as root.
    
    Closes !49 - Add file system interface tests

 tests/test_SupportedFileSystems.cc | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/tests/test_SupportedFileSystems.cc b/tests/test_SupportedFileSystems.cc
index f8b9959b..1eb05815 100644
--- a/tests/test_SupportedFileSystems.cc
+++ b/tests/test_SupportedFileSystems.cc
@@ -488,6 +488,7 @@ TEST_P(SupportedFileSystemsTest, CreateAndReadUsage)
        SKIP_IF_FS_DOESNT_SUPPORT(read);
        SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
        SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
+       SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
 
        extra_setup();
        ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
@@ -517,6 +518,7 @@ TEST_P(SupportedFileSystemsTest, CreateAndReadLabel)
        SKIP_IF_FS_DOESNT_SUPPORT(read_label);
        SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
        SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
+       SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
 
        const char* fs_label = "TEST_LABEL";
        extra_setup();
@@ -539,6 +541,7 @@ TEST_P(SupportedFileSystemsTest, CreateAndReadUUID)
        SKIP_IF_FS_DOESNT_SUPPORT(read_uuid);
        SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
        SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
+       SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
 
        extra_setup();
        ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
@@ -558,6 +561,7 @@ TEST_P(SupportedFileSystemsTest, CreateAndWriteLabel)
        SKIP_IF_FS_DOESNT_SUPPORT(create);
        SKIP_IF_FS_DOESNT_SUPPORT(write_label);
        SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
+       SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
 
        extra_setup();
        m_partition.set_filesystem_label("FIRST");
@@ -574,6 +578,7 @@ TEST_P(SupportedFileSystemsTest, CreateAndWriteUUID)
        SKIP_IF_FS_DOESNT_SUPPORT(create);
        SKIP_IF_FS_DOESNT_SUPPORT(write_uuid);
        SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
+       SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
 
        extra_setup();
        ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]