From: Luis Henriques <luis@igalia.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Chen Linxuan <me@black-desk.cn>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Matt Harvey <mharvey@jumptrading.com>,
kernel-dev@igalia.com
Subject: Re: [RFC PATCH v2 5/8] selftests/fuse: factor-out test fixture setup/teardown
Date: Tue, 18 Aug 2026 16:51:58 +0100 [thread overview]
Message-ID: <87lda3e89t.fsf@wotan.olymp> (raw)
In-Reply-To: <CAOQ4uxgUECPPchwipkH6qg=q1L_Fqg9=_cPOC6wm9TJ27EQqEw@mail.gmail.com> (Amir Goldstein's message of "Tue, 18 Aug 2026 15:09:58 +0200")
On Tue, Aug 18 2026, Amir Goldstein wrote:
> On Mon, Aug 17, 2026 at 4:11 PM Luis Henriques <luis@igalia.com> wrote:
>>
>> In order to reduce new tests setup/teardown code duplication, factor-out
>> these functions from the existing acl_cache test.
>
> When I read this I thought you were going to share these helpers with the
> new symlink and readdir cache tests, but you did not.
>
> Maybe a fuse_common.c would make sense to reduce boiler plate
> in new fuse tests.
>
> These helpers and fixture look pretty similar in all three tests.
True. I'll try to reduce the duplication by moving the common place.
Cheers,
--
Luís
> Thanks,
> Amir.
>
>
>>
>> Signed-off-by: Luis Henriques <luis@igalia.com>
>> ---
>> .../filesystems/fuse/fuse_acl_cache_test.c | 82 ++++++++++++-------
>> 1 file changed, 53 insertions(+), 29 deletions(-)
>>
>> diff --git a/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c b/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
>> index 2411a6e285f1..8bdc90572be2 100644
>> --- a/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
>> +++ b/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
>> @@ -50,6 +50,8 @@
>>
>> #include "kselftest_harness.h"
>>
>> +#define MAX_ERR_MSG 256
>> +
>> /* ---- ACL binary encoding ------------------------------------------------ */
>> /*
>> * POSIX ACL v2 xattr format (little-endian):
>> @@ -193,52 +195,74 @@ FIXTURE(acl_cache) {
>> pthread_t thread;
>> };
>>
>> -FIXTURE_SETUP(acl_cache)
>> +int fs_setup(struct fuse_session **se, char *mountpoint, char *file_path,
>> + pthread_t *thread, char *err)
>> {
>> char *fuse_argv[] = { "fuse_acl_cache_test", NULL };
>> struct fuse_args args = FUSE_ARGS_INIT(1, fuse_argv);
>>
>> - g_ds.acl = acl_a;
>> - g_ds.acl_size = sizeof(acl_a);
>> - g_ds.getxattr_count = 0;
>> -
>> - strcpy(self->mountpoint, "/tmp/acl_cache_test_XXXXXX");
>> - if (!mkdtemp(self->mountpoint))
>> - SKIP(return, "mkdtemp: %s", strerror(errno));
>> + strcpy(mountpoint, "/tmp/acl_cache_test_XXXXXX");
>> + if (!mkdtemp(mountpoint)) {
>> + snprintf(err, MAX_ERR_MSG, "mkdtemp: %s", strerror(errno));
>> + return -1;
>> + }
>>
>> - snprintf(self->file_path, sizeof(self->file_path),
>> - "%s/" FILE_NAME, self->mountpoint);
>> + snprintf(file_path, PATH_MAX, "%s/" FILE_NAME, mountpoint);
>>
>> - self->se = fuse_session_new(&args, &fs_ops, sizeof(fs_ops), NULL);
>> - if (!self->se) {
>> - rmdir(self->mountpoint);
>> - SKIP(return, "fuse_session_new failed");
>> + *se = fuse_session_new(&args, &fs_ops, sizeof(fs_ops), NULL);
>> + if (!*se) {
>> + rmdir(mountpoint);
>> + snprintf(err, MAX_ERR_MSG, "fuse_session_new failed");
>> + return -1;
>> }
>>
>> - if (fuse_session_mount(self->se, self->mountpoint)) {
>> - fuse_session_destroy(self->se);
>> - rmdir(self->mountpoint);
>> - SKIP(return, "fuse_session_mount failed "
>> - "(missing fusermount3 or insufficient privileges)");
>> + if (fuse_session_mount(*se, mountpoint)) {
>> + fuse_session_destroy(*se);
>> + rmdir(mountpoint);
>> + snprintf(err, MAX_ERR_MSG, "fuse_session_mount failed "
>> + "(missing fusermount3 or insufficient privileges)");
>> + return -1;
>> }
>>
>> - if (pthread_create(&self->thread, NULL, run_daemon, self->se)) {
>> - fuse_session_unmount(self->se);
>> - fuse_session_destroy(self->se);
>> - rmdir(self->mountpoint);
>> - SKIP(return, "pthread_create: %s", strerror(errno));
>> + if (pthread_create(thread, NULL, run_daemon, *se)) {
>> + fuse_session_unmount(*se);
>> + fuse_session_destroy(*se);
>> + rmdir(mountpoint);
>> + snprintf(err, MAX_ERR_MSG, "pthread_create: %s", strerror(errno));
>> + return -1;
>> }
>>
>> fuse_opt_free_args(&args);
>> +
>> + return 0;
>> +}
>> +
>> +static void fs_teardown(struct fuse_session *se, pthread_t thread,
>> + char *mountpoint)
>> +{
>> + fuse_session_exit(se);
>> + fuse_session_unmount(se);
>> + pthread_join(thread, NULL);
>> + fuse_session_destroy(se);
>> + rmdir(mountpoint);
>> +}
>> +
>> +FIXTURE_SETUP(acl_cache)
>> +{
>> + char err[MAX_ERR_MSG];
>> +
>> + g_ds.acl = acl_a;
>> + g_ds.acl_size = sizeof(acl_a);
>> + g_ds.getxattr_count = 0;
>> +
>> + if (fs_setup(&self->se, self->mountpoint, self->file_path,
>> + &self->thread, err))
>> + SKIP(return, err);
>> }
>>
>> FIXTURE_TEARDOWN(acl_cache)
>> {
>> - fuse_session_exit(self->se);
>> - fuse_session_unmount(self->se);
>> - pthread_join(self->thread, NULL);
>> - fuse_session_destroy(self->se);
>> - rmdir(self->mountpoint);
>> + fs_teardown(self->se, self->thread, self->mountpoint);
>> }
>>
>> static int do_force_statx(const char *path)
next prev parent reply other threads:[~2026-08-18 15:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 14:11 [RFC PATCH v2 0/8] fuse: caches documentation and testing Luis Henriques
2026-08-17 14:11 ` [RFC PATCH v2 1/8] Documentation: fuse: add document on caches being used by FUSE Luis Henriques
2026-08-18 12:40 ` Amir Goldstein
2026-08-18 15:51 ` Luis Henriques
2026-08-18 19:57 ` Amir Goldstein
2026-08-17 14:11 ` [RFC PATCH v2 2/8] selftests/fuse: convert fusectl test to fuse3 Luis Henriques
2026-08-17 14:11 ` [RFC PATCH v2 3/8] selftests/fuse: check that fusectlfs is mounted Luis Henriques
2026-08-17 14:11 ` [RFC PATCH v2 4/8] selftests/fuse: add fuse symlink caching test Luis Henriques
2026-08-17 14:11 ` [RFC PATCH v2 5/8] selftests/fuse: factor-out test fixture setup/teardown Luis Henriques
2026-08-18 13:09 ` Amir Goldstein
2026-08-18 15:51 ` Luis Henriques [this message]
2026-08-17 14:11 ` [RFC PATCH v2 6/8] selftests/fuse: use dynamically allocated memory to store ACLs Luis Henriques
2026-08-17 14:11 ` [RFC PATCH v2 7/8] selftests/fuse: add some extra ACL caching tests Luis Henriques
2026-08-17 14:11 ` [RFC PATCH v2 8/8] selftests/fuse: add fuse readdir caching test Luis Henriques
2026-08-18 13:13 ` [RFC PATCH v2 0/8] fuse: caches documentation and testing Amir Goldstein
2026-08-18 15:52 ` Luis Henriques
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lda3e89t.fsf@wotan.olymp \
--to=luis@igalia.com \
--cc=amir73il@gmail.com \
--cc=corbet@lwn.net \
--cc=fuse-devel@lists.linux.dev \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=me@black-desk.cn \
--cc=mharvey@jumptrading.com \
--cc=miklos@szeredi.hu \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.