diff options
Diffstat (limited to 'test/test_examples.py')
-rwxr-xr-x | test/test_examples.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/test/test_examples.py b/test/test_examples.py index 3b1fd1b..e0fb8c4 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -18,13 +18,15 @@ import time import errno import sys import platform -from looseversion import LooseVersion +import re +from packaging import version from tempfile import NamedTemporaryFile from contextlib import contextmanager from util import (wait_for_mount, umount, cleanup, base_cmdline, safe_sleep, basename, fuse_test_marker, test_printcap, - fuse_proto, fuse_caps, powerset) + fuse_proto, fuse_caps, powerset, parse_kernel_version) from os.path import join as pjoin +import logging pytestmark = fuse_test_marker() @@ -88,31 +90,46 @@ def readdir_inode(dir): @pytest.mark.parametrize("options", powerset(options)) @pytest.mark.parametrize("name", ('hello', 'hello_ll')) def test_hello(tmpdir, name, options, cmdline_builder, output_checker): + logger = logging.getLogger(__name__) mnt_dir = str(tmpdir) + logger.debug(f"Mount directory: {mnt_dir}") + cmdline = cmdline_builder(mnt_dir, name, options) + logger.debug(f"Command line: {' '.join(cmdline)}") mount_process = subprocess.Popen( - cmdline_builder(mnt_dir, name, options), + cmdline, stdout=output_checker.fd, stderr=output_checker.fd) + logger.debug(f"Mount process PID: {mount_process.pid}") try: + logger.debug("Waiting for mount...") wait_for_mount(mount_process, mnt_dir) + logger.debug("Mount completed") assert os.listdir(mnt_dir) == [ 'hello' ] + logger.debug("Verified 'hello' file exists in mount directory") filename = pjoin(mnt_dir, 'hello') with open(filename, 'r') as fh: assert fh.read() == 'Hello World!\n' + logger.debug("Verified contents of 'hello' file") with pytest.raises(IOError) as exc_info: open(filename, 'r+') assert exc_info.value.errno == errno.EACCES + logger.debug("Verified EACCES error when trying to open file for writing") with pytest.raises(IOError) as exc_info: open(filename + 'does-not-exist', 'r+') assert exc_info.value.errno == errno.ENOENT + logger.debug("Verified ENOENT error for non-existent file") if name == 'hello_ll': + logger.debug("Testing xattr for hello_ll") tst_xattr(mnt_dir) path = os.path.join(mnt_dir, 'hello') tst_xattr(path) except: + logger.error("Exception occurred during test", exc_info=True) cleanup(mount_process, mnt_dir) raise else: + logger.debug("Unmounting...") umount(mount_process, mnt_dir) + logger.debug("Test completed successfully") @pytest.mark.parametrize("writeback", (False, True)) @pytest.mark.parametrize("name", ('passthrough', 'passthrough_plus', @@ -251,7 +268,7 @@ def test_passthrough_hp(short_tmpdir, cache, output_checker): # unlinked testfiles check fails without kernel fix # "fuse: fix illegal access to inode with reused nodeid" # so opt-in for this test from kernel 5.14 - if LooseVersion(platform.release()) >= '5.14': + if parse_kernel_version(platform.release()) >= version.parse('5.14'): syscall_test_cmd.append('-u') subprocess.check_call(syscall_test_cmd) except: |