Commit Graph

189 Commits

Author SHA1 Message Date
CismonX
09e6583b54 Use off_t instead of loff_t
Since we're already enforcing 64-bit off_t, using loff_t
makes no difference.

Also loff_t is Linux-only, which breaks compatibility for *BSD.
2024-06-25 07:16:49 +02:00
Ashley Pittman
e3bd7de517 Install all test/build python packages from requirements.txt
Have GitHub actions setup python on runners and install
all python dependencies via pip.

Signed-off-by: Ashley Pittman <ashley@pittman.co.uk>
2024-03-27 17:26:14 +01:00
Bernd Schubert
e547a66566
ci-build.sh: Fix checking for function arguments (#909)
Checking for an emtpy string actually doesn't work for $@,
so just check for number of arguments.

Co-authored-by: Bernd Schubert <bschubert@ddn.com>
2024-03-20 16:43:54 +01:00
Bernd Schubert
0d90a90b06 /test_ctests / test_notify1: Print cmdline on failure
Tests sometimes fail with

pytest.fail('file system process terminated prematurely')

And it is not clear what actually happens.
2024-03-20 12:37:17 +01:00
Bernd Schubert
99ef7a93ea ci-build.sh: Add back test without versioned symbols
Commit b1cdc497 ("ci-build.sh: Run ASAN and UBSAN at the same time")
also accidentally removed the test for versioned symbols.

Also export clang/clang++ to make sure new shells get it.
2024-03-20 12:37:15 +01:00
Bernd Schubert
255de0b78a Build clang/sanitized build first
This was stalling - easier to check what happens
when it fails fast. And in general, sanitized
builds are faster than valgrind and detect almost
as much errors as valgrind (same level would be
achieved with MSAN, but that is hard to use),
so failures can be detected faster whan sanitizers
run first.
2024-03-20 12:32:39 +01:00
Bernd Schubert
f041818c63 Add back s-bit for compiled fusermount
This is also needed by some tests and was accidentally removed
in commit aab146eea8
2024-03-20 12:32:39 +01:00
Bernd Schubert
71a97226e8 Fix test failures: Create missing mount dir
Tests were failing because mount dir was missing.
Unclear to me why this became only recently an issue
(github internal - out of the sudden tests were hanging).
2024-03-20 12:32:30 +01:00
Bernd Schubert
38d40c5bc1 ci-build.sh: Reduce pytest --maxfail from 99 to 1
We want to see errors - reduce allowed errors.
With --maxfail=99 tests out of the sudden started to hang
in github, without a change in libfuse (I had actually tested
to previous release tags). With --maxfail=1 pytest aborts
and we see failing github.

Also increase python log level to NOTSET - NOTSET should print
all messages.

Also use "pytest" has wrapper for "python3 -m"
2024-03-20 09:09:29 +01:00
Bernd Schubert
a6a219f534
Merge pull request #901 from bsbernd/posix_spawn
Switch from fork to posix_spawn
2024-03-07 12:03:41 +01:00
Bernd Schubert
aab146eea8 ci-build.sh: Always install and add s-bit for fusermount3
As per pull #898, fusermount3 had a severe issue that
should have been detected by ASAN. I guess tests used
the system default and not the sanitized binary.
Order of execution of fusermount3 is to try
1) full install path
if that fails
2) just fusermount3

So tests should be fixed by installing libfuse, setting the s-bit
on fusermount3 and then to run the tests.
2024-03-07 11:56:30 +01:00
Bernd Schubert
b1cdc497b8 ci-build.sh: Run ASAN and UBSAN at the same time
Also set halt_on_error=1 to make UBSAN to fail if it
would find something.
2024-03-07 11:56:30 +01:00
Bernd Schubert
a6ac2ec12d Fix undefined loff_t in test_write_cache.c on alpine
This fixes #899. Seems that Alpine (and maybe Fedora) need
_GNU_SOURCE to get loff_t.
2024-03-06 13:12:50 +01:00
Bernd Schubert
31bf17c744
Fix tests/test_write_cache in write back mode (#892)
This test could fail whenever a something (kernel, userspace) decides
to flush in between of two 2048B writes. These two writes are supposed
to be merged into a single 4906 byte write by the kernel writeback cache,
but _sometimes_ the test fails because 2048 byte writes get through.
Fixes #882

Solution here is a modification how the test works - instead
of requiring an exact aggregation of 2x2048B into 4096B,
it now writes 64x2048B and requires in write-back modes
the number of received writes requests is lower than 64 - we
can expect that at least some writes get aggregated, but we do
know how many.

Co-authored-by: Bernd Schubert <bschubert@ddn.com>
2024-02-26 19:09:00 +01:00
HereThereBeDragons
67d28fb4b7 make FUSE_CAP_EXPIRE_ONLY test depend on available cap and not on version 2024-01-29 08:43:58 +00:00
amitgeron
bd8985945b
Allow *xattr operations on root directory (ino 1) 2023-12-17 17:45:47 +00:00
Nikolaus Rath
1cb6e17e0c Reduce default write size by half
Hopefully this will reduce test flakiness on CI.
2023-07-01 14:12:44 +01:00
Nikolaus Rath
b51f69f620 Add missing include. 2023-07-01 14:10:47 +01:00
HereThereBeDragons
51bc827df8
Make expire only function fail if no kernel support (#789) 2023-06-30 13:57:06 +01:00
Peri
bb1890afd7
Fix issue #746. (#782)
Added a secondary check in fuse_lib_unlink() after hide_node()
to check again under a lock if the (now hidden) file is still open.
If not then delete it.

This should synchronise fuse_lib_unlink() with fuse_lib_release(),
when nullpath_ok is set.
2023-05-11 02:38:46 +01:00
Matthias Görgens
34d9d2abf1
Disable leak suppression (#773) 2023-04-12 08:40:18 +01:00
Matthias Görgens
7297044ada
Fuse mount: make auto_unmount compatible with suid/dev mount options (#762)
* Fuse mount: make auto_unmount compatible with suid/dev mount options

> When you run as root, fuse normally does not call fusermount but uses
> the mount system call directly. When you specify auto_unmount, it goes
> through fusermount instead. However, fusermount is a setuid binary that
> is normally called by regular users, so it cannot in general accept suid
> or dev options.

In this patch, we split up how fuse mounts as root when `auto_unmount`
is specified.

First, we mount using system calls directly, then we reach out to
fusermount to set up auto_unmount only (with no actual mounting done in
fusermount).

Fixes: #148
2023-04-12 08:39:32 +01:00
Matthias Goergens
eb88309882 Migrate away from deprecated distutils
Before:

```
=============================== warnings summary ===============================
test/test_ctests.py:12
  /tmp/libfuse-build-mB50ZC/build-gcc-9/test/test_ctests.py:12: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
    from distutils.version import LooseVersion

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
```
2023-04-11 13:32:00 +01:00
Matthias Goergens
c261271aa9 Fix typo 2023-04-11 11:58:33 +01:00
Matthias Goergens
6ce27f48bc Fix PytestReturnNotNoneWarning
```
test_examples.py::test_printcap
  /usr/local/lib/python3.9/dist-packages/_pytest/python.py:199: PytestReturnNotNoneWarning: Expected None, but test_examples.py::test_printcap returned ((7, 38), {'FUSE_CAP_READDIRPLUS_AUTO', 'FUSE_CAP_ASYNC_DIO', 'FUSE_CAP_SPLICE_READ', 'FUSE_CAP_CACHE_SYMLINKS', 'FUSE_CAP_IOCTL_DIR', 'FUSE_CAP_NO_OPENDIR_SUPPORT', 'FUSE_CAP_NO_OPEN_SUPPORT', 'FUSE_CAP_POSIX_LOCKS', 'FUSE_CAP_READDIRPLUS', 'FUSE_CAP_POSIX_ACL', 'FUSE_CAP_ATOMIC_O_TRUNC', 'FUSE_CAP_SPLICE_MOVE', 'FUSE_CAP_EXPORT_SUPPORT', 'FUSE_CAP_FLOCK_LOCKS', 'FUSE_CAP_EXPLICIT_INVAL_DATA', 'FUSE_CAP_EXPIRE_ONLY', 'FUSE_CAP_DONT_MASK', 'FUSE_CAP_WRITEBACK_CACHE', 'FUSE_CAP_AUTO_INVAL_DATA', 'FUSE_CAP_PARALLEL_DIROPS', 'FUSE_CAP_SPLICE_WRITE', 'FUSE_CAP_ASYNC_READ'}), which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(
```
2023-04-07 15:31:58 +01:00
Matthias Goergens
b9b4307e4d Fix deprecated @pytest.mark.hookwrapper
```
PytestDeprecationWarning: The hookimpl pytest_pyfunc_call uses old-style configuration options (marks or attributes).
  Please use the pytest.hookimpl(hookwrapper=True) decorator instead
   to configure the hooks.
   See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
    @pytest.mark.hookwrapper
```
2023-04-07 15:31:58 +01:00
Matthias Goergens
7555d032a2 Fix meson deprecation warning
Also for rest of CI
2023-04-07 14:01:16 +01:00
Matthias Goergens
b37f6dfe70 Upgrade meson version in CI 2023-04-07 13:32:35 +01:00
Nikolaus Rath
d65686ac2c Add unit tests for setxattr() et al
Hopefully, this will catch issues as in commit 024eccbf3
2023-04-01 16:49:01 +01:00
Nikolaus Rath
17e8b3e273 Migrate from Travis to Github actions
With current Ubuntu, Valgrind apparently does not like clang debug info, so do not run
valgrind with clang-compiled binaries.
2023-02-20 20:28:12 +00:00
Bernd Schubert
db35a37def Install a the configure_file (config.h) and use in headers
This addresses: https://github.com/libfuse/libfuse/issues/724

HAVE_LIBC_VERSIONED_SYMBOLS configures the library if to use
versioned symbols and is set at meson configuration time.
External filesystems (the main target, actually)
include fuse headers and the preprocessor
then acts on HAVE_LIBC_VERSIONED_SYMBOLS. Problem was now that
'config.h' was not distributed with libfuse and so
HAVE_LIBC_VERSIONED_SYMBOLS was never defined with external
tools and the preprocessor did the wrong decision.

This commit also increases the the minimal meson version,
as this depends on meson feature only available in 0.50

<quote 'meson' >
WARNING: Project specifies a minimum meson_
version '>= 0.42' but uses features which were added
 in newer versions:
 * 0.50.0: {'install arg in configure_file'}
</quote>

Additionally the config file has been renamed to "fuse_config.h"
to avoid clashes - 'config.h' is not very specific.
2023-01-28 09:35:34 +00:00
Bernd Schubert
e42b972271 Update travis to ubuntu jammy (22.04)
A newer ubuntu version is required to get a more recent meson
(at least 0.50 now)
2023-01-28 09:35:34 +00:00
Bernd Schubert
856c683c36 passthrough_hp: Add options for clone_fd, max_threads, daemonize
This is useful for benchmarking.

Note: This changes behavior - passthrough_hp runs in background by default
      now.
2023-01-13 10:21:42 +00:00
Tofik Sonono
50c74e6459
Support application-defined I/O functions for FUSE fd
The io for FUSE requests and responses can now be further customized by allowing to write custom functions for reading/writing the responses. This includes overriding the splice io.

The reason for this addition is that having a custom file descriptor is not sufficient to allow custom io. Different types of file descriptor require different mechanisms of io interaction. For example, some file descriptor communication has boundaries (SOCK_DGRAM, EOF, etc...), while other types of fd:s might be unbounded (SOCK_STREAMS, ...). For unbounded communication, you have to read the header of the FUSE request first, and then read the remaining packet data. Furthermore, the one read call does not necessarily return all the data expected, requiring further
calls in a loop.
2023-01-10 10:04:35 +00:00
HereThereBeDragons
c0a344e379 Test for fuse_lowlevel_notify_expire_entry.
This test is too simple to check for all functionalities of notify_expire as it always successfully passes when libfuse supports the function (even if kernel does not support it -  it just takes it as notify_inval)
2023-01-06 18:35:52 +00:00
Bernd Schubert
d372d3f80b Fixes when HAVE_LIBC_VERSIONED_SYMBOLS is not defined
fuse_loop_mt and fuse_new had not been defined when
HAVE_LIBC_VERSIONED_SYMBOLS had not been set and additionally,
fuse_new_31 was missing in the version script and was therefore
an unusable symbol.

This also adds a test for unset HAVE_LIBC_VERSIONED_SYMBOLS.
2023-01-04 15:27:21 +00:00
Bernd Schubert
8d934122df Fix a test strncpy compilation warning with recent gcc
meson configure -D buildtype=debugoptimized
meson configure -D b_sanitize=address,undefined

Results in '-fsanitize=address,undefined ... -O2 -g' that made
compilation to give errors with recent gcc versions.


bernd@t1700bs build-ubuntu>ninja -v
[1/2] ccache gcc -Itest/test_syscalls.p -Itest -I../test -Iinclude -I../include -Ilib -I../lib -I. -I.. -fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -O2 -g -D_REENTRANT -DHAVE_CONFIG_H -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -fno-strict-aliasing -Wno-unused-result -DHAVE_SYMVER_ATTRIBUTE -MD -MQ test/test_syscalls.p/test_syscalls.c.o -MF test/test_syscalls.p/test_syscalls.c.o.d -o test/test_syscalls.p/test_syscalls.c.o -c ../test/test_syscalls.c
FAILED: test/test_syscalls.p/test_syscalls.c.o
ccache gcc -Itest/test_syscalls.p -Itest -I../test -Iinclude -I../include -Ilib -I../lib -I. -I.. -fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -O2 -g -D_REENTRANT -DHAVE_CONFIG_H -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -fno-strict-aliasing -Wno-unused-result -DHAVE_SYMVER_ATTRIBUTE -MD -MQ test/test_syscalls.p/test_syscalls.c.o -MF test/test_syscalls.p/test_syscalls.c.o.d -o test/test_syscalls.p/test_syscalls.c.o -c ../test/test_syscalls.c
In file included from /usr/include/string.h:519,
                 from ../test/test_syscalls.c:7:
In function ‘strncpy’,
    inlined from ‘test_socket’ at ../test/test_syscalls.c:1885:2,
    inlined from ‘main’ at ../test/test_syscalls.c:2030:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: error: ‘__builtin_strncpy’ output may be truncated copying 107 bytes from a string of length 1023 [-Werror=stringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |                                   __glibc_objsize (__dest));
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~



I disagree a bit on the gcc sanity here, as the code was behaving
correctly and even already checked the string length. But sice
the string length is already verified, that length can be used
for the final strncpy.
2022-05-06 21:21:06 +01:00
Amir Goldstein
435a14e029 Add test for FOPEN_NOFLUSH flag
Simulate write() delay and verify that close(rofd) does not
block waiting on pending writes.

The support for the flag was added in kernel v5.16-rc1.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2022-01-05 08:43:43 +02:00
Luis Henriques
cee6de8d66
test/test_syscalls.c: allow EBADF in fcheck_stat() (#631)
Test test/test_examples.py::test_passthrough_hp[False] fails because, on
kernels >= 5.14, fstat() will return -EBADF:

3 [check_unlinked_testfile] fcheck_stat() - fstat: Bad file descriptor
4 [check_unlinked_testfile] fcheck_stat() - fstat: Bad file descriptor
5 [check_unlinked_testfile] fcheck_stat() - fstat: Bad file descriptor
9 [check_unlinked_testfile] fcheck_stat() - fstat: Bad file descriptor
...

This patch simply whitelists the EBADF errno code.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Co-authored-by: Luís Henriques <lhenriques@suse.de>
2021-11-20 10:09:25 +00:00
Nikolaus Rath
624327ba00 Travis-CI: Make sure lsan supppressions file can be read by root. 2021-06-24 09:11:29 +01:00
Amir Goldstein
570933394e Do not run unlinked files test on passthrough_hp with old kernels
test_syscalls unlinked testfiles check fails on passthourhg_hp without
the kernel commit "fuse: fix illegal access to inode with reused nodeid"
queued for kernel 5.14 [1].

Make this check opt-in and do not run it with kernel version before 5.14.

[1] https://lore.kernel.org/linux-fsdevel/CAJfpegtGKjeK8E5QsHKF0=re1J9wVHuGRVgg9NDJ_OOwQdCUNg@mail.gmail.com/

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-23 11:46:19 +01:00
Amir Goldstein
10ecd4fda4 test/test_syscalls.c: check unlinked testfiles at the end of the test
On some tests on regular files, open an O_PATH fd of the testfile and
record it along side the size and mode and inode.

At the end of all tests, use recorded testfiles info to re-check the size
mode and inode of the unlinked testfiles.

With O_PATH fd, the server does not have to keep the inode alive so FUSE
inode may be stale or bad.  Therefore, ESTALE and EIO are valid results
for fstat() on the old testfile fd's, but returning the wrong size or
mode is an invalid result.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-14 09:13:12 +01:00
Amir Goldstein
494e15127c test/test_syscalls.c: refactor fcheck_* helpers
Avoid multiple fstat() calls and consolidate all fcheck_* helpers
into fcheck_stat().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-14 09:13:12 +01:00
Amir Goldstein
057d6de867 test/test_syscalls.c: use unique filename per test
Generate unique filename per test (only for regular file for now).
Make sure to unlink the unique filename after each test.

realpath variable was renamed to basepath_r to fix build warning
on conflicting symbols with realpath() function.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-14 09:13:12 +01:00
Christian Menges
57b46adc35
Cuse example: Fix memory leak (#607)
* cuse example: fix memory leak

* Travis CI: re-enable leak checking
2021-06-09 09:04:41 +01:00
Amir Goldstein
8852a22399
test/test_syscalls.c: fix test failure on xfs src dir (#611)
rename dir loop test fails when test tmp dir is xfs with an error
 test_rename_dir_loop() - rename : File exists

That is because xfs returns EEXIST for the case of renaming over
a non-empty directory.

According to rename(2) man page, EEXIST and ENOTEMPTY are both valid
error code in this case.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-02 10:23:06 +01:00
Jean-Pierre André
bdd2d4110f
Fix returning d_ino and d_type by readdir(3) in non-plus mode
When not using the readdir_plus mode, the d_type was not returned,
and the use_ino flag was not used for returning d_ino.

This patch fixes the returned values for d_ino and d_type by readdir(3)

The test for the returned value of d_ino has been adjusted to also
take the d_type into consideration and to check the returned values in
both basic readdir and readdir_plus modes. This is done by executing
the passthrough test twice.

Co-authored-by: Jean-Pierre André <jpandre@users.sourceforge.net>
2021-03-18 09:52:30 +00:00
Martin Pärtel
5012a05ac8
Fix returning inode numbers from readdir() in offset==0 mode. (#584)
- Test added for all passthrough examples.
- passthrough.c uses offset==0 mode. The others don't.
- passthrough.c changed to set FUSE_FILL_DIR_PLUS to make the test pass.
- This fixes #583.
2021-02-03 09:53:21 +00:00
Zhiqiang Liu
71f0d7c366 test/test_syscalls.c: fix potential fd leakage problems
In test_syscalls.c, several funcs have potential fd leakage
problems. This patch will fix them.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Haotian Li <lihaotian9@huawei.com>
2020-11-06 19:26:03 +00:00
Tom Callaway
d7d08595e2
Update Travis to Ubuntu Bionic 2020-09-12 09:28:27 +01:00