summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHereThereBeDragons <HereThereBeDragons@users.noreply.github.com>2023-01-06 14:05:00 +0100
committerNikolaus Rath <Nikolaus@rath.org>2023-01-06 18:35:52 +0000
commitc0a344e3797844896d04efc4b565a2627067b67f (patch)
treede8931c4436d00216000362ee164e6bbee957366
parent91083df90eadc0e69e4ce6956f823a2acb602f25 (diff)
downloadfuse-c0a344e3797844896d04efc4b565a2627067b67f.tar.gz
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)
-rw-r--r--example/notify_inval_entry.c23
-rwxr-xr-xtest/test_examples.py5
2 files changed, 22 insertions, 6 deletions
diff --git a/example/notify_inval_entry.c b/example/notify_inval_entry.c
index 9f50992..8af31bc 100644
--- a/example/notify_inval_entry.c
+++ b/example/notify_inval_entry.c
@@ -11,8 +11,8 @@
* This example implements a file system with a single file whose
* file name changes dynamically to reflect the current time.
*
- * It illustrates the use of the fuse_lowlevel_notify_inval_entry()
- * function.
+ * It illustrates the use of the fuse_lowlevel_notify_inval_entry() and
+ * fuse_lowlevel_notify_expire_entry() functions.
*
* To see the effect, first start the file system with the
* ``--no-notify``
@@ -64,6 +64,9 @@
* $ sleep 1; stat mnt/$file
* stat: cannot stat ‘mnt/Time_is_20h_42m_11s’: No such file or directory
*
+ * To use the function fuse_lowlevel_notify_expire_entry() instead of
+ * fuse_lowlevel_notify_inval_entry(), use the command line option --only-expire
+ *
* ## Compilation ##
*
* gcc -Wall notify_inval_entry.c `pkg-config fuse3 --cflags --libs` -o notify_inval_entry
@@ -96,11 +99,13 @@ struct options {
int no_notify;
float timeout;
int update_interval;
+ int only_expire;
};
static struct options options = {
.timeout = 5,
.no_notify = 0,
.update_interval = 1,
+ .only_expire = 0,
};
#define OPTION(t, p) \
@@ -109,6 +114,7 @@ static const struct fuse_opt option_spec[] = {
OPTION("--no-notify", no_notify),
OPTION("--update-interval=%d", update_interval),
OPTION("--timeout=%f", timeout),
+ OPTION("--only-expire", only_expire),
FUSE_OPT_END
};
@@ -250,9 +256,15 @@ static void* update_fs_loop(void *data) {
while(1) {
old_name = strdup(file_name);
update_fs();
- if (!options.no_notify && lookup_cnt)
- assert(fuse_lowlevel_notify_inval_entry
- (se, FUSE_ROOT_ID, old_name, strlen(old_name)) == 0);
+ if (!options.no_notify && lookup_cnt) {
+ if(options.only_expire) {
+ assert(fuse_lowlevel_notify_expire_entry
+ (se, FUSE_ROOT_ID, old_name, strlen(old_name), FUSE_LL_EXPIRE_ONLY) == 0);
+ } else {
+ assert(fuse_lowlevel_notify_inval_entry
+ (se, FUSE_ROOT_ID, old_name, strlen(old_name)) == 0);
+ }
+ }
free(old_name);
sleep(options.update_interval);
}
@@ -266,6 +278,7 @@ static void show_help(const char *progname)
" --timeout=<secs> Timeout for kernel caches\n"
" --update-interval=<secs> Update-rate of file system contents\n"
" --no-notify Disable kernel notifications\n"
+ " --only-expire Expire entries instead of invalidating them\n"
"\n");
}
diff --git a/test/test_examples.py b/test/test_examples.py
index 97eebfc..cfce57c 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -331,8 +331,9 @@ def test_null(tmpdir, output_checker):
@pytest.mark.skipif(fuse_proto < (7,12),
reason='not supported by running kernel')
+@pytest.mark.parametrize("only_expire", ("invalidate_entries", "expire_entries"))
@pytest.mark.parametrize("notify", (True, False))
-def test_notify_inval_entry(tmpdir, notify, output_checker):
+def test_notify_inval_entry(tmpdir, only_expire, notify, output_checker):
mnt_dir = str(tmpdir)
cmdline = base_cmdline + \
[ pjoin(basename, 'example', 'notify_inval_entry'),
@@ -340,6 +341,8 @@ def test_notify_inval_entry(tmpdir, notify, output_checker):
'--timeout=5', mnt_dir ]
if not notify:
cmdline.append('--no-notify')
+ if only_expire == "expire_entries":
+ cmdline.append('--only-expire')
mount_process = subprocess.Popen(cmdline, stdout=output_checker.fd,
stderr=output_checker.fd)
try: