[gparted] Write new UUID to JFS before testing reading UUID (!49)



commit 19ed25d774b4baa21417973029ef782c771bb736
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Sep 3 07:37:52 2019 +0100

    Write new UUID to JFS before testing reading UUID (!49)
    
    Testing reading the UUID from a newly created JFS was failing like this:
    
        $ ./test_SupportedFileSystems --gtest_filter='*ReadUUID/jfs'
    ...
        [ RUN      ] My/SupportedFileSystemsTest.CreateAndReadUUID/jfs
        test_SupportedFileSystems.cc:552: Failure
        Expected: (m_partition.uuid.size()) >= (9U), actual: 0 vs 9
        [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUUID/jfs, where GetParam() = 17 (57 ms)
    
    Mkfs.jfs creates a file system as version 1.  It does have a UUID and
    blkid can report it, but jfs_tune doesn't report it.
    
        $ touch -s 256M test_jfs.img
        $ mkfs.jfs -q test_jfs.img
        mkfs.jfs version 1.1.15, 04-Mar-2011
    
        Format completed successfully.
    
        262144 kilobytes total disk space.
        $ blkid test_jfs.img
        test_jfs.img: UUID="6b0bb46a-a240-47b4-89ab-1fe759aa572d" TYPE="jfs"
    
        $ jfs_tune -l test_jfs.img | egrep 'version|UUID'
        jfs_tune version 1.1.15, 04-Mar-2011
        JFS version:                1
    
        $ hexdump -C test_jfs.img
        00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
        *
        00008000  4a 46 53 31 01 00 00 00  58 f6 07 00 00 00 00 00  |JFS1....X.......|
    Version >---------------- ^^ ^^ ^^ ^^
    ...
        00008080  00 00 00 00 00 00 00 00  6b 0b b4 6a a2 40 47 b4  |........k..j.@G.|
        00008090  89 ab 1f e7 59 aa 57 2d  00 00 00 00 00 00 00 00  |....Y.W-........|
    UUID >-------------------------------- ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^
                  ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^
    
    However writing a new UUID to the JFS also updates the version to 2 and
    allows jfs_tune to report the UUID.
    
        $ jfs_tune -U random test_jfs.img
        jfs_tune version 1.1.15, 04-Mar-2011
        UUID updated successfully.
    
        $ blkid test_jfs.img
        test_jfs.img: UUID="6374ec58-3568-4ffb-bea9-ff76bf5c192f" TYPE="jfs"
    
        $ jfs_tune -l test_jfs.img | egrep 'version|UUID'
        jfs_tune version 1.1.15, 04-Mar-2011
        JFS version:            2
        File system UUID:       6374ec58-3568-4ffb-bea9-ff76bf5c192f
        External log UUID:      00000000-0000-0000-0000-000000000000
    
        $ hexdump -C test_jfs.img
        00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
        *
        00008000  4a 46 53 31 02 00 00 00  58 f6 07 00 00 00 00 00  |JFS1....X.......|
    Version >---------------- ^^ ^^ ^^ ^^
    ...
        00008080  00 00 00 00 00 00 00 00  63 74 ec 58 35 68 4f fb  |........ct.X5hO.|
        00008090  be a9 ff 76 bf 5c 19 2f  00 00 00 00 00 00 00 00  |...v.\./........|
    New UUID >---------------------------- ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^
                  ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^
    
    Therefore change the CreateAndReadUUID test for JFS to also write a new
    UUID so that it also updates the version to 2, thus allowing jfs_tune to
    report the UUID and the test pass.
    
    Note that GParted doesn't encounter this problem because it used blkid
    by default to report the UUID and only falls back to using the file
    system interface method which calls jfs_tune when blkid is not
    available.
    
    Closes !49 - Add file system interface tests

 tests/test_SupportedFileSystems.cc | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/tests/test_SupportedFileSystems.cc b/tests/test_SupportedFileSystems.cc
index 99c59fad..1f218aee 100644
--- a/tests/test_SupportedFileSystems.cc
+++ b/tests/test_SupportedFileSystems.cc
@@ -546,6 +546,14 @@ TEST_P(SupportedFileSystemsTest, CreateAndReadUUID)
        extra_setup();
        ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
 
+       if (m_fstype == FS_JFS)
+       {
+               // Write a new UUID to cause the jfs version to be updated from 1 to 2 so
+               // that jfs_tune can successfully report the UUID of the file system.
+               SKIP_IF_FS_DOESNT_SUPPORT(write_uuid);
+               ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_detail)) << m_operation_detail;
+       }
+
        // Test reading the UUID is successful.
        reload_partition();
        m_fs_object->read_uuid(m_partition);


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