2019-07-17 06:08:08 -06:00
|
|
|
/* Copyright (C) 2019 Mike Fleetwood
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
/* Test SupportedFileSystems
|
2019-07-17 06:08:08 -06:00
|
|
|
*
|
|
|
|
* Test the derived FileSystem interface classes which call the file system specific
|
2019-09-18 02:22:32 -06:00
|
|
|
* executables via the SupportedFileSystems class. Rather than mocking command execution
|
|
|
|
* and returned output just run real commands, effectively making this integration testing.
|
2019-07-17 06:08:08 -06:00
|
|
|
*
|
|
|
|
* Test case setup determines the file system supported actions using
|
|
|
|
* get_filesystem_support() and individual tests are skipped if a feature is not
|
|
|
|
* supported, just as GParted does for it's actions.
|
|
|
|
*
|
|
|
|
* Each test creates it's own sparse image file and a fresh file system, performs a test
|
|
|
|
* on one FileSystem interface call and deletes the image file. This makes each test
|
|
|
|
* independent and allows them to run as a non-root user, provided the file system command
|
|
|
|
* itself doesn't require root. Errors reported for a failed interface call will include
|
|
|
|
* the GParted OperationDetails, which in turn includes the file system specific command
|
|
|
|
* used and stdout and stderr from it's execution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "GParted_Core.h"
|
|
|
|
#include "FileSystem.h"
|
|
|
|
#include "OperationDetail.h"
|
|
|
|
#include "Partition.h"
|
|
|
|
#include "Utils.h"
|
2019-09-18 02:22:32 -06:00
|
|
|
#include "SupportedFileSystems.h"
|
2019-07-17 06:08:08 -06:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
2019-07-26 09:18:58 -06:00
|
|
|
#include <vector>
|
2019-09-24 02:17:30 -06:00
|
|
|
#include <stdlib.h>
|
2019-07-17 06:08:08 -06:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <gtkmm.h>
|
|
|
|
#include <glibmm/thread.h>
|
|
|
|
#include <glibmm/ustring.h>
|
|
|
|
#include <parted/parted.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2019-10-25 06:07:36 -06:00
|
|
|
// Hacky XML parser which strips italic and bold markup added in
|
|
|
|
// OperationDetail::set_description() and reverts just these 5 characters &<>'" encoded by
|
|
|
|
// Glib::Markup::escape_text() -> g_markup_escape_text() -> append_escaped_text().
|
|
|
|
Glib::ustring strip_markup(const Glib::ustring& str)
|
|
|
|
{
|
|
|
|
size_t len = str.length();
|
|
|
|
size_t i = 0;
|
|
|
|
Glib::ustring ret;
|
|
|
|
ret.reserve(len);
|
|
|
|
while (i < len)
|
|
|
|
{
|
|
|
|
if (str.compare(i, 3, "<i>") == 0)
|
|
|
|
i += 3;
|
|
|
|
else if (str.compare(i, 4, "</i>") == 0)
|
|
|
|
i += 4;
|
|
|
|
else if (str.compare(i, 3, "<b>") == 0)
|
|
|
|
i += 3;
|
|
|
|
else if (str.compare(i, 4, "</b>") == 0)
|
|
|
|
i += 4;
|
|
|
|
else if (str.compare(i, 5, "&") == 0)
|
|
|
|
{
|
|
|
|
ret.push_back('&');
|
|
|
|
i += 5;
|
|
|
|
}
|
|
|
|
else if (str.compare(i, 4, "<") == 0)
|
|
|
|
{
|
|
|
|
ret.push_back('<');
|
|
|
|
i += 4;
|
|
|
|
}
|
|
|
|
else if (str.compare(i, 4, ">") == 0)
|
|
|
|
{
|
|
|
|
ret.push_back('>');
|
|
|
|
i += 4;
|
|
|
|
}
|
|
|
|
else if (str.compare(i, 6, "'") == 0)
|
|
|
|
{
|
|
|
|
ret.push_back('\'');
|
|
|
|
i += 6;
|
|
|
|
}
|
|
|
|
else if (str.compare(i, 6, """) == 0)
|
|
|
|
{
|
|
|
|
ret.push_back('"');
|
|
|
|
i += 6;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret.push_back(str[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-26 09:18:58 -06:00
|
|
|
// Print method for the messages in a Partition object.
|
|
|
|
std::ostream& operator<<(std::ostream& out, const Partition& partition)
|
|
|
|
{
|
|
|
|
const std::vector<Glib::ustring> messages = partition.get_messages();
|
|
|
|
out << "Partition messages:\n";
|
|
|
|
for (unsigned int i = 0; i < messages.size(); i++)
|
|
|
|
out << messages[i];
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-17 06:08:08 -06:00
|
|
|
// Print method for OperationDetailStatus.
|
|
|
|
std::ostream& operator<<(std::ostream& out, const OperationDetailStatus od_status)
|
|
|
|
{
|
|
|
|
switch (od_status)
|
|
|
|
{
|
|
|
|
case STATUS_NONE: out << "NONE"; break;
|
|
|
|
case STATUS_EXECUTE: out << "EXECUTE"; break;
|
|
|
|
case STATUS_SUCCESS: out << "SUCCESS"; break;
|
|
|
|
case STATUS_ERROR: out << "ERROR"; break;
|
|
|
|
case STATUS_INFO: out << "INFO"; break;
|
|
|
|
case STATUS_WARNING: out << "WARNING"; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Print method for an OperationDetail object.
|
|
|
|
std::ostream& operator<<(std::ostream& out, const OperationDetail& od)
|
|
|
|
{
|
2019-10-25 06:07:36 -06:00
|
|
|
out << strip_markup(od.get_description());
|
2019-07-17 06:08:08 -06:00
|
|
|
Glib::ustring elapsed = od.get_elapsed_time();
|
|
|
|
if (! elapsed.empty())
|
|
|
|
out << " " << elapsed;
|
|
|
|
if (od.get_status() != STATUS_NONE)
|
|
|
|
out << " (" << od.get_status() << ")";
|
|
|
|
out << "\n";
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < od.get_childs().size(); i++)
|
|
|
|
{
|
|
|
|
out << *od.get_childs()[i];
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-04 04:31:57 -06:00
|
|
|
// Printable file system type which meets the requirements for a Google Test name.
|
|
|
|
// Use GParted's file system names except when they contains any non-alphabetic chars.
|
|
|
|
// Reference:
|
|
|
|
// * Specifying Names for Value-Parameterized Test Parameters
|
|
|
|
// https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#specifying-names-for-value-parameterized-test-parameters
|
|
|
|
// "NOTE: test names must be non-empty, unique, and may only contain ASCII
|
|
|
|
// alphanumeric characters. In particular, they should not contain underscores."
|
|
|
|
const std::string test_fsname(FSType fstype)
|
|
|
|
{
|
|
|
|
switch (fstype)
|
|
|
|
{
|
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
2019-08-05 09:13:04 -06:00
|
|
|
case FS_HFSPLUS: return "hfsplus";
|
2019-08-04 04:31:57 -06:00
|
|
|
case FS_LINUX_SWAP: return "linuxswap";
|
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
2019-08-05 09:13:04 -06:00
|
|
|
case FS_LVM2_PV: return "lvm2pv";
|
2019-08-04 04:31:57 -06:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return std::string(Utils::get_filesystem_string(fstype));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Function callable by INSTANTIATE_TEST_CASE_P() to get the file system type for printing
|
|
|
|
// as part of the test name.
|
|
|
|
const std::string param_fsname(const ::testing::TestParamInfo<FSType>& info)
|
|
|
|
{
|
|
|
|
return test_fsname(info.param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-17 06:08:08 -06:00
|
|
|
// Google Test 1.8.1 (and earlier) doesn't implement run-time test skipping so implement
|
|
|
|
// our own for GParted run-time detected of unsupported file system features.
|
|
|
|
// Ref:
|
|
|
|
// Skipping tests at runtime with GTEST_SKIP() #1544
|
|
|
|
// https://github.com/google/googletest/pull/1544
|
|
|
|
// (Merged after Google Test 1.8.1)
|
2019-07-26 09:18:58 -06:00
|
|
|
#define SKIP_IF_FS_DOESNT_SUPPORT(opt) \
|
2019-08-02 04:15:48 -06:00
|
|
|
if (s_supported_filesystems->get_fs_support(m_fstype).opt != FS::EXTERNAL) \
|
2019-07-26 09:18:58 -06:00
|
|
|
{ \
|
|
|
|
std::cout << __FILE__ << ":" << __LINE__ << ": Skip test. " \
|
|
|
|
<< #opt << " not supported or support not found" << std::endl; \
|
|
|
|
return; \
|
2019-07-17 06:08:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-30 10:25:40 -06:00
|
|
|
#define SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(fstype) \
|
|
|
|
if (m_fstype == fstype) \
|
|
|
|
{ \
|
|
|
|
if (getuid() != 0) \
|
|
|
|
{ \
|
|
|
|
std::cout << __FILE__ << ":" << __LINE__ << ": Skip test. Not root " \
|
|
|
|
<< "to be able to create required loop device" << std::endl; \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
m_require_loopdev = true; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-27 02:59:22 -06:00
|
|
|
const Byte_Value IMAGESIZE_Default = 256*MEBIBYTE;
|
|
|
|
const Byte_Value IMAGESIZE_Larger = 512*MEBIBYTE;
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
class SupportedFileSystemsTest : public ::testing::TestWithParam<FSType>
|
2019-07-17 06:08:08 -06:00
|
|
|
{
|
|
|
|
protected:
|
2019-08-02 04:15:48 -06:00
|
|
|
SupportedFileSystemsTest();
|
2019-07-17 06:08:08 -06:00
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
virtual void SetUp();
|
2019-07-27 02:59:22 -06:00
|
|
|
virtual void extra_setup(Byte_Value size = IMAGESIZE_Default);
|
2019-07-17 06:08:08 -06:00
|
|
|
virtual void TearDown();
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
public:
|
2019-07-17 06:08:08 -06:00
|
|
|
static void SetUpTestCase();
|
|
|
|
static void TearDownTestCase();
|
|
|
|
|
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
2019-08-05 09:13:04 -06:00
|
|
|
static std::vector<FSType> get_supported_fstypes();
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
protected:
|
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
2019-08-05 09:13:04 -06:00
|
|
|
static void setup_supported_filesystems();
|
|
|
|
static void teardown_supported_filesystems();
|
|
|
|
|
2019-08-30 10:25:40 -06:00
|
|
|
virtual const std::string create_loopdev(const std::string& image_name) const;
|
|
|
|
virtual void detach_loopdev(const std::string& loopdev_name) const;
|
|
|
|
virtual void reload_loopdev_size(const std::string& loopdev_name) const;
|
|
|
|
|
2019-08-27 09:49:02 -06:00
|
|
|
virtual void reload_partition();
|
2019-07-27 02:59:22 -06:00
|
|
|
virtual void resize_image(Byte_Value new_size);
|
|
|
|
virtual void shrink_partition(Byte_Value size);
|
2019-08-27 09:49:02 -06:00
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
static SupportedFileSystems* s_supported_filesystems; // Owning pointer
|
|
|
|
static const char* s_image_name;
|
2019-07-17 06:08:08 -06:00
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
FSType m_fstype;
|
|
|
|
FileSystem* m_fs_object; // Alias pointer
|
2019-08-30 10:25:40 -06:00
|
|
|
bool m_require_loopdev;
|
|
|
|
std::string m_dev_name;
|
2019-07-17 06:08:08 -06:00
|
|
|
Partition m_partition;
|
|
|
|
OperationDetail m_operation_detail;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
SupportedFileSystems* SupportedFileSystemsTest::s_supported_filesystems = NULL;
|
|
|
|
const char* SupportedFileSystemsTest::s_image_name = "test_SupportedFileSystems.img";
|
2019-07-17 06:08:08 -06:00
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
SupportedFileSystemsTest::SupportedFileSystemsTest()
|
2019-08-30 10:25:40 -06:00
|
|
|
: m_fstype(GetParam()), m_fs_object(NULL), m_require_loopdev(false),
|
|
|
|
// Initialise top-level operation detail object with description ...
|
|
|
|
m_operation_detail("Operation details:", STATUS_NONE)
|
2019-08-02 04:15:48 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SupportedFileSystemsTest::SetUp()
|
|
|
|
{
|
|
|
|
ASSERT_TRUE(s_supported_filesystems != NULL) << __func__ << "(): TEST_BUG: File system interfaces not loaded";
|
|
|
|
|
|
|
|
// Lookup file system interface object.
|
|
|
|
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 "
|
2019-08-04 04:31:57 -06:00
|
|
|
<< test_fsname(m_fstype);
|
2019-08-02 04:15:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
void SupportedFileSystemsTest::extra_setup(Byte_Value size)
|
2019-07-17 06:08:08 -06:00
|
|
|
{
|
2019-07-27 02:59:22 -06:00
|
|
|
// Create new image file to work with.
|
2019-07-17 06:08:08 -06:00
|
|
|
unlink(s_image_name);
|
|
|
|
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="
|
|
|
|
<< errno << "," << strerror(errno);
|
2019-07-27 02:59:22 -06:00
|
|
|
ASSERT_EQ(ftruncate(fd, (off_t)size), 0) << "Failed to set image file '" << s_image_name << "' to size "
|
|
|
|
<< size << ". errno=" << errno << "," << strerror(errno);
|
2019-07-17 06:08:08 -06:00
|
|
|
close(fd);
|
|
|
|
|
2019-08-30 10:25:40 -06:00
|
|
|
m_dev_name = s_image_name;
|
|
|
|
if (m_require_loopdev)
|
|
|
|
m_dev_name = create_loopdev(s_image_name);
|
|
|
|
|
2019-08-27 09:49:02 -06:00
|
|
|
reload_partition();
|
2019-07-17 06:08:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
void SupportedFileSystemsTest::TearDown()
|
2019-07-17 06:08:08 -06:00
|
|
|
{
|
2019-08-30 10:25:40 -06:00
|
|
|
if (m_require_loopdev)
|
|
|
|
detach_loopdev(m_dev_name);
|
|
|
|
|
2019-07-17 06:08:08 -06:00
|
|
|
unlink(s_image_name);
|
2019-08-02 04:15:48 -06:00
|
|
|
|
|
|
|
m_fs_object = NULL;
|
2019-07-17 06:08:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
// Common test case initialisation creating the supported file system interface object.
|
|
|
|
void SupportedFileSystemsTest::SetUpTestCase()
|
2019-07-17 06:08:08 -06:00
|
|
|
{
|
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
2019-08-05 09:13:04 -06:00
|
|
|
setup_supported_filesystems();
|
2019-07-17 06:08:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
// Common test case teardown destroying the supported file systems interface object.
|
|
|
|
void SupportedFileSystemsTest::TearDownTestCase()
|
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
2019-08-05 09:13:04 -06:00
|
|
|
{
|
|
|
|
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()
|
2019-07-17 06:08:08 -06:00
|
|
|
{
|
2019-09-18 02:22:32 -06:00
|
|
|
delete s_supported_filesystems;
|
|
|
|
s_supported_filesystems = NULL;
|
2019-07-17 06:08:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-30 10:25:40 -06:00
|
|
|
// Create loop device over named image file and return the device name.
|
|
|
|
const std::string SupportedFileSystemsTest::create_loopdev(const std::string& image_name) const
|
|
|
|
{
|
|
|
|
Glib::ustring output;
|
|
|
|
Glib::ustring error;
|
|
|
|
Glib::ustring cmd = "losetup --find --show " + Glib::shell_quote(image_name);
|
|
|
|
int exit_status = Utils::execute_command(cmd, output, error, true);
|
|
|
|
if (exit_status != 0)
|
|
|
|
{
|
|
|
|
ADD_FAILURE() << __func__ << "(): Execute: " << cmd << "\n"
|
|
|
|
<< error
|
|
|
|
<< __func__ << "(): Losetup failed with exit status " << exit_status << "\n"
|
|
|
|
<< __func__ << "(): Failed to create required loop device";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Strip trailing New Line.
|
|
|
|
size_t len = output.length();
|
|
|
|
if (len > 0 && output[len-1] == '\n')
|
|
|
|
output.resize(len-1);
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Detach named loop device.
|
|
|
|
void SupportedFileSystemsTest::detach_loopdev(const std::string& loopdev_name) const
|
|
|
|
{
|
|
|
|
Glib::ustring output;
|
|
|
|
Glib::ustring error;
|
|
|
|
Glib::ustring cmd = "losetup --detach " + Glib::shell_quote(loopdev_name);
|
|
|
|
int exit_status = Utils::execute_command(cmd, output, error, true);
|
|
|
|
if (exit_status != 0)
|
|
|
|
{
|
|
|
|
// Report losetup detach error but don't fail the test because of it.
|
|
|
|
std::cout << __func__ << "(): Execute: " << cmd << "\n"
|
|
|
|
<< error
|
|
|
|
<< __func__ << "(): Losetup failed with exit status " << exit_status << "\n"
|
|
|
|
<< __func__ << "(): Failed to detach loop device. Test NOT affected" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Instruct loop device to reload the size of the underlying image file.
|
|
|
|
void SupportedFileSystemsTest::reload_loopdev_size(const std::string& loopdev_name) const
|
|
|
|
{
|
|
|
|
Glib::ustring output;
|
|
|
|
Glib::ustring error;
|
|
|
|
Glib::ustring cmd = "losetup --set-capacity " + Glib::shell_quote(loopdev_name);
|
|
|
|
int exit_status = Utils::execute_command(cmd, output, error, true);
|
|
|
|
if (exit_status != 0)
|
|
|
|
{
|
|
|
|
ADD_FAILURE() << __func__ << "(): Execute: " << cmd << "\n"
|
|
|
|
<< error
|
|
|
|
<< __func__ << "(): Losetup failed with exit status " << exit_status << "\n"
|
|
|
|
<< __func__ << "(): Failed to reload loop device size";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-27 09:49:02 -06:00
|
|
|
// (Re)initialise m_partition as a Partition object spanning the whole of the image file
|
|
|
|
// with file system type only. No file system usage, label or UUID.
|
2019-09-18 02:22:32 -06:00
|
|
|
void SupportedFileSystemsTest::reload_partition()
|
2019-08-27 09:49:02 -06:00
|
|
|
{
|
|
|
|
m_partition.Reset();
|
|
|
|
|
|
|
|
// Use libparted to get the sector size etc. of the image file.
|
2019-08-30 10:25:40 -06:00
|
|
|
PedDevice* lp_device = ped_device_get(m_dev_name.c_str());
|
2019-08-27 09:49:02 -06:00
|
|
|
ASSERT_TRUE(lp_device != NULL);
|
|
|
|
|
|
|
|
// Prepare partition object spanning whole of the image file.
|
2019-08-30 10:25:40 -06:00
|
|
|
m_partition.set_unpartitioned(m_dev_name,
|
2019-08-27 09:49:02 -06:00
|
|
|
lp_device->path,
|
2019-08-02 04:15:48 -06:00
|
|
|
m_fstype,
|
2019-08-27 09:49:02 -06:00
|
|
|
lp_device->length,
|
|
|
|
lp_device->sector_size,
|
|
|
|
false);
|
|
|
|
|
|
|
|
ped_device_destroy(lp_device);
|
|
|
|
lp_device = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
void SupportedFileSystemsTest::resize_image(Byte_Value new_size)
|
2019-07-27 02:59:22 -06:00
|
|
|
{
|
|
|
|
int fd = open(s_image_name, O_WRONLY|O_NONBLOCK);
|
|
|
|
ASSERT_GE(fd, 0) << "Failed to open image file '" << s_image_name << "'. errno="
|
|
|
|
<< errno << "," << strerror(errno);
|
|
|
|
ASSERT_EQ(ftruncate(fd, (off_t)new_size), 0) << "Failed to resize image file '" << s_image_name << "' to size "
|
|
|
|
<< new_size << ". errno=" << errno << "," << strerror(errno);
|
|
|
|
close(fd);
|
2019-08-30 10:25:40 -06:00
|
|
|
|
|
|
|
if (m_require_loopdev)
|
|
|
|
reload_loopdev_size(m_dev_name);
|
2019-07-27 02:59:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-18 02:22:32 -06:00
|
|
|
void SupportedFileSystemsTest::shrink_partition(Byte_Value new_size)
|
2019-07-27 02:59:22 -06:00
|
|
|
{
|
|
|
|
ASSERT_LE(new_size, m_partition.get_byte_length()) << __func__ << "(): TEST_BUG: Cannot grow Partition object size";
|
|
|
|
Sector new_sectors = (new_size + m_partition.sector_size - 1) / m_partition.sector_size;
|
|
|
|
m_partition.sector_end = new_sectors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, Create)
|
2019-07-17 06:08:08 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
|
|
|
|
2019-07-17 06:08:08 -06:00
|
|
|
extra_setup();
|
|
|
|
// Call create, check for success and print operation details on failure.
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-17 06:08:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndReadUsage)
|
2019-07-26 09:18:58 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(read);
|
2019-10-09 06:35:17 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
2019-10-14 10:12:37 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
|
2019-07-26 09:18:58 -06:00
|
|
|
|
|
|
|
extra_setup();
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 09:18:58 -06:00
|
|
|
|
2019-08-27 09:49:02 -06:00
|
|
|
reload_partition();
|
2019-08-02 04:15:48 -06:00
|
|
|
m_fs_object->set_used_sectors(m_partition);
|
2019-07-26 09:18:58 -06:00
|
|
|
// Test file system usage is reported correctly.
|
|
|
|
// Used is between 0 and length.
|
|
|
|
EXPECT_LE(0, m_partition.sectors_used);
|
|
|
|
EXPECT_LE(m_partition.sectors_used, m_partition.get_sector_length());
|
|
|
|
// Unused is between 0 and length.
|
|
|
|
EXPECT_LE(0, m_partition.sectors_unused);
|
|
|
|
EXPECT_LE(m_partition.sectors_unused, m_partition.get_sector_length());
|
|
|
|
// Unallocated is 0.
|
|
|
|
EXPECT_EQ(m_partition.sectors_unallocated, 0);
|
|
|
|
// Used + unused = length.
|
|
|
|
EXPECT_EQ(m_partition.sectors_used + m_partition.sectors_unused, m_partition.get_sector_length());
|
|
|
|
|
|
|
|
// Test messages from read operation are empty or print them.
|
|
|
|
EXPECT_TRUE(m_partition.get_messages().empty()) << m_partition;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndReadLabel)
|
2019-07-26 09:18:58 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(read_label);
|
2019-10-09 06:35:17 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
2019-10-14 10:12:37 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
|
2019-07-26 09:18:58 -06:00
|
|
|
|
|
|
|
const char* fs_label = "TEST_LABEL";
|
|
|
|
extra_setup();
|
|
|
|
m_partition.set_filesystem_label(fs_label);
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 09:18:58 -06:00
|
|
|
|
|
|
|
// Test reading the label is successful.
|
2019-08-27 09:49:02 -06:00
|
|
|
reload_partition();
|
2019-08-02 04:15:48 -06:00
|
|
|
m_fs_object->read_label(m_partition);
|
2019-07-26 09:18:58 -06:00
|
|
|
EXPECT_STREQ(fs_label, m_partition.get_filesystem_label().c_str());
|
|
|
|
|
|
|
|
// Test messages from read operation are empty or print them.
|
|
|
|
EXPECT_TRUE(m_partition.get_messages().empty()) << m_partition;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndReadUUID)
|
2019-07-26 09:18:58 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(read_uuid);
|
2019-10-09 06:35:17 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
2019-10-14 10:12:37 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
|
2019-07-26 09:18:58 -06:00
|
|
|
|
|
|
|
extra_setup();
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 09:18:58 -06:00
|
|
|
|
|
|
|
// Test reading the UUID is successful.
|
2019-08-27 09:49:02 -06:00
|
|
|
reload_partition();
|
2019-08-02 04:15:48 -06:00
|
|
|
m_fs_object->read_uuid(m_partition);
|
2019-08-05 09:31:02 -06:00
|
|
|
EXPECT_GE(m_partition.uuid.size(), 9U);
|
2019-07-26 09:18:58 -06:00
|
|
|
|
|
|
|
// Test messages from read operation are empty or print them.
|
|
|
|
EXPECT_TRUE(m_partition.get_messages().empty()) << m_partition;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndWriteLabel)
|
2019-07-26 14:11:51 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(write_label);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
2019-10-14 10:12:37 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
|
2019-07-26 14:11:51 -06:00
|
|
|
|
|
|
|
extra_setup();
|
|
|
|
m_partition.set_filesystem_label("FIRST");
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 14:11:51 -06:00
|
|
|
|
|
|
|
// Test writing a label is successful.
|
|
|
|
m_partition.set_filesystem_label("SECOND");
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->write_label(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 14:11:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndWriteUUID)
|
2019-07-26 14:11:51 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(write_uuid);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
2019-10-14 10:12:37 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
|
2019-07-26 14:11:51 -06:00
|
|
|
|
|
|
|
extra_setup();
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 14:11:51 -06:00
|
|
|
|
|
|
|
// Test writing a new random UUID is successful.
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 14:11:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndCheck)
|
2019-07-26 14:11:51 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(check);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
2019-07-26 14:11:51 -06:00
|
|
|
|
|
|
|
extra_setup();
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 14:11:51 -06:00
|
|
|
|
|
|
|
// Test checking the file system is successful.
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->check_repair(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 14:11:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndRemove)
|
2019-07-26 14:11:51 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(remove);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
2019-07-26 14:11:51 -06:00
|
|
|
|
|
|
|
extra_setup();
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 14:11:51 -06:00
|
|
|
|
|
|
|
// Test removing the file system is successful. Note that most file systems don't
|
|
|
|
// implement remove so will skip this test.
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->remove(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-26 14:11:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndGrow)
|
2019-07-27 02:59:22 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(grow);
|
Create loop devices for online resized file system tests (!49)
File systems BTRFS, JFS, NILFS2 and XFS can only be resized while
mounted, but only root can mount file systems. Therefore these tests
fail. Also BTRFS resize uses 'btrfs filesystem show' to discover the
devid, which also fails as described in the previous commit message.
Note that root can mount a file system image directly, but that it
implicitly creates loop device:
# truncate -s 256M test.img
# mkfs.xfs test.img
# mount test.img /mnt/1
# fgrep /mnt/1 /proc/mounts
/dev/loop0 /mnt/1 xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
# losetup -a
/dev/loop0: [64768]:35826659 (/root/test.img)
Therefore make these tests root only and require an explicit loop
device. Now these file system resize tests succeed as root and are
skipped as non-root.
Closes !49 - Add file system interface tests
2019-10-10 09:35:46 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
|
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_JFS);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
Create loop devices for online resized file system tests (!49)
File systems BTRFS, JFS, NILFS2 and XFS can only be resized while
mounted, but only root can mount file systems. Therefore these tests
fail. Also BTRFS resize uses 'btrfs filesystem show' to discover the
devid, which also fails as described in the previous commit message.
Note that root can mount a file system image directly, but that it
implicitly creates loop device:
# truncate -s 256M test.img
# mkfs.xfs test.img
# mount test.img /mnt/1
# fgrep /mnt/1 /proc/mounts
/dev/loop0 /mnt/1 xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
# losetup -a
/dev/loop0: [64768]:35826659 (/root/test.img)
Therefore make these tests root only and require an explicit loop
device. Now these file system resize tests succeed as root and are
skipped as non-root.
Closes !49 - Add file system interface tests
2019-10-10 09:35:46 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
|
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_XFS);
|
2019-07-27 02:59:22 -06:00
|
|
|
|
|
|
|
extra_setup(IMAGESIZE_Default);
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-27 02:59:22 -06:00
|
|
|
|
|
|
|
// Test growing the file system is successful.
|
|
|
|
resize_image(IMAGESIZE_Larger);
|
|
|
|
reload_partition();
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->resize(m_partition, m_operation_detail, true)) << m_operation_detail;
|
2019-07-27 02:59:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
TEST_P(SupportedFileSystemsTest, CreateAndShrink)
|
2019-07-27 02:59:22 -06:00
|
|
|
{
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(create);
|
|
|
|
SKIP_IF_FS_DOESNT_SUPPORT(shrink);
|
Create loop devices for online resized file system tests (!49)
File systems BTRFS, JFS, NILFS2 and XFS can only be resized while
mounted, but only root can mount file systems. Therefore these tests
fail. Also BTRFS resize uses 'btrfs filesystem show' to discover the
devid, which also fails as described in the previous commit message.
Note that root can mount a file system image directly, but that it
implicitly creates loop device:
# truncate -s 256M test.img
# mkfs.xfs test.img
# mount test.img /mnt/1
# fgrep /mnt/1 /proc/mounts
/dev/loop0 /mnt/1 xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
# losetup -a
/dev/loop0: [64768]:35826659 (/root/test.img)
Therefore make these tests root only and require an explicit loop
device. Now these file system resize tests succeed as root and are
skipped as non-root.
Closes !49 - Add file system interface tests
2019-10-10 09:35:46 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_BTRFS);
|
2019-08-30 10:25:40 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
|
Create loop devices for online resized file system tests (!49)
File systems BTRFS, JFS, NILFS2 and XFS can only be resized while
mounted, but only root can mount file systems. Therefore these tests
fail. Also BTRFS resize uses 'btrfs filesystem show' to discover the
devid, which also fails as described in the previous commit message.
Note that root can mount a file system image directly, but that it
implicitly creates loop device:
# truncate -s 256M test.img
# mkfs.xfs test.img
# mount test.img /mnt/1
# fgrep /mnt/1 /proc/mounts
/dev/loop0 /mnt/1 xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
# losetup -a
/dev/loop0: [64768]:35826659 (/root/test.img)
Therefore make these tests root only and require an explicit loop
device. Now these file system resize tests succeed as root and are
skipped as non-root.
Closes !49 - Add file system interface tests
2019-10-10 09:35:46 -06:00
|
|
|
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
|
2019-07-27 02:59:22 -06:00
|
|
|
|
|
|
|
extra_setup(IMAGESIZE_Larger);
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
|
2019-07-27 02:59:22 -06:00
|
|
|
|
|
|
|
// Test shrinking the file system is successful.
|
|
|
|
shrink_partition(IMAGESIZE_Default);
|
2019-08-02 04:15:48 -06:00
|
|
|
ASSERT_TRUE(m_fs_object->resize(m_partition, m_operation_detail, false)) << m_operation_detail;
|
2019-07-27 02:59:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 04:15:48 -06:00
|
|
|
// Instantiate the test case so every test is run for the specified file system types.
|
|
|
|
// 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
|
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
2019-08-05 09:13:04 -06:00
|
|
|
INSTANTIATE_TEST_CASE_P(My,
|
|
|
|
SupportedFileSystemsTest,
|
|
|
|
::testing::ValuesIn(SupportedFileSystemsTest::get_supported_fstypes()),
|
|
|
|
param_fsname);
|
2019-08-02 04:15:48 -06:00
|
|
|
|
|
|
|
|
2019-07-17 06:08:08 -06:00
|
|
|
} // namespace GParted
|
|
|
|
|
|
|
|
|
2019-09-24 02:17:30 -06:00
|
|
|
// Re-execute current executable using xvfb-run so that it provides a virtual X11 display.
|
|
|
|
void exec_using_xvfb_run(int argc, char** argv)
|
|
|
|
{
|
|
|
|
// argc+2 = Space for "xvfb-run" command, existing argc strings plus NULL pointer.
|
|
|
|
size_t size = sizeof(char*) * (argc+2);
|
|
|
|
char** new_argv = (char**)malloc(size);
|
|
|
|
if (new_argv == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to allocate %lu bytes of memory. errno=%d,%s\n",
|
|
|
|
(unsigned long)size, errno, strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
new_argv[0] = strdup("xvfb-run");
|
|
|
|
if (new_argv[0] == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to allocate %lu bytes of memory. errno=%d,%s\n",
|
|
|
|
(unsigned long)strlen(new_argv[0])+1, errno, strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy argv pointers including final NULL pointer.
|
|
|
|
for (unsigned int i = 0; i <= (unsigned)argc; i++)
|
|
|
|
new_argv[i+1] = argv[i];
|
|
|
|
|
|
|
|
execvp(new_argv[0], new_argv);
|
|
|
|
fprintf(stderr, "Failed to execute '%s %s ...'. errno=%d,%s\n", new_argv[0], new_argv[1],
|
|
|
|
errno, strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-17 06:08:08 -06:00
|
|
|
// Custom Google Test main().
|
|
|
|
// Reference:
|
|
|
|
// * Google Test, Primer, Writing the main() function
|
|
|
|
// https://github.com/google/googletest/blob/master/googletest/docs/primer.md#writing-the-main-function
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
printf("Running main() from %s\n", __FILE__);
|
2019-09-24 02:17:30 -06:00
|
|
|
|
|
|
|
const char* display = getenv("DISPLAY");
|
|
|
|
if (display == NULL)
|
|
|
|
{
|
|
|
|
printf("DISPLAY environment variable unset. Executing 'xvfb-run %s ...'\n", argv[0]);
|
|
|
|
exec_using_xvfb_run(argc, argv);
|
|
|
|
}
|
|
|
|
printf("DISPLAY=\"%s\"\n", display);
|
|
|
|
|
2019-07-17 06:08:08 -06:00
|
|
|
// Initialise threading in GParted to allow FileSystem interface classes to
|
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
2019-08-05 09:13:04 -06:00
|
|
|
// successfully use Utils:: and Filesystem::execute_command(). Must be before
|
|
|
|
// InitGoogleTest().
|
2019-07-17 06:08:08 -06:00
|
|
|
GParted::GParted_Core::mainthread = Glib::Thread::self();
|
|
|
|
Gtk::Main gtk_main = Gtk::Main();
|
|
|
|
|
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
2019-08-05 09:13:04 -06:00
|
|
|
testing::InitGoogleTest(&argc, argv);
|
|
|
|
|
2019-07-17 06:08:08 -06:00
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|