|  |  |  |  | 
libblockdev's test suite is written using the standard unittest.TestCase framework in Python. Tests are separated in modules, usually one per libblockdev plugin - e.g. BTRFS, LVM, Crypto. There are one or more base classes in each module used to setup the environment and perform some testing. More specific test scenarios inherit from these base classes.
Before running the tests you have to prepare your system so that libblockdev can be built from source.
Install all build requirements. On Fedora this can be done with
cat dist/libblockdev.spec.in | grep BuildRequires: | cut -f2 -d: | cut -f2 -d' ' | xargs dnf -y install
      Configure the build scripts
./autogen.sh
./configure
To execute the Pylint code analysis tool run:
make checkThe check target is a dependency of all test targets and you don't have to execute it explicitly when testing.
To execute the test suite from inside the source directory run one of these commands:
make testexecutes all safe tests or
make fast-testexecutes all fast tests or
make test-allexecutes all tests, including ones which may result in kernel panic or take more time to complete or
make test-plugin-NAMEexecutes only tests for given plugin and similarly
make fast-test-plugin-NAMEexecutes only fast tests for given plugin.
It is also possible to run only subset of available tests or only one test using the `run_tests.py` script:
# python3 tests/run_tests.py fs_test.GenericResizeexecutes all tests from the GenericResize test class from filesystem plugin test cases and
# python3 tests/run_tests.py fs_test.GenericResize.test_ext2_generic_resizeexecutes only test_ext2_generic_resize from this class. This script also allows skipping slow tests or running potentially dangerous tests. Use:
$ python3 tests/run_tests.py --helpto see all available options.
It is also possible to generate test coverage reports using the Python coverage tool:
make coverageis equivalent to `make test'.
make coverage-allis equivalent to `make test-all'.