Extend tests to all fully supported file systems (!49)

Extend testing to all fully supported file systems, those with an
implemented FileSystem derived class.

Note that in main() GParted threading needs to now be initialised before
InitGoogleTest() because it calls INSTANTIATE_TEST_CASE_P() which in
turn calls get_supported_fstypes() which eventually constructs all the
individual file system interface objects and discovers available
support, some of which use execute_command().  Example call chain:
    InitGoogleTest()
      INSTANTIATE_TEST_CASE_P()
        get_supported_fstypes()
          setup_supported_filesystems()
            {SupportedFileSystems}->find_supported_filesystems()
              {btrfs}->get_filesystem_support()
                Utils::execute_command()

In the CentOS 7 GitLab CI image the EPEL (Extra Packages for Enterprise
Linux) repository is added to provide f2fs-tools and ntfsprogs.

23 of 210 tests fail on CentOS 7 and 22 on Ubuntu 18.04 LTS.  The
following commits will resolve these test failures.

    $ ./test_SupportedFileSystems
    Running main() from test_SupportedFileSystems.cc
    [==========] Running 210 tests from 1 test case.
    [----------] Global test environment set-up.
    [----------] 210 tests from My/SupportedFileSystemsTest
...
    [----------] 210 tests from My/SupportedFileSystemsTest (11066 ms total)

    [----------] Global test environment tear-down
    [==========] 210 tests from 1 test case ran. (11067 ms total)
    [  PASSED  ] 187 tests.
    [  FAILED  ] 23 tests, listed below:
    [  FAILED  ] My/SupportedFileSystemsTest.Create/lvm2pv, where GetParam() = 20
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUsage/btrfs, where GetParam() = 7
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUsage/lvm2pv, where GetParam() = 20
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2, where GetParam() = 22
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadLabel/btrfs, where GetParam() = 7
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadLabel/nilfs2, where GetParam() = 22
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUUID/btrfs, where GetParam() = 7
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUUID/fat16, where GetParam() = 13
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUUID/fat32, where GetParam() = 14
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUUID/jfs, where GetParam() = 17
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUUID/nilfs2, where GetParam() = 22
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndWriteLabel/nilfs2, where GetParam() = 22
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndWriteUUID/nilfs2, where GetParam() = 22
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndCheck/lvm2pv, where GetParam() = 20
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndCheck/minix, where GetParam() = 21
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndRemove/lvm2pv, where GetParam() = 20
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndGrow/btrfs, where GetParam() = 7
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndGrow/lvm2pv, where GetParam() = 20
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndGrow/xfs, where GetParam() = 27
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndShrink/btrfs, where GetParam() = 7
    [  FAILED  ] My/SupportedFileSystemsTest.CreateAndShrink/lvm2pv, where GetParam() = 20

    23 FAILED TESTS

Closes !49 - Add file system interface tests
This commit is contained in:
Mike Fleetwood 2019-08-05 16:13:04 +01:00 committed by Curtis Gedak
parent 7b92e9343b
commit 8f4edb0693
2 changed files with 62 additions and 11 deletions

View File

@ -11,7 +11,12 @@ stages:
gcc-c++ libuuid-devel parted-devel gtkmm30-devel make
polkit file
# Extra packages only needed during the test stage.
- yum install -y e2fsprogs util-linux xorg-x11-server-Xvfb
# Install EPEL repo first for f2fs-tools and ntfsprogs.
- yum install -y epel-release
- yum install -y btrfs-progs e2fsprogs f2fs-tools dosfstools mtools
hfsplus-tools util-linux cryptsetup device-mapper lvm2
ntfsprogs udftools xfsprogs xfsdump
xorg-x11-server-Xvfb
- cat /etc/os-release
.ubuntu_image_template: &ubuntu_image_definition
@ -23,7 +28,10 @@ stages:
uuid-dev libparted-dev libgtkmm-3.0-dev make
policykit-1
# Extra packages only needed during the test stage.
- apt-get install -y e2fsprogs util-linux xvfb
- apt-get install -y btrfs-progs e2fsprogs f2fs-tools dosfstools mtools
hfsutils hfsprogs jfsutils util-linux cryptsetup-bin
dmsetup lvm2 nilfs-tools ntfs-3g reiser4progs
reiserfsprogs udftools xfsprogs xfsdump xvfb
- cat /etc/os-release
.build_stage_template: &build_stage_definition

View File

@ -174,7 +174,9 @@ const std::string test_fsname(FSType fstype)
{
switch (fstype)
{
case FS_HFSPLUS: return "hfsplus";
case FS_LINUX_SWAP: return "linuxswap";
case FS_LVM2_PV: return "lvm2pv";
default: break;
}
return std::string(Utils::get_filesystem_string(fstype));
@ -221,7 +223,12 @@ public:
static void SetUpTestCase();
static void TearDownTestCase();
static std::vector<FSType> get_supported_fstypes();
protected:
static void setup_supported_filesystems();
static void teardown_supported_filesystems();
virtual void reload_partition();
virtual void resize_image(Byte_Value new_size);
virtual void shrink_partition(Byte_Value size);
@ -284,16 +291,48 @@ void SupportedFileSystemsTest::TearDown()
// Common test case initialisation creating the supported file system interface object.
void SupportedFileSystemsTest::SetUpTestCase()
{
s_supported_filesystems = new SupportedFileSystems();
// Discover available file systems support capabilities, base on available file
// system specific tools.
s_supported_filesystems->find_supported_filesystems();
setup_supported_filesystems();
}
// Common test case teardown destroying the supported file systems interface object.
void SupportedFileSystemsTest::TearDownTestCase()
{
teardown_supported_filesystems();
}
std::vector<FSType> SupportedFileSystemsTest::get_supported_fstypes()
{
setup_supported_filesystems();
std::vector<FSType> v;
const std::vector<FS>& fss = s_supported_filesystems->get_all_fs_support();
for (unsigned int i = 0; i < fss.size(); i++)
{
if (s_supported_filesystems->supported_filesystem(fss[i].filesystem))
v.push_back(fss[i].filesystem);
}
return v;
}
// Create the supported file system interface object.
void SupportedFileSystemsTest::setup_supported_filesystems()
{
if (s_supported_filesystems == NULL)
{
s_supported_filesystems = new SupportedFileSystems();
// Discover available file systems support capabilities, base on available
// file system specific tools.
s_supported_filesystems->find_supported_filesystems();
}
}
// Destroy the supported file systems interface object.
void SupportedFileSystemsTest::teardown_supported_filesystems()
{
delete s_supported_filesystems;
s_supported_filesystems = NULL;
@ -504,7 +543,10 @@ TEST_P(SupportedFileSystemsTest, CreateAndShrink)
// Reference:
// * Google Test, Advanced googletest Topics, How to Write Value-Parameterized Tests
// https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#how-to-write-value-parameterized-tests
INSTANTIATE_TEST_CASE_P(My, SupportedFileSystemsTest, ::testing::Values(FS_EXT2, FS_LINUX_SWAP), param_fsname);
INSTANTIATE_TEST_CASE_P(My,
SupportedFileSystemsTest,
::testing::ValuesIn(SupportedFileSystemsTest::get_supported_fstypes()),
param_fsname);
} // namespace GParted
@ -558,12 +600,13 @@ int main(int argc, char** argv)
}
printf("DISPLAY=\"%s\"\n", display);
testing::InitGoogleTest(&argc, argv);
// Initialise threading in GParted to allow FileSystem interface classes to
// successfully use Utils:: and Filesystem::execute_command().
// successfully use Utils:: and Filesystem::execute_command(). Must be before
// InitGoogleTest().
GParted::GParted_Core::mainthread = Glib::Thread::self();
Gtk::Main gtk_main = Gtk::Main();
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}