Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 3 additions & 81 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,91 +7,16 @@ on:
pull_request:

jobs:
Static-Code-Checks:
runs-on: ubuntu-slim

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install Dependencies
run: |
python3 -m pip install ioctl-opt paramiko types-paramiko pytest

- name: Style Check With Ruff
run: |
python3 -m pip install ruff
ruff check --config tests/.ruff.toml -- $( git ls-tree -r --name-only HEAD | 'grep' -E '[.]py$' )

- name: Style Check With Black
run: |
python3 -m pip install black
black -q --diff --line-length 120 --skip-string-normalization $( git ls-tree -r --name-only HEAD | 'grep' -E '[.]py$' ) > black.diff
if [ -s black.diff ]; then
cat black.diff
exit 123
fi

- name: Lint With Codespell
run: |
python3 -m pip install codespell
codespell $( git ls-tree -r --name-only HEAD | 'grep' -E '[.](py|md|txt|sh|yml)$' )

- name: Lint With Flake8
run: |
python3 -m pip install flake8
flake8 --config tests/.flake8 $( git ls-tree -r --name-only HEAD | 'grep' -E '[.]py$' )

- name: Lint With Pylint
run: |
python3 -m pip install pylint
pylint --rcfile tests/.pylintrc $( git ls-tree -r --name-only HEAD | 'grep' -E '[.]py$' ) | tee pylint.log
! 'egrep' ': E[0-9]{4}: ' pylint.log

- name: Lint With Pytype
run: |
python3 -m pip install pytype
pytype -d import-error $( git ls-tree -r --name-only HEAD | 'grep' -E '[.]py$' )

- name: Lint With Mypy
run: |
yes | python3 -m pip install --upgrade-strategy eager --upgrade types-dataclasses mypy
mypy --config-file tests/.mypy.ini $( git ls-tree -r --name-only HEAD | 'grep' -E '[.]py$' )

Tests:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
# https://endoflife.date/python
include:
- os: ubuntu-22.04
python-version: '3.9'
- os: ubuntu-22.04-arm
python-version: '3.10'
- os: ubuntu-22.04
python-version: '3.11'
- os: ubuntu-24.04-arm
python-version: '3.12'
- os: ubuntu-24.04
python-version: '3.13'
- os: ubuntu-24.04
python-version: '3.14'
- os: macos-15
python-version: '3.9'
- os: macos-14
python-version: '3.10'
- os: macos-15-intel
python-version: '3.11'
- os: macos-14
python-version: '3.12'
- os: macos-15-intel
python-version: '3.13'
- os: macos-15
python-version: '3.14'

env:
Expand Down Expand Up @@ -293,7 +218,7 @@ jobs:

# Packages
sudo -E pkgin -y update
sudo -E pkgin -y install git fuse perfuse python311 py311-pip
sudo -E pkgin -y install git pkgconf python311 py311-pip
sudo -E ln -sf /usr/pkg/bin/python3.11 /usr/pkg/bin/python3

# Fix PATH
Expand All @@ -304,9 +229,6 @@ jobs:
sudo sysctl -w kern.sbmax=4194304
sudo chmod 666 /dev/puffs

# avoid permissions issue for perfused trace file:
sudo chmod 777 /var/run

# Install pip Dependencies
python3 -m pip install pytest pytest-order ioctl-opt

Expand All @@ -317,7 +239,7 @@ jobs:
rc=0
python3 -m pytest -s -v -rs tests/test_struct_layout.py
# for now, run the tests as root, too many PermissionErrors:
sudo -E python3 -m pytest -s -v -rs tests || rc=$?
sudo -E python3 -m pytest -s -v -rs -k "not struct_layout" tests || rc=$?
exit "$rc"
;;
esac
10 changes: 7 additions & 3 deletions mfusepy.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class c_utimbuf(ctypes.Structure):
_libfuse_path = (
find_library('fuse4x') or find_library('osxfuse') or find_library('fuse') or find_library('fuse-t')
)
elif _system == 'NetBSD':
# On NetBSD 10+ librefuse implements FUSE 3, targetting 3.10 compatibility.
_libfuse_path = find_library('refuse')
elif _system == 'Windows':
# pytype: disable=module-attr
try:
Expand Down Expand Up @@ -155,7 +158,7 @@ def get_fuse_version(libfuse):
f"Found library {_libfuse_path} is too old: {fuse_version_major}.{fuse_version_minor}. "
"There have been several ABI breaks in each version. Libfuse < 2.6 is not supported!"
)
if fuse_version_major != 2 and not (fuse_version_major == 3 and _system == 'Linux'):
if fuse_version_major != 2 and not (fuse_version_major == 3 and _system in ('Linux', 'NetBSD')):
raise AttributeError(
f"Found library {_libfuse_path} has wrong major version: {fuse_version_major}. Expected FUSE 2!"
)
Expand Down Expand Up @@ -1379,7 +1382,8 @@ class as is to Operations, instead of just the fh field.
}

argsb = [arg.encode(encoding, self.errors) for arg in args]
argv = (ctypes.c_char_p * len(argsb))(*argsb)
argc = len(argsb)
argv = (ctypes.c_char_p * (argc + 1))(*argsb, None) # Null terminate explicitly

alternative_callbacks = {
"readdir": ["readdir_with_offset"],
Expand Down Expand Up @@ -1443,7 +1447,7 @@ class as is to Operations, instead of just the fh field.
except ValueError:
old_handler = SIG_DFL

err = fuse_main_real(len(argsb), argv, ctypes.pointer(fuse_ops), ctypes.sizeof(fuse_ops), None)
err = fuse_main_real(argc, argv, ctypes.pointer(fuse_ops), ctypes.sizeof(fuse_ops), None)

try:
signal(SIGINT, old_handler)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ def unmount(self):
time.sleep(0.1)


@pytest.mark.parametrize('cli', [cli_loopback, cli_memory, cli_memory_nullpath])
#@pytest.mark.parametrize('cli', [cli_loopback, cli_memory, cli_memory_nullpath])
@pytest.mark.parametrize('cli', [cli_loopback])
def test_read_write_file_system(cli, tmp_path):
if cli == cli_loopback:
mount_source = tmp_path / "folder"
Expand Down
12 changes: 6 additions & 6 deletions tests/test_struct_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
}
"""

print(C_CHECKER)
# print(C_CHECKER)


def get_compiler():
Expand Down Expand Up @@ -219,10 +219,10 @@ def c_run(name: str, source: str) -> str:
print(f"Compiler stderr:\n{e.stderr}")
assert e.returncode == 0, "Could not compile C program to verify sizes."

for line in Path(preprocessed_file).read_text().split('\n'):
if not line.startswith('#') and line:
print(line)
print(preprocessed_file)
#for line in Path(preprocessed_file).read_text().split('\n'):
# if not line.startswith('#') and line:
# print(line)
#print(preprocessed_file)

output = subprocess.check_output([exe_file], text=True)
return output
Expand All @@ -232,7 +232,7 @@ def c_run(name: str, source: str) -> str:
def test_struct_layout():
output = c_run("verify_structs", C_CHECKER)
c_infos = {line.split(':', 1)[0]: int(line.split(':', 1)[1]) for line in output.strip().split('\n')}
pprint.pprint(c_infos)
#pprint.pprint(c_infos)

fail = False
for struct_name, member_names in STRUCT_NAMES.items():
Expand Down
Loading