"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/test_SupportedFileSystems.cc" between
gparted-1.2.0.tar.gz and gparted-1.3.0.tar.gz

About: GParted is a graphical partition editor for creating, reorganizing, and deleting disk partitions (using GNU libparted).

test_SupportedFileSystems.cc  (gparted-1.2.0):test_SupportedFileSystems.cc  (gparted-1.3.0)
skipping to change at line 219 skipping to change at line 219
} }
#define SKIP_IF_TEST_DISABLED_FOR_FS(fstype) \ #define SKIP_IF_TEST_DISABLED_FOR_FS(fstype) \
if (m_fstype == fstype) \ if (m_fstype == fstype) \
{ \ { \
std::cout << __FILE__ << ":" << __LINE__ << ": Skip test. " \ std::cout << __FILE__ << ":" << __LINE__ << ": Skip test. " \
<< "Test disabled for file system" << std::endl; \ << "Test disabled for file system" << std::endl; \
return; \ return; \
} }
// Temporarily workaround bugs in mkfs.reiser4 and debugfs.reiser4 which occasio
nally
// create and read a null UUID respectively.
#define IGNORE_REISER4_NULL_UUID() \
if (m_fstype == FS_REISER4 && m_partition.uuid.size() == 0) \
{ \
std::cout << __FILE__ << ":" << __LINE__ << ": Ignore test " \
<< "failure of a null UUID." << std::endl; \
m_partition.uuid = "XXXXXXXXX"; \
}
const Byte_Value IMAGESIZE_Default = 256*MEBIBYTE; const Byte_Value IMAGESIZE_Default = 256*MEBIBYTE;
const Byte_Value IMAGESIZE_Larger = 512*MEBIBYTE; const Byte_Value IMAGESIZE_Larger = 512*MEBIBYTE;
class SupportedFileSystemsTest : public ::testing::TestWithParam<FSType> class SupportedFileSystemsTest : public ::testing::TestWithParam<FSType>
{ {
protected: protected:
SupportedFileSystemsTest(); SupportedFileSystemsTest();
virtual void SetUp(); virtual void SetUp();
virtual void extra_setup(Byte_Value size = IMAGESIZE_Default); virtual void create_image_file(Byte_Value size = IMAGESIZE_Default);
virtual void TearDown(); virtual void TearDown();
public: public:
static void SetUpTestCase(); static void SetUpTestCase();
static void TearDownTestCase(); static void TearDownTestCase();
static std::vector<FSType> get_supported_fstypes(); static std::vector<FSType> get_supported_fstypes();
protected: protected:
static void setup_supported_filesystems(); static void setup_supported_filesystems();
skipping to change at line 280 skipping to change at line 290
void SupportedFileSystemsTest::SetUp() void SupportedFileSystemsTest::SetUp()
{ {
ASSERT_TRUE(s_supported_filesystems != NULL) << __func__ << "(): TEST_BUG : File system interfaces not loaded"; ASSERT_TRUE(s_supported_filesystems != NULL) << __func__ << "(): TEST_BUG : File system interfaces not loaded";
// Lookup file system interface object. // Lookup file system interface object.
m_fs_object = s_supported_filesystems->get_fs_object(m_fstype); m_fs_object = s_supported_filesystems->get_fs_object(m_fstype);
ASSERT_TRUE(m_fs_object != NULL) << __func__ << "(): TEST_BUG: Interface object not found for file system " ASSERT_TRUE(m_fs_object != NULL) << __func__ << "(): TEST_BUG: Interface object not found for file system "
<< test_fsname(m_fstype); << test_fsname(m_fstype);
} }
void SupportedFileSystemsTest::extra_setup(Byte_Value size) void SupportedFileSystemsTest::create_image_file(Byte_Value size)
{ {
// Create new image file to work with. // Create new image file to work with.
unlink(s_image_name); unlink(s_image_name);
int fd = open(s_image_name, O_WRONLY|O_CREAT|O_NONBLOCK, 0666); int fd = open(s_image_name, O_WRONLY|O_CREAT|O_NONBLOCK, 0666);
ASSERT_GE(fd, 0) << "Failed to create image file '" << s_image_name << "' . errno=" ASSERT_GE(fd, 0) << "Failed to create image file '" << s_image_name << "' . errno="
<< errno << "," << strerror(errno); << errno << "," << strerror(errno);
ASSERT_EQ(ftruncate(fd, (off_t)size), 0) << "Failed to set image file '" << s_image_name << "' to size " ASSERT_EQ(ftruncate(fd, (off_t)size), 0) << "Failed to set image file '" << s_image_name << "' to size "
<< size << ". errno=" << errno << "," << strerror(errno); << size << ". errno=" << errno << "," << strerror(errno);
close(fd); close(fd);
skipping to change at line 458 skipping to change at line 468
ASSERT_LE(new_size, m_partition.get_byte_length()) << __func__ << "(): TE ST_BUG: Cannot grow Partition object size"; ASSERT_LE(new_size, m_partition.get_byte_length()) << __func__ << "(): TE ST_BUG: Cannot grow Partition object size";
Sector new_sectors = (new_size + m_partition.sector_size - 1) / m_partiti on.sector_size; Sector new_sectors = (new_size + m_partition.sector_size - 1) / m_partiti on.sector_size;
m_partition.sector_end = new_sectors; m_partition.sector_end = new_sectors;
} }
TEST_P(SupportedFileSystemsTest, Create) TEST_P(SupportedFileSystemsTest, Create)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
extra_setup(); create_image_file();
// Call create, check for success and print operation details on failure. // Call create, check for success and print operation details on failure.
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
} }
TEST_P(SupportedFileSystemsTest, CreateAndReadUsage) TEST_P(SupportedFileSystemsTest, CreateAndReadUsage)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(read); 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_BTRFS);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
extra_setup(); create_image_file();
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
reload_partition(); reload_partition();
m_fs_object->set_used_sectors(m_partition); m_fs_object->set_used_sectors(m_partition);
// Test file system usage is reported correctly. // Test file system usage is reported correctly.
// Used is between 0 and length. // Used is between 0 and length.
EXPECT_LE(0, m_partition.get_sectors_used()); EXPECT_LE(0, m_partition.get_sectors_used());
EXPECT_LE(m_partition.get_sectors_used(), m_partition.get_sector_length() ); EXPECT_LE(m_partition.get_sectors_used(), m_partition.get_sector_length() );
// Unused is between 0 and length. // Unused is between 0 and length.
EXPECT_LE(0, m_partition.get_sectors_unused()); EXPECT_LE(0, m_partition.get_sectors_unused());
skipping to change at line 501 skipping to change at line 511
TEST_P(SupportedFileSystemsTest, CreateAndReadLabel) TEST_P(SupportedFileSystemsTest, CreateAndReadLabel)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(read_label); 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_BTRFS);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
const char* fs_label = "TEST_LABEL"; const char* fs_label = "TEST_LABEL";
extra_setup(); create_image_file();
m_partition.set_filesystem_label(fs_label); m_partition.set_filesystem_label(fs_label);
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
// Test reading the label is successful. // Test reading the label is successful.
reload_partition(); reload_partition();
m_fs_object->read_label(m_partition); m_fs_object->read_label(m_partition);
EXPECT_STREQ(fs_label, m_partition.get_filesystem_label().c_str()); EXPECT_STREQ(fs_label, m_partition.get_filesystem_label().c_str());
// Test messages from read operation are empty or print them. // Test messages from read operation are empty or print them.
EXPECT_TRUE(m_partition.get_messages().empty()) << m_partition; EXPECT_TRUE(m_partition.get_messages().empty()) << m_partition;
} }
TEST_P(SupportedFileSystemsTest, CreateAndReadUUID) TEST_P(SupportedFileSystemsTest, CreateAndReadUUID)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(read_uuid); 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_BTRFS);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
extra_setup(); create_image_file();
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
if (m_fstype == FS_JFS) if (m_fstype == FS_JFS)
{ {
// Write a new UUID to cause the jfs version to be updated from 1 to 2 so // 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 sys tem. // that jfs_tune can successfully report the UUID of the file sys tem.
SKIP_IF_FS_DOESNT_SUPPORT(write_uuid); SKIP_IF_FS_DOESNT_SUPPORT(write_uuid);
ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_deta il)) << m_operation_detail; ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_deta il)) << m_operation_detail;
} }
// Test reading the UUID is successful. // Test reading the UUID is successful.
reload_partition(); reload_partition();
m_fs_object->read_uuid(m_partition); m_fs_object->read_uuid(m_partition);
IGNORE_REISER4_NULL_UUID();
EXPECT_GE(m_partition.uuid.size(), 9U); EXPECT_GE(m_partition.uuid.size(), 9U);
// Test messages from read operation are empty or print them. // Test messages from read operation are empty or print them.
EXPECT_TRUE(m_partition.get_messages().empty()) << m_partition; EXPECT_TRUE(m_partition.get_messages().empty()) << m_partition;
} }
TEST_P(SupportedFileSystemsTest, CreateAndWriteLabel) TEST_P(SupportedFileSystemsTest, CreateAndWriteLabel)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(write_label); 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_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
extra_setup(); create_image_file();
m_partition.set_filesystem_label("FIRST"); m_partition.set_filesystem_label("FIRST");
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
// Test writing a label is successful. // Test writing a label is successful.
m_partition.set_filesystem_label("SECOND"); m_partition.set_filesystem_label("SECOND");
ASSERT_TRUE(m_fs_object->write_label(m_partition, m_operation_detail)) << m_operation_detail; ASSERT_TRUE(m_fs_object->write_label(m_partition, m_operation_detail)) << m_operation_detail;
} }
TEST_P(SupportedFileSystemsTest, CreateAndWriteUUID) TEST_P(SupportedFileSystemsTest, CreateAndWriteUUID)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(write_uuid); 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_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
extra_setup(); create_image_file();
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
// Test writing a new random UUID is successful. // Test writing a new random UUID is successful.
ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_detail)) << m_operation_detail; ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_detail)) << m_operation_detail;
} }
TEST_P(SupportedFileSystemsTest, CreateAndCheck) TEST_P(SupportedFileSystemsTest, CreateAndCheck)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(check); SKIP_IF_FS_DOESNT_SUPPORT(check);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
SKIP_IF_TEST_DISABLED_FOR_FS(FS_MINIX); // FIXME: Enable when util-linux >= 2.27 is available everywhere SKIP_IF_TEST_DISABLED_FOR_FS(FS_MINIX); // FIXME: Enable when util-linux >= 2.27 is available everywhere
extra_setup(); create_image_file();
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
// Test checking the file system is successful. // Test checking the file system is successful.
ASSERT_TRUE(m_fs_object->check_repair(m_partition, m_operation_detail)) < < m_operation_detail; ASSERT_TRUE(m_fs_object->check_repair(m_partition, m_operation_detail)) < < m_operation_detail;
} }
TEST_P(SupportedFileSystemsTest, CreateAndRemove) TEST_P(SupportedFileSystemsTest, CreateAndRemove)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(remove); SKIP_IF_FS_DOESNT_SUPPORT(remove);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
extra_setup(); create_image_file();
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
// Test removing the file system is successful. Note that most file syst ems don't // Test removing the file system is successful. Note that most file syst ems don't
// implement remove so will skip this test. // implement remove so will skip this test.
ASSERT_TRUE(m_fs_object->remove(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->remove(m_partition, m_operation_detail)) << m_op eration_detail;
} }
TEST_P(SupportedFileSystemsTest, CreateAndGrow) TEST_P(SupportedFileSystemsTest, CreateAndGrow)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(grow); SKIP_IF_FS_DOESNT_SUPPORT(grow);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_JFS); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_JFS);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_XFS); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_XFS);
extra_setup(IMAGESIZE_Default); create_image_file(IMAGESIZE_Default);
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
// Test growing the file system is successful. // Test growing the file system is successful.
resize_image(IMAGESIZE_Larger); resize_image(IMAGESIZE_Larger);
reload_partition(); reload_partition();
ASSERT_TRUE(m_fs_object->resize(m_partition, m_operation_detail, true)) < < m_operation_detail; ASSERT_TRUE(m_fs_object->resize(m_partition, m_operation_detail, true)) < < m_operation_detail;
} }
TEST_P(SupportedFileSystemsTest, CreateAndShrink) TEST_P(SupportedFileSystemsTest, CreateAndShrink)
{ {
SKIP_IF_FS_DOESNT_SUPPORT(create); SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(shrink); SKIP_IF_FS_DOESNT_SUPPORT(shrink);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS); 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_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2); SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
extra_setup(IMAGESIZE_Larger); create_image_file(IMAGESIZE_Larger);
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail; ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_op eration_detail;
// Test shrinking the file system is successful. // Test shrinking the file system is successful.
shrink_partition(IMAGESIZE_Default); shrink_partition(IMAGESIZE_Default);
ASSERT_TRUE(m_fs_object->resize(m_partition, m_operation_detail, false)) << m_operation_detail; ASSERT_TRUE(m_fs_object->resize(m_partition, m_operation_detail, false)) << m_operation_detail;
} }
// Instantiate the test case so every test is run for the specified file system types. // Instantiate the test case so every test is run for the specified file system types.
// Reference: // Reference:
// * Google Test, Advanced googletest Topics, How to Write Value-Parameterized Tests // * Google Test, Advanced googletest Topics, How to Write Value-Parameterized Tests
 End of changes. 14 change blocks. 
12 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)