gparted/tests/test_SupportedFileSystems.cc

653 lines
23 KiB
C++
Raw Normal View History

Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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/>.
*/
/* Test SupportedFileSystems
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
*
* Test the derived FileSystem interface classes which call the file system specific
* executables via the SupportedFileSystems class. Rather than mocking command execution
* and returned output just run real commands, effectively making this integration testing.
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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.
*/
Move duplicated test code into shared modules (#220) Move common testing code which doesn't need linking with GParted objects into the common module. Move the remaining common code used to print GParted objects using the insertion operator (operator<<) into the insertion_operators module. Split the common code like this so that the operator<<(std::ostream&, const OperationDetail&) function is not included in test_PipeCapture and it is not forced to link with all the non-UI related GParted objects. The Automake manual provides guidance that when a header belongs to a single program it is recommended to be listed in the program's _SOURCES variable and for a directory only containing header files listing them in the noinst_HEADERS variable is the right variable to use [1]. However the guidance doesn't cover this case for common.h and insertion_operators.h; header files in a directory with other files and used by multiple programs. So just because we have gparted_core_OBJECTS (normal Makefile, not Automake special variable) listing objects to link with, choose to use noinst_HEADERS Automake variable to list needed headers. [1] GNU Automake manual, 9.2 Header files https://www.gnu.org/software/automake/manual/html_node/Headers.html "Usually, only header files that accompany installed libraries need to be installed. Headers used by programs or convenience libraries are not installed. The noinst_HEADERS variable can be used for such headers. However, when the header belongs to a single convenience library or program, we recommend listing it in the program's or library's _SOURCES variable (see Defining program sources) instead of in noinst_HEADERS. This is clearer for the Makefile.am reader. noinst_HEADERS would be the right variable to use in a directory containing only headers and no associated library or program. All header files must be listed somewhere; in a _SOURCES variable or in a _HEADERS variable. Missing ones will not appear in the distribution. " Closes #220 - Format to Cleared not clearing "pdc" ataraid signature
2023-02-05 04:16:43 -07:00
#include "common.h"
#include "insertion_operators.h"
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
#include "GParted_Core.h"
#include "FileSystem.h"
#include "OperationDetail.h"
#include "Partition.h"
#include "Utils.h"
#include "SupportedFileSystems.h"
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
#include "gtest/gtest.h"
#include <iostream>
#include <fstream>
#include <vector>
Run test program under xvfb-run to satisfy need for an X11 display (!49) Running test_ext2 in GitLab Continuous Integration environment fails like this: (test_ext2:6338): Gtk-WARNING **: 09:06:17.576: cannot open display: Running main() from test_ext2.cc Obviously the GitLab CI environment doesn't have an X11 display, but unfortunately this test case code requires one. Utils::execute_command() calls Gtk::Main::run() so requires a Gtk::Main object constructing and therefore an X11 display, even though this program never displays anything graphical. The call chain is: main() test_ext2.cc Gtk::Main::Main() gtkmm/gtk/src/main.ccg Gtk::Main::init() [1] gtk_init() gtk/gtk/gtkmain.c [2] which exits with a non-zero exit status when the DISPLAY environment variable is unset. Looked at deriving from Gtk::Main class and writing a replacement init() method which calls gtk_init_check() instead of gtk_init() but Gtk::Main::instance_ is a private member so not accessible in a derived class. Tried using Glib::MainLoop instead of Gtk::Main, but that doesn't initialise everything that Gtk::Main(), so the program crashes. Therefore use xvfb-run [3][4] to run this test program against a virtual X11 display when a real display isn't available. Coded execution of xvfb-run into this test program so that it can simply be executed on the command line like the other test programs, without having to remember to run "xvfb-run ./test_ext2 ...". [1] Gtk::Main::init() https://gitlab.gnome.org/GNOME/gtkmm/blob/3.10.1/gtk/src/main.ccg#L287 [2] gtk_init() https://gitlab.gnome.org/GNOME/gtk/blob/3.10.9/gtk/gtkmain.c#L1000 [3] how to run gtk app on linux without an x server https://superuser.com/questions/624918/how-to-run-gtk-app-on-linux-without-an-x-server [4] Using GTK without DISPLAY https://stackoverflow.com/questions/11694278/using-gtk-without-display Closes !49 - Add file system interface tests
2019-09-24 02:17:30 -06:00
#include <stdlib.h>
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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
{
// 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;
}
Print file system types in parameterised test names (!49) Until now the parameterised test values are printed as part of the test names as just 0, 1, etc. like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (48 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (11 ms) Provide the file system types as the names for the parameterised test values [1]. Now the test names are printed like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/ext2 [ OK ] My/SupportedFileSystemsTest.Create/ext2 (51 ms) [ RUN ] My/SupportedFileSystemsTest.Create/linuxswap [ OK ] My/SupportedFileSystemsTest.Create/linuxswap (11 ms) Also use these Google Test name friendly ASCII alphanumeric only names everywhere the file system type needs to be reported in this test program. [1] 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 Closes !49 - Add file system interface tests
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";
Print file system types in parameterised test names (!49) Until now the parameterised test values are printed as part of the test names as just 0, 1, etc. like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (48 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (11 ms) Provide the file system types as the names for the parameterised test values [1]. Now the test names are printed like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/ext2 [ OK ] My/SupportedFileSystemsTest.Create/ext2 (51 ms) [ RUN ] My/SupportedFileSystemsTest.Create/linuxswap [ OK ] My/SupportedFileSystemsTest.Create/linuxswap (11 ms) Also use these Google Test name friendly ASCII alphanumeric only names everywhere the file system type needs to be reported in this test program. [1] 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 Closes !49 - Add file system interface tests
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";
Print file system types in parameterised test names (!49) Until now the parameterised test values are printed as part of the test names as just 0, 1, etc. like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (48 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (11 ms) Provide the file system types as the names for the parameterised test values [1]. Now the test names are printed like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/ext2 [ OK ] My/SupportedFileSystemsTest.Create/ext2 (51 ms) [ RUN ] My/SupportedFileSystemsTest.Create/linuxswap [ OK ] My/SupportedFileSystemsTest.Create/linuxswap (11 ms) Also use these Google Test name friendly ASCII alphanumeric only names everywhere the file system type needs to be reported in this test program. [1] 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 Closes !49 - Add file system interface tests
2019-08-04 04:31:57 -06:00
default: break;
}
return std::string(Utils::get_filesystem_string(fstype));
}
// Function callable by INSTANTIATE_TEST_SUITE_P() to get the file system type for
// printing as part of the test name.
Print file system types in parameterised test names (!49) Until now the parameterised test values are printed as part of the test names as just 0, 1, etc. like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (48 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (11 ms) Provide the file system types as the names for the parameterised test values [1]. Now the test names are printed like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/ext2 [ OK ] My/SupportedFileSystemsTest.Create/ext2 (51 ms) [ RUN ] My/SupportedFileSystemsTest.Create/linuxswap [ OK ] My/SupportedFileSystemsTest.Create/linuxswap (11 ms) Also use these Google Test name friendly ASCII alphanumeric only names everywhere the file system type needs to be reported in this test program. [1] 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 Closes !49 - Add file system interface tests
2019-08-04 04:31:57 -06:00
const std::string param_fsname(const ::testing::TestParamInfo<FSType>& info)
{
return test_fsname(info.param);
}
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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)
#define SKIP_IF_FS_DOESNT_SUPPORT(opt) \
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
if (s_supported_filesystems->get_fs_support(m_fstype).opt != FS::EXTERNAL) \
{ \
std::cout << __FILE__ << ":" << __LINE__ << ": Skip test. " \
<< #opt << " not supported or support not found" << std::endl; \
return; \
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -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; \
}
#define SKIP_IF_TEST_DISABLED_FOR_FS(fstype) \
if (m_fstype == fstype) \
{ \
std::cout << __FILE__ << ":" << __LINE__ << ": Skip test. " \
<< "Test disabled for file system" << std::endl; \
return; \
}
Ignore test failure when reiser4 reports null UUID (#145) The GitLab CI ubuntu_test job has occasionally been failing like this, perhaps once every few weeks or so. [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4 test_SupportedFileSystems.cc:569: Failure Expected: (m_partition.uuid.size()) >= (9U), actual: 0 vs 9 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4, where GetParam() = 24 (17 ms) [----------] 1 test from My/SupportedFileSystemsTest (17 ms total) Turns out there are 2 bugs in resier4progs. One causes debugfs.reiser4 to report a null UUID if the first byte of the UUID happens to be zero [1], and the other cases mkfs.resier4 to write a corrupted UUID, sometimes a null (all zeros) UUID [2]. There is a 1 in 256 chance of getting a null UUID [2] when creating and reading a reiser4 file system, hence the occasional failure of the CI job. The centos_test job isn't affected because CentOS doesn't have the reiser4progs package. Fix this by detecting when reiser4 reports a null UUID and assign a dummy UUID to make the test pass. This does mean that there is a 1 in 256 chance of not detecting a true failure. However that still means there is a 255 in 256 chance of detecting a true failure. That's good odds. When a null UUID is detected for a reiser4 file system the test output looks like this: [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4 test_SupportedFileSystems.cc:580: Ignore test failure of a null UUID. [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4 (46 ms) [1] https://github.com/edward6/reiser4progs/commit/4802cdb18ae03031d0e51a58b6655f3b99021ec2 Fix up repair_master_print() [2] https://github.com/edward6/reiser4progs/commit/44cc024f398f60adef1519426d65f3f081ee826a Stop occasionally making file systems with null UUIDs Closes #145 - Sporadic failure of test case My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4
2021-03-18 15:10:39 -06:00
// Temporarily workaround bugs in mkfs.reiser4 and debugfs.reiser4 which occasionally
// 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 = 320*MEBIBYTE;
const Byte_Value IMAGESIZE_Larger = 512*MEBIBYTE;
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
class SupportedFileSystemsTest : public ::testing::TestWithParam<FSType>
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
{
protected:
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
SupportedFileSystemsTest();
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
virtual void SetUp();
virtual void create_image_file(Byte_Value size = IMAGESIZE_Default);
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
virtual void TearDown();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
public:
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
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();
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;
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
virtual void reload_partition();
virtual void resize_image(Byte_Value new_size);
virtual void shrink_partition(Byte_Value size);
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
static SupportedFileSystems* s_supported_filesystems; // Owning pointer
static const char* s_image_name;
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
FSType m_fstype;
FileSystem* m_fs_object; // Alias pointer
bool m_require_loopdev;
std::string m_dev_name;
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
Partition m_partition;
OperationDetail m_operation_detail;
};
SupportedFileSystems* SupportedFileSystemsTest::s_supported_filesystems = nullptr;
const char* SupportedFileSystemsTest::s_image_name = "test_SupportedFileSystems.img";
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
SupportedFileSystemsTest::SupportedFileSystemsTest()
: m_fstype(GetParam()), m_fs_object(nullptr), m_require_loopdev(false),
// Initialise top-level operation detail object with description ...
m_operation_detail("Operation details:", STATUS_NONE)
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
{
}
void SupportedFileSystemsTest::SetUp()
{
ASSERT_TRUE(s_supported_filesystems != nullptr) << __func__ << "(): TEST_BUG: File system interfaces not loaded";
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
// Lookup file system interface object.
m_fs_object = s_supported_filesystems->get_fs_object(m_fstype);
ASSERT_TRUE(m_fs_object != nullptr) << __func__ << "(): TEST_BUG: Interface object not found for file system "
<< test_fsname(m_fstype);
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
}
void SupportedFileSystemsTest::create_image_file(Byte_Value size)
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
{
// Create new image file to work with.
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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);
ASSERT_EQ(ftruncate(fd, (off_t)size), 0) << "Failed to set image file '" << s_image_name << "' to size "
<< size << ". errno=" << errno << "," << strerror(errno);
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
close(fd);
m_dev_name = s_image_name;
if (m_require_loopdev)
m_dev_name = create_loopdev(s_image_name);
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
reload_partition();
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
}
void SupportedFileSystemsTest::TearDown()
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
{
if (m_require_loopdev)
detach_loopdev(m_dev_name);
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
unlink(s_image_name);
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
m_fs_object = nullptr;
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
}
// Common test case initialisation creating the supported file system interface object.
void SupportedFileSystemsTest::SetUpTestCase()
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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();
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -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].fstype))
v.push_back(fss[i].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
}
return v;
}
// Create the supported file system interface object.
void SupportedFileSystemsTest::setup_supported_filesystems()
{
if (s_supported_filesystems == nullptr)
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
{
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()
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
{
delete s_supported_filesystems;
s_supported_filesystems = nullptr;
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -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 "";
}
return Utils::trim_trailing_new_line(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";
}
}
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
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.
void SupportedFileSystemsTest::reload_partition()
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
{
m_partition.Reset();
// Use libparted to get the sector size etc. of the image file.
PedDevice* lp_device = ped_device_get(m_dev_name.c_str());
ASSERT_TRUE(lp_device != nullptr);
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
// Prepare partition object spanning whole of the image file.
m_partition.set_unpartitioned(m_dev_name,
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
lp_device->path,
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
m_fstype,
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
lp_device->length,
lp_device->sector_size,
false);
ped_device_destroy(lp_device);
lp_device = nullptr;
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
}
void SupportedFileSystemsTest::resize_image(Byte_Value new_size)
{
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);
if (m_require_loopdev)
reload_loopdev_size(m_dev_name);
}
void SupportedFileSystemsTest::shrink_partition(Byte_Value new_size)
{
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;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, Create)
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
create_image_file();
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
// Call create, check for success and print operation details on failure.
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndReadUsage)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(read);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
Create loop devices for NILFS2 read and write FS interface tests (!49) For NILFS2 the read and write tests which use nilfs-tune all fail using an image file, even when run as root, however the other tests succeed. Selected output from the test program: # ./test_SupportedFileSystems --gtest_filter='*/nilfs2' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.Create/nilfs2 (22 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2, where GetParam() = 22 (31 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadLabel/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUUID/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteLabel/nilfs2, where GetParam() = 22 (37 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteUUID/nilfs2, where GetParam() = 22 (39 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/nilfs2 (386 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/nilfs2 (345 ms) [----------] 10 tests from My/SupportedFileSystemsTest (920 ms total) [==========] 10 tests from 1 test case ran. (920 ms total) nilfs-tune fails like this when given an image file: # truncate -s 256M test.img # mkfs.nilfs2 test.img mkfs.nilfs2 (nilfs-utils 2.2.7) Start writing file system initial data to the device Blocksize:4096 Device:test.img Device Size:268435456 File system initialization succeeded !! # nilfs-tune -l test.img nilfs-tune 2.2.7 nilfs-tune: test.img: cannot open NILFS # echo $? 1 However using nilfs-tune via a loop device works: # losetup --show --find /dev/loop0 /dev/loop0 # nilfs-tune -l /dev/loop0 nilfs-tune 2.2.7 Filesystem volume name: (none) Filesystem UUID: fc49912c-4d39-4672-8610-1e1185d0db5f Filesystem magic number: 0x3434 Filesystem revision #: 2.0 Filesystem features: (none) Filesystem state: valid Filesystem OS type: Linux Block size: 4096 ... So nilfs-tune only works with block devices. Fix by making these tests require a loop device and therefore make them root only. Now these tests are skipped as non-root user and pass as root. Closes !49 - Add file system interface tests
2019-10-14 10:12:37 -06:00
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
create_image_file();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
reload_partition();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
m_fs_object->set_used_sectors(m_partition);
// Test file system usage is reported correctly.
// Used is between 0 and length.
Accept FS usage figures within significant unallocated threshold (!49) So far the read file system usage figures, read via the file system interface classes using file system specific tools, have been checked to the exact sector for: 0 <= used <= size 0 <= unused <= size unallocated = 0 used + unused = size However for JFS and NTFS this fails like this: # ./test_SupportedFileSystems --gtest_filter='*ReadUsage/*' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/btrfs (335 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/exfat (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext2 (38 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext3 (131 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext4 (32 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/f2fs (47 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/fat16 (19 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/fat32 (48 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/hfs (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/hfsplus (0 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (73 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/linuxswap (20 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/luks (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/lvm2pv (410 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/minix (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2 (226 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 (56 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/reiser4 (49 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/reiserfs (139 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/udf (34 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/xfs (67 ms) [----------] 21 tests from My/SupportedFileSystemsTest (1726 ms total) [==========] 21 tests from 1 test case ran. (1726 ms total) # ./test_SupportedFileSystems --gtest_filter='*ReadUsage/jfs:*ReadUsage/ntfs' Running main() from test_SupportedFileSystems.cc Note: Google Test filter = *ReadUsage/jfs:*ReadUsage/ntfs [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs test_SupportedFileSystems.cc:465: Failure Expected equality of these values: m_partition.sectors_unallocated Which is: 2472 0 test_SupportedFileSystems.cc:517: Failure Expected equality of these values: m_partition.sectors_used + m_partition.sectors_unused Which is: 521816 m_partition.get_sector_length() Which is: 524288 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (36 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs test_SupportedFileSystems.cc:465: Failure Expected equality of these values: m_partition.sectors_unallocated Which is: 8 0 test_SupportedFileSystems.cc:517: Failure Expected equality of these values: m_partition.sectors_used + m_partition.sectors_unused Which is: 524280 m_partition.get_sector_length() Which is: 524288 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 (35 ms) [----------] 2 tests from My/SupportedFileSystemsTest (71 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (72 ms total) [ PASSED ] 0 tests. [ FAILED ] 2 tests, listed below: [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 2 FAILED TESTS So JFS is reporting 2472 unallocated sectors in a size of 524288 sectors and NTFS is reporting 8 unallocated sectors in the same size. This exact issue is already solved for GParted so that it doesn't show a small amount of unallocated space by commits [1][2] from Bug 499202 [3]. Fix the same way, use the accessors to the file system usage figures which don't show unallocated space when it is below the significant threshold. [1] b5c80f18a9ce27fda2b11e9b590d7f856209ac32 Enhance calculation of significant unallocated space (#499202) [2] 7ebedc4bb3b81e85fb4c628a2a05308ada147d68 Don't show intrinsic unallocated space (#499202) [3] Bug 499202 - gparted does not see the difference if partition size differs from filesystem size https://bugzilla.gnome.org/show_bug.cgi?id=499202 Closes !49 - Add file system interface tests
2019-10-20 05:22:49 -06:00
EXPECT_LE(0, m_partition.get_sectors_used());
EXPECT_LE(m_partition.get_sectors_used(), m_partition.get_sector_length());
// Unused is between 0 and length.
Accept FS usage figures within significant unallocated threshold (!49) So far the read file system usage figures, read via the file system interface classes using file system specific tools, have been checked to the exact sector for: 0 <= used <= size 0 <= unused <= size unallocated = 0 used + unused = size However for JFS and NTFS this fails like this: # ./test_SupportedFileSystems --gtest_filter='*ReadUsage/*' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/btrfs (335 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/exfat (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext2 (38 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext3 (131 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext4 (32 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/f2fs (47 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/fat16 (19 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/fat32 (48 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/hfs (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/hfsplus (0 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (73 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/linuxswap (20 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/luks (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/lvm2pv (410 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/minix (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2 (226 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 (56 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/reiser4 (49 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/reiserfs (139 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/udf (34 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/xfs (67 ms) [----------] 21 tests from My/SupportedFileSystemsTest (1726 ms total) [==========] 21 tests from 1 test case ran. (1726 ms total) # ./test_SupportedFileSystems --gtest_filter='*ReadUsage/jfs:*ReadUsage/ntfs' Running main() from test_SupportedFileSystems.cc Note: Google Test filter = *ReadUsage/jfs:*ReadUsage/ntfs [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs test_SupportedFileSystems.cc:465: Failure Expected equality of these values: m_partition.sectors_unallocated Which is: 2472 0 test_SupportedFileSystems.cc:517: Failure Expected equality of these values: m_partition.sectors_used + m_partition.sectors_unused Which is: 521816 m_partition.get_sector_length() Which is: 524288 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (36 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs test_SupportedFileSystems.cc:465: Failure Expected equality of these values: m_partition.sectors_unallocated Which is: 8 0 test_SupportedFileSystems.cc:517: Failure Expected equality of these values: m_partition.sectors_used + m_partition.sectors_unused Which is: 524280 m_partition.get_sector_length() Which is: 524288 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 (35 ms) [----------] 2 tests from My/SupportedFileSystemsTest (71 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (72 ms total) [ PASSED ] 0 tests. [ FAILED ] 2 tests, listed below: [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 2 FAILED TESTS So JFS is reporting 2472 unallocated sectors in a size of 524288 sectors and NTFS is reporting 8 unallocated sectors in the same size. This exact issue is already solved for GParted so that it doesn't show a small amount of unallocated space by commits [1][2] from Bug 499202 [3]. Fix the same way, use the accessors to the file system usage figures which don't show unallocated space when it is below the significant threshold. [1] b5c80f18a9ce27fda2b11e9b590d7f856209ac32 Enhance calculation of significant unallocated space (#499202) [2] 7ebedc4bb3b81e85fb4c628a2a05308ada147d68 Don't show intrinsic unallocated space (#499202) [3] Bug 499202 - gparted does not see the difference if partition size differs from filesystem size https://bugzilla.gnome.org/show_bug.cgi?id=499202 Closes !49 - Add file system interface tests
2019-10-20 05:22:49 -06:00
EXPECT_LE(0, m_partition.get_sectors_unused());
EXPECT_LE(m_partition.get_sectors_unused(), m_partition.get_sector_length());
// Unallocated is 0.
Accept FS usage figures within significant unallocated threshold (!49) So far the read file system usage figures, read via the file system interface classes using file system specific tools, have been checked to the exact sector for: 0 <= used <= size 0 <= unused <= size unallocated = 0 used + unused = size However for JFS and NTFS this fails like this: # ./test_SupportedFileSystems --gtest_filter='*ReadUsage/*' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/btrfs (335 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/exfat (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext2 (38 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext3 (131 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext4 (32 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/f2fs (47 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/fat16 (19 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/fat32 (48 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/hfs (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/hfsplus (0 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (73 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/linuxswap (20 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/luks (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/lvm2pv (410 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/minix (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2 (226 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 (56 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/reiser4 (49 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/reiserfs (139 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/udf (34 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/xfs (67 ms) [----------] 21 tests from My/SupportedFileSystemsTest (1726 ms total) [==========] 21 tests from 1 test case ran. (1726 ms total) # ./test_SupportedFileSystems --gtest_filter='*ReadUsage/jfs:*ReadUsage/ntfs' Running main() from test_SupportedFileSystems.cc Note: Google Test filter = *ReadUsage/jfs:*ReadUsage/ntfs [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs test_SupportedFileSystems.cc:465: Failure Expected equality of these values: m_partition.sectors_unallocated Which is: 2472 0 test_SupportedFileSystems.cc:517: Failure Expected equality of these values: m_partition.sectors_used + m_partition.sectors_unused Which is: 521816 m_partition.get_sector_length() Which is: 524288 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (36 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs test_SupportedFileSystems.cc:465: Failure Expected equality of these values: m_partition.sectors_unallocated Which is: 8 0 test_SupportedFileSystems.cc:517: Failure Expected equality of these values: m_partition.sectors_used + m_partition.sectors_unused Which is: 524280 m_partition.get_sector_length() Which is: 524288 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 (35 ms) [----------] 2 tests from My/SupportedFileSystemsTest (71 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (72 ms total) [ PASSED ] 0 tests. [ FAILED ] 2 tests, listed below: [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 2 FAILED TESTS So JFS is reporting 2472 unallocated sectors in a size of 524288 sectors and NTFS is reporting 8 unallocated sectors in the same size. This exact issue is already solved for GParted so that it doesn't show a small amount of unallocated space by commits [1][2] from Bug 499202 [3]. Fix the same way, use the accessors to the file system usage figures which don't show unallocated space when it is below the significant threshold. [1] b5c80f18a9ce27fda2b11e9b590d7f856209ac32 Enhance calculation of significant unallocated space (#499202) [2] 7ebedc4bb3b81e85fb4c628a2a05308ada147d68 Don't show intrinsic unallocated space (#499202) [3] Bug 499202 - gparted does not see the difference if partition size differs from filesystem size https://bugzilla.gnome.org/show_bug.cgi?id=499202 Closes !49 - Add file system interface tests
2019-10-20 05:22:49 -06:00
EXPECT_EQ(m_partition.get_sectors_unallocated(), 0);
// Used + unused = length.
Accept FS usage figures within significant unallocated threshold (!49) So far the read file system usage figures, read via the file system interface classes using file system specific tools, have been checked to the exact sector for: 0 <= used <= size 0 <= unused <= size unallocated = 0 used + unused = size However for JFS and NTFS this fails like this: # ./test_SupportedFileSystems --gtest_filter='*ReadUsage/*' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/btrfs (335 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/exfat (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext2 (38 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext3 (131 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/ext4 (32 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/f2fs (47 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/fat16 (19 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/fat32 (48 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/hfs (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/hfsplus (0 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (73 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/linuxswap (20 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/luks (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/lvm2pv (410 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/minix (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2 (226 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 (56 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/reiser4 (49 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/reiserfs (139 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/udf (34 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/xfs (67 ms) [----------] 21 tests from My/SupportedFileSystemsTest (1726 ms total) [==========] 21 tests from 1 test case ran. (1726 ms total) # ./test_SupportedFileSystems --gtest_filter='*ReadUsage/jfs:*ReadUsage/ntfs' Running main() from test_SupportedFileSystems.cc Note: Google Test filter = *ReadUsage/jfs:*ReadUsage/ntfs [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs test_SupportedFileSystems.cc:465: Failure Expected equality of these values: m_partition.sectors_unallocated Which is: 2472 0 test_SupportedFileSystems.cc:517: Failure Expected equality of these values: m_partition.sectors_used + m_partition.sectors_unused Which is: 521816 m_partition.get_sector_length() Which is: 524288 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (36 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs test_SupportedFileSystems.cc:465: Failure Expected equality of these values: m_partition.sectors_unallocated Which is: 8 0 test_SupportedFileSystems.cc:517: Failure Expected equality of these values: m_partition.sectors_used + m_partition.sectors_unused Which is: 524280 m_partition.get_sector_length() Which is: 524288 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 (35 ms) [----------] 2 tests from My/SupportedFileSystemsTest (71 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (72 ms total) [ PASSED ] 0 tests. [ FAILED ] 2 tests, listed below: [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/ntfs, where GetParam() = 23 2 FAILED TESTS So JFS is reporting 2472 unallocated sectors in a size of 524288 sectors and NTFS is reporting 8 unallocated sectors in the same size. This exact issue is already solved for GParted so that it doesn't show a small amount of unallocated space by commits [1][2] from Bug 499202 [3]. Fix the same way, use the accessors to the file system usage figures which don't show unallocated space when it is below the significant threshold. [1] b5c80f18a9ce27fda2b11e9b590d7f856209ac32 Enhance calculation of significant unallocated space (#499202) [2] 7ebedc4bb3b81e85fb4c628a2a05308ada147d68 Don't show intrinsic unallocated space (#499202) [3] Bug 499202 - gparted does not see the difference if partition size differs from filesystem size https://bugzilla.gnome.org/show_bug.cgi?id=499202 Closes !49 - Add file system interface tests
2019-10-20 05:22:49 -06:00
EXPECT_EQ(m_partition.get_sectors_used() + m_partition.get_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;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndReadLabel)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(read_label);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
Create loop devices for NILFS2 read and write FS interface tests (!49) For NILFS2 the read and write tests which use nilfs-tune all fail using an image file, even when run as root, however the other tests succeed. Selected output from the test program: # ./test_SupportedFileSystems --gtest_filter='*/nilfs2' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.Create/nilfs2 (22 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2, where GetParam() = 22 (31 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadLabel/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUUID/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteLabel/nilfs2, where GetParam() = 22 (37 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteUUID/nilfs2, where GetParam() = 22 (39 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/nilfs2 (386 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/nilfs2 (345 ms) [----------] 10 tests from My/SupportedFileSystemsTest (920 ms total) [==========] 10 tests from 1 test case ran. (920 ms total) nilfs-tune fails like this when given an image file: # truncate -s 256M test.img # mkfs.nilfs2 test.img mkfs.nilfs2 (nilfs-utils 2.2.7) Start writing file system initial data to the device Blocksize:4096 Device:test.img Device Size:268435456 File system initialization succeeded !! # nilfs-tune -l test.img nilfs-tune 2.2.7 nilfs-tune: test.img: cannot open NILFS # echo $? 1 However using nilfs-tune via a loop device works: # losetup --show --find /dev/loop0 /dev/loop0 # nilfs-tune -l /dev/loop0 nilfs-tune 2.2.7 Filesystem volume name: (none) Filesystem UUID: fc49912c-4d39-4672-8610-1e1185d0db5f Filesystem magic number: 0x3434 Filesystem revision #: 2.0 Filesystem features: (none) Filesystem state: valid Filesystem OS type: Linux Block size: 4096 ... So nilfs-tune only works with block devices. Fix by making these tests require a loop device and therefore make them root only. Now these tests are skipped as non-root user and pass as root. Closes !49 - Add file system interface tests
2019-10-14 10:12:37 -06:00
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
const char* fs_label = "TEST_LABEL";
create_image_file();
m_partition.set_filesystem_label(fs_label);
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
// Test reading the label is successful.
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
reload_partition();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
m_fs_object->read_label(m_partition);
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;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndReadUUID)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(read_uuid);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
Create loop devices for NILFS2 read and write FS interface tests (!49) For NILFS2 the read and write tests which use nilfs-tune all fail using an image file, even when run as root, however the other tests succeed. Selected output from the test program: # ./test_SupportedFileSystems --gtest_filter='*/nilfs2' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.Create/nilfs2 (22 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2, where GetParam() = 22 (31 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadLabel/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUUID/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteLabel/nilfs2, where GetParam() = 22 (37 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteUUID/nilfs2, where GetParam() = 22 (39 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/nilfs2 (386 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/nilfs2 (345 ms) [----------] 10 tests from My/SupportedFileSystemsTest (920 ms total) [==========] 10 tests from 1 test case ran. (920 ms total) nilfs-tune fails like this when given an image file: # truncate -s 256M test.img # mkfs.nilfs2 test.img mkfs.nilfs2 (nilfs-utils 2.2.7) Start writing file system initial data to the device Blocksize:4096 Device:test.img Device Size:268435456 File system initialization succeeded !! # nilfs-tune -l test.img nilfs-tune 2.2.7 nilfs-tune: test.img: cannot open NILFS # echo $? 1 However using nilfs-tune via a loop device works: # losetup --show --find /dev/loop0 /dev/loop0 # nilfs-tune -l /dev/loop0 nilfs-tune 2.2.7 Filesystem volume name: (none) Filesystem UUID: fc49912c-4d39-4672-8610-1e1185d0db5f Filesystem magic number: 0x3434 Filesystem revision #: 2.0 Filesystem features: (none) Filesystem state: valid Filesystem OS type: Linux Block size: 4096 ... So nilfs-tune only works with block devices. Fix by making these tests require a loop device and therefore make them root only. Now these tests are skipped as non-root user and pass as root. Closes !49 - Add file system interface tests
2019-10-14 10:12:37 -06:00
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
create_image_file();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
Write new UUID to JFS before testing reading UUID (!49) Testing reading the UUID from a newly created JFS was failing like this: $ ./test_SupportedFileSystems --gtest_filter='*ReadUUID/jfs' ... [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/jfs test_SupportedFileSystems.cc:552: Failure Expected: (m_partition.uuid.size()) >= (9U), actual: 0 vs 9 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUUID/jfs, where GetParam() = 17 (57 ms) Mkfs.jfs creates a file system as version 1. It does have a UUID and blkid can report it, but jfs_tune doesn't report it. $ touch -s 256M test_jfs.img $ mkfs.jfs -q test_jfs.img mkfs.jfs version 1.1.15, 04-Mar-2011 Format completed successfully. 262144 kilobytes total disk space. $ blkid test_jfs.img test_jfs.img: UUID="6b0bb46a-a240-47b4-89ab-1fe759aa572d" TYPE="jfs" $ jfs_tune -l test_jfs.img | egrep 'version|UUID' jfs_tune version 1.1.15, 04-Mar-2011 JFS version: 1 $ hexdump -C test_jfs.img 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00008000 4a 46 53 31 01 00 00 00 58 f6 07 00 00 00 00 00 |JFS1....X.......| Version >---------------- ^^ ^^ ^^ ^^ ... 00008080 00 00 00 00 00 00 00 00 6b 0b b4 6a a2 40 47 b4 |........k..j.@G.| 00008090 89 ab 1f e7 59 aa 57 2d 00 00 00 00 00 00 00 00 |....Y.W-........| UUID >-------------------------------- ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ However writing a new UUID to the JFS also updates the version to 2 and allows jfs_tune to report the UUID. $ jfs_tune -U random test_jfs.img jfs_tune version 1.1.15, 04-Mar-2011 UUID updated successfully. $ blkid test_jfs.img test_jfs.img: UUID="6374ec58-3568-4ffb-bea9-ff76bf5c192f" TYPE="jfs" $ jfs_tune -l test_jfs.img | egrep 'version|UUID' jfs_tune version 1.1.15, 04-Mar-2011 JFS version: 2 File system UUID: 6374ec58-3568-4ffb-bea9-ff76bf5c192f External log UUID: 00000000-0000-0000-0000-000000000000 $ hexdump -C test_jfs.img 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00008000 4a 46 53 31 02 00 00 00 58 f6 07 00 00 00 00 00 |JFS1....X.......| Version >---------------- ^^ ^^ ^^ ^^ ... 00008080 00 00 00 00 00 00 00 00 63 74 ec 58 35 68 4f fb |........ct.X5hO.| 00008090 be a9 ff 76 bf 5c 19 2f 00 00 00 00 00 00 00 00 |...v.\./........| New UUID >---------------------------- ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ Therefore change the CreateAndReadUUID test for JFS to also write a new UUID so that it also updates the version to 2, thus allowing jfs_tune to report the UUID and the test pass. Note that GParted doesn't encounter this problem because it used blkid by default to report the UUID and only falls back to using the file system interface method which calls jfs_tune when blkid is not available. Closes !49 - Add file system interface tests
2019-09-03 00:37:52 -06:00
if (m_fstype == FS_JFS)
{
// Write a new UUID to cause the jfs version to be updated from 1 to 2 so
// that jfs_tune can successfully report the UUID of the file system.
SKIP_IF_FS_DOESNT_SUPPORT(write_uuid);
ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_detail)) << m_operation_detail;
}
// Test reading the UUID is successful.
Reload Partition object after FS creation in read tests (!49) Here are the errors reported in the deliberately broken CreateAndReadLabel test from the previous commit message: [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:311: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (77 ms) Even though the test was deliberately broken by setting the wrong path for the file system image and the e2label command failed, apparently testing for the expected label still passed. What happened was that the desired "TEST_LABEL" has to be in the Partition object and then the file system was created. Then reading the file system label failed, however "TEST_LABEL" was already set in the Partition object so it matched. Reading the label is unique among the read actions of usage, label and UUID as the others don't need to be set before the file system is created. GParted doesn't encounter this issue because when refreshing devices it creates new blank Partition objects and then performs the read actions to populate them. Fix by resetting the Partition object back to only containing basic information before all the reading file system information tests, even though it is only needed in the read label case. This also better reflects how GParted works. Now with the same deliberate brokenness the test also reports the label does not match it's expected value: $ ./test_ext2 --gtest_filter='ext2Test.CreateAndReadLabel' Running main() from test_ext2.cc Note: Google Test filter = ext2Test.CreateAndReadLabel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.CreateAndReadLabel test_ext2.cc:322: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" test_ext2.cc:272: Failure Value of: m_partition.get_messages().empty() Actual: false Expected: true Partition messages: e2label: No such file or directory while trying to open /does_not_exist/test_ext2.img Couldn't find valid filesystem superblock. [ FAILED ] ext2Test.CreateAndReadLabel (70 ms) [----------] 1 test from ext2Test (70 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (75 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.CreateAndReadLabel 1 FAILED TEST Closes !49 - Add file system interface tests
2019-08-27 09:49:02 -06:00
reload_partition();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
m_fs_object->read_uuid(m_partition);
Ignore test failure when reiser4 reports null UUID (#145) The GitLab CI ubuntu_test job has occasionally been failing like this, perhaps once every few weeks or so. [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4 test_SupportedFileSystems.cc:569: Failure Expected: (m_partition.uuid.size()) >= (9U), actual: 0 vs 9 [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4, where GetParam() = 24 (17 ms) [----------] 1 test from My/SupportedFileSystemsTest (17 ms total) Turns out there are 2 bugs in resier4progs. One causes debugfs.reiser4 to report a null UUID if the first byte of the UUID happens to be zero [1], and the other cases mkfs.resier4 to write a corrupted UUID, sometimes a null (all zeros) UUID [2]. There is a 1 in 256 chance of getting a null UUID [2] when creating and reading a reiser4 file system, hence the occasional failure of the CI job. The centos_test job isn't affected because CentOS doesn't have the reiser4progs package. Fix this by detecting when reiser4 reports a null UUID and assign a dummy UUID to make the test pass. This does mean that there is a 1 in 256 chance of not detecting a true failure. However that still means there is a 255 in 256 chance of detecting a true failure. That's good odds. When a null UUID is detected for a reiser4 file system the test output looks like this: [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4 test_SupportedFileSystems.cc:580: Ignore test failure of a null UUID. [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4 (46 ms) [1] https://github.com/edward6/reiser4progs/commit/4802cdb18ae03031d0e51a58b6655f3b99021ec2 Fix up repair_master_print() [2] https://github.com/edward6/reiser4progs/commit/44cc024f398f60adef1519426d65f3f081ee826a Stop occasionally making file systems with null UUIDs Closes #145 - Sporadic failure of test case My/SupportedFileSystemsTest.CreateAndReadUUID/reiser4
2021-03-18 15:10:39 -06:00
IGNORE_REISER4_NULL_UUID();
EXPECT_GE(m_partition.uuid.size(), 9U);
// Test messages from read operation are empty or print them.
EXPECT_TRUE(m_partition.get_messages().empty()) << m_partition;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndWriteLabel)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(write_label);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
Create loop devices for NILFS2 read and write FS interface tests (!49) For NILFS2 the read and write tests which use nilfs-tune all fail using an image file, even when run as root, however the other tests succeed. Selected output from the test program: # ./test_SupportedFileSystems --gtest_filter='*/nilfs2' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.Create/nilfs2 (22 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2, where GetParam() = 22 (31 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadLabel/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUUID/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteLabel/nilfs2, where GetParam() = 22 (37 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteUUID/nilfs2, where GetParam() = 22 (39 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/nilfs2 (386 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/nilfs2 (345 ms) [----------] 10 tests from My/SupportedFileSystemsTest (920 ms total) [==========] 10 tests from 1 test case ran. (920 ms total) nilfs-tune fails like this when given an image file: # truncate -s 256M test.img # mkfs.nilfs2 test.img mkfs.nilfs2 (nilfs-utils 2.2.7) Start writing file system initial data to the device Blocksize:4096 Device:test.img Device Size:268435456 File system initialization succeeded !! # nilfs-tune -l test.img nilfs-tune 2.2.7 nilfs-tune: test.img: cannot open NILFS # echo $? 1 However using nilfs-tune via a loop device works: # losetup --show --find /dev/loop0 /dev/loop0 # nilfs-tune -l /dev/loop0 nilfs-tune 2.2.7 Filesystem volume name: (none) Filesystem UUID: fc49912c-4d39-4672-8610-1e1185d0db5f Filesystem magic number: 0x3434 Filesystem revision #: 2.0 Filesystem features: (none) Filesystem state: valid Filesystem OS type: Linux Block size: 4096 ... So nilfs-tune only works with block devices. Fix by making these tests require a loop device and therefore make them root only. Now these tests are skipped as non-root user and pass as root. Closes !49 - Add file system interface tests
2019-10-14 10:12:37 -06:00
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
create_image_file();
m_partition.set_filesystem_label("FIRST");
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
// Test clearing the label is successful.
m_partition.set_filesystem_label("");
ASSERT_TRUE(m_fs_object->write_label(m_partition, m_operation_detail)) << m_operation_detail;
// Test writing the label is successful.
m_partition.set_filesystem_label("SECOND");
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->write_label(m_partition, m_operation_detail)) << m_operation_detail;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndWriteUUID)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(write_uuid);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
Create loop devices for NILFS2 read and write FS interface tests (!49) For NILFS2 the read and write tests which use nilfs-tune all fail using an image file, even when run as root, however the other tests succeed. Selected output from the test program: # ./test_SupportedFileSystems --gtest_filter='*/nilfs2' | fgrep ' ms' [ OK ] My/SupportedFileSystemsTest.Create/nilfs2 (22 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2, where GetParam() = 22 (31 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadLabel/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndReadUUID/nilfs2, where GetParam() = 22 (30 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteLabel/nilfs2, where GetParam() = 22 (37 ms) [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteUUID/nilfs2, where GetParam() = 22 (39 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/nilfs2 (0 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/nilfs2 (386 ms) [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/nilfs2 (345 ms) [----------] 10 tests from My/SupportedFileSystemsTest (920 ms total) [==========] 10 tests from 1 test case ran. (920 ms total) nilfs-tune fails like this when given an image file: # truncate -s 256M test.img # mkfs.nilfs2 test.img mkfs.nilfs2 (nilfs-utils 2.2.7) Start writing file system initial data to the device Blocksize:4096 Device:test.img Device Size:268435456 File system initialization succeeded !! # nilfs-tune -l test.img nilfs-tune 2.2.7 nilfs-tune: test.img: cannot open NILFS # echo $? 1 However using nilfs-tune via a loop device works: # losetup --show --find /dev/loop0 /dev/loop0 # nilfs-tune -l /dev/loop0 nilfs-tune 2.2.7 Filesystem volume name: (none) Filesystem UUID: fc49912c-4d39-4672-8610-1e1185d0db5f Filesystem magic number: 0x3434 Filesystem revision #: 2.0 Filesystem features: (none) Filesystem state: valid Filesystem OS type: Linux Block size: 4096 ... So nilfs-tune only works with block devices. Fix by making these tests require a loop device and therefore make them root only. Now these tests are skipped as non-root user and pass as root. Closes !49 - Add file system interface tests
2019-10-14 10:12:37 -06:00
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
create_image_file();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
// Test writing a new random UUID is successful.
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_detail)) << m_operation_detail;
}
Add CreateAndWriteUUIDAndReadLabel unit test (!104) During review and testing of this patchset it was discovered that using GParted to set a new UUID on a FAT16 or FAT32 file system that there was a new unwanted side effect of clearing the label. Add unit test to cover this error scenario. It does the following: 1. Creates a file system with a known label; 2. Writes a new UUID; 3. Reads the label and confirms it matches the initial label. This new unit test captures the fault like this: $ ./test_SupportedFileSystems --gtest_filter='*CreateAndWriteUUIDAndReadLabel*' ... [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUIDAndReadLabel/fat16 test_SupportedFileSystems.cc:645: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteUUIDAndReadLabel/fat16, where GetParam() = 13 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUIDAndReadLabel/fat32 test_SupportedFileSystems.cc:645: Failure Expected equality of these values: fs_label Which is: "TEST_LABEL" m_partition.get_filesystem_label().c_str() Which is: "" [ FAILED ] My/SupportedFileSystemsTest.CreateAndWriteUUIDAndReadLabel/fat32, where GetParam() = 14 (22 ms) Don't forget to exclude this unit test for file systems which need a loop device but which fails to be created inside the docker CI image. Reference: 39fdfe51da4bddecb2c99a9b544b270130423e72 Exclude unit tests needing losetup in Docker CI image (!59) Closes !104 - Add Alpine Linux CI jobs and resolve label and UUID issues with FAT16/32
2022-07-01 02:09:52 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndWriteUUIDAndReadLabel)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(write_uuid);
SKIP_IF_FS_DOESNT_SUPPORT(read_label);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
const char* fs_label = "TEST_LABEL";
create_image_file();
m_partition.set_filesystem_label(fs_label);
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
// Test writing a new random UUID is successful.
ASSERT_TRUE(m_fs_object->write_uuid(m_partition, m_operation_detail)) << m_operation_detail;
// Test reading the label is successful and it hasn't changed.
reload_partition();
m_fs_object->read_label(m_partition);
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;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndCheck)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(check);
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
create_image_file();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
// Test checking the file system is successful.
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->check_repair(m_partition, m_operation_detail)) << m_operation_detail;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndRemove)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
SKIP_IF_FS_DOESNT_SUPPORT(remove);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_LVM2_PV);
create_image_file();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
// Test removing the file system is successful. Note that most file systems don't
// implement remove so will skip this test.
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->remove(m_partition, m_operation_detail)) << m_operation_detail;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndGrow)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
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_JFS);
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_XFS);
create_image_file(IMAGESIZE_Default);
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
// Test growing the file system is successful.
resize_image(IMAGESIZE_Larger);
reload_partition();
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->resize(m_partition, m_operation_detail, true)) << m_operation_detail;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
TEST_P(SupportedFileSystemsTest, CreateAndShrink)
{
SKIP_IF_FS_DOESNT_SUPPORT(create);
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_LVM2_PV);
SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS(FS_NILFS2);
create_image_file(IMAGESIZE_Larger);
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->create(m_partition, m_operation_detail)) << m_operation_detail;
// Test shrinking the file system is successful.
shrink_partition(IMAGESIZE_Default);
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
ASSERT_TRUE(m_fs_object->resize(m_partition, m_operation_detail, false)) << m_operation_detail;
}
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
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.10.x/googletest/docs/advanced.md#how-to-write-value-parameterized-tests
INSTANTIATE_TEST_SUITE_P(My,
SupportedFileSystemsTest,
::testing::ValuesIn(SupportedFileSystemsTest::get_supported_fstypes()),
param_fsname);
Add testing of linux-swap using Value-Parameterised Google Tests (!49) Use Google Test Value-Parameterised to call every test for both ext2 and linux-swap. https://github.com/google/googletest/blob/v1.8.x/googletest/docs/advanced.md#value-parameterized-tests Running the test now looks like this: $ ./test_SupportedFileSystems Running main() from test_SupportedFileSystems.cc [==========] Running 20 tests from 1 test case. [----------] Global test environment set-up. [----------] 20 tests from My/SupportedFileSystemsTest [ RUN ] My/SupportedFileSystemsTest.Create/0 [ OK ] My/SupportedFileSystemsTest.Create/0 (97 ms) [ RUN ] My/SupportedFileSystemsTest.Create/1 [ OK ] My/SupportedFileSystemsTest.Create/1 (15 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/0 (106 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUsage/1 (14 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/0 (95 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadLabel/1 (23 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/0 (99 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndReadUUID/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/0 (102 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteLabel/1 (22 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/0 (101 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 [ OK ] My/SupportedFileSystemsTest.CreateAndWriteUUID/1 (21 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/0 [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/0 (153 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndCheck/1 test_SupportedFileSystems.cc:424: Skip test. check not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndCheck/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/0 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/0 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndRemove/1 test_SupportedFileSystems.cc:437: Skip test. remove not supported or support not found [ OK ] My/SupportedFileSystemsTest.CreateAndRemove/1 (0 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/0 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/0 (266 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndGrow/1 [ OK ] My/SupportedFileSystemsTest.CreateAndGrow/1 (32 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/0 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/0 (111 ms) [ RUN ] My/SupportedFileSystemsTest.CreateAndShrink/1 [ OK ] My/SupportedFileSystemsTest.CreateAndShrink/1 (28 ms) [----------] 20 tests from My/SupportedFileSystemsTest (1311 ms total) [----------] Global test environment tear-down [==========] 20 tests from 1 test case ran. (1342 ms total) [ PASSED ] 20 tests. Closes !49 - Add file system interface tests
2019-08-02 04:15:48 -06:00
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
} // namespace GParted
// 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__);
Move duplicated test code into shared modules (#220) Move common testing code which doesn't need linking with GParted objects into the common module. Move the remaining common code used to print GParted objects using the insertion operator (operator<<) into the insertion_operators module. Split the common code like this so that the operator<<(std::ostream&, const OperationDetail&) function is not included in test_PipeCapture and it is not forced to link with all the non-UI related GParted objects. The Automake manual provides guidance that when a header belongs to a single program it is recommended to be listed in the program's _SOURCES variable and for a directory only containing header files listing them in the noinst_HEADERS variable is the right variable to use [1]. However the guidance doesn't cover this case for common.h and insertion_operators.h; header files in a directory with other files and used by multiple programs. So just because we have gparted_core_OBJECTS (normal Makefile, not Automake special variable) listing objects to link with, choose to use noinst_HEADERS Automake variable to list needed headers. [1] GNU Automake manual, 9.2 Header files https://www.gnu.org/software/automake/manual/html_node/Headers.html "Usually, only header files that accompany installed libraries need to be installed. Headers used by programs or convenience libraries are not installed. The noinst_HEADERS variable can be used for such headers. However, when the header belongs to a single convenience library or program, we recommend listing it in the program's or library's _SOURCES variable (see Defining program sources) instead of in noinst_HEADERS. This is clearer for the Makefile.am reader. noinst_HEADERS would be the right variable to use in a directory containing only headers and no associated library or program. All header files must be listed somewhere; in a _SOURCES variable or in a _HEADERS variable. Missing ones will not appear in the distribution. " Closes #220 - Format to Cleared not clearing "pdc" ataraid signature
2023-02-05 04:16:43 -07:00
GParted::ensure_x11_display(argc, argv);
Run test program under xvfb-run to satisfy need for an X11 display (!49) Running test_ext2 in GitLab Continuous Integration environment fails like this: (test_ext2:6338): Gtk-WARNING **: 09:06:17.576: cannot open display: Running main() from test_ext2.cc Obviously the GitLab CI environment doesn't have an X11 display, but unfortunately this test case code requires one. Utils::execute_command() calls Gtk::Main::run() so requires a Gtk::Main object constructing and therefore an X11 display, even though this program never displays anything graphical. The call chain is: main() test_ext2.cc Gtk::Main::Main() gtkmm/gtk/src/main.ccg Gtk::Main::init() [1] gtk_init() gtk/gtk/gtkmain.c [2] which exits with a non-zero exit status when the DISPLAY environment variable is unset. Looked at deriving from Gtk::Main class and writing a replacement init() method which calls gtk_init_check() instead of gtk_init() but Gtk::Main::instance_ is a private member so not accessible in a derived class. Tried using Glib::MainLoop instead of Gtk::Main, but that doesn't initialise everything that Gtk::Main(), so the program crashes. Therefore use xvfb-run [3][4] to run this test program against a virtual X11 display when a real display isn't available. Coded execution of xvfb-run into this test program so that it can simply be executed on the command line like the other test programs, without having to remember to run "xvfb-run ./test_ext2 ...". [1] Gtk::Main::init() https://gitlab.gnome.org/GNOME/gtkmm/blob/3.10.1/gtk/src/main.ccg#L287 [2] gtk_init() https://gitlab.gnome.org/GNOME/gtk/blob/3.10.9/gtk/gtkmain.c#L1000 [3] how to run gtk app on linux without an x server https://superuser.com/questions/624918/how-to-run-gtk-app-on-linux-without-an-x-server [4] Using GTK without DISPLAY https://stackoverflow.com/questions/11694278/using-gtk-without-display Closes !49 - Add file system interface tests
2019-09-24 02:17:30 -06:00
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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().
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
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);
Add initial create ext2 only FileSystem interface class test (!49) This is the first step of adding testing of the derived FileSystem interface classes which call the file system specific executables. Rather than mocking command execution and returned output the tests run the real commands, effectively making this integration testing. 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. For example, temporarily breaking the test code to create a 10 KiB image file instead of 256 MiB one produces this: $ ./test_ext2 Running main() from test_ext2.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from ext2Test [ RUN ] ext2Test.Create test_ext2.cc:199: Failure Value of: s_ext2_obj->create(m_partition, m_operation_detail) Actual: false Expected: true Operation details: <b><i>mkfs.ext2 -F -L &apos;&apos; &apos;/home/centos/programming/c/gparted/tests/test_ext2.img&apos;</i></b> 00:00:00 (ERROR) <i></i> <i>mke2fs 1.42.9 (28-Dec-2013) /home/centos/programming/c/gparted/tests/test_ext2.img: Not enough space to build proposed filesystem while setting up superblock </i> [ FAILED ] ext2Test.Create (25 ms) [----------] 1 test from ext2Test (25 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (30 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] ext2Test.Create 1 FAILED TEST $ echo $? 1 Also as Utils:: and FileSystem::execute_command() are needed, this requires linking with GParted_Core for GParted_Core::mainthread and therefore with most of the non-UI classes in gpartedbin. Closes !49 - Add file system interface tests
2019-07-17 06:08:08 -06:00
return RUN_ALL_TESTS();
}