selftests/landlock: Support running the full fs test suite on another FS
Subsystems (3)
RFC PATCH 1/1 selftests/landlock: Support running the full fs test suite on another FS
Adds a TMP_BIND_TO environment variable which the test binary will check, and if present, instead of mounting a tmpfs on ./tmp, it will bind mount that path to ./tmp instead.
Currently there is the layout3_fs tests which runs a few tests (but not the full set of Landlock tests) in separate filesystems, notably no file creation/write/rename etc. This is necessary for certain special fs such as proc or sysfs, as the tests can only read a specific path. However, for a more typical fs like v9fs, this is limitting.
This test makes it possible to run the full set on any filesystem (even though this is still not automated). Note that there are some expected failures, such as v9fs not supporting RENAME_EXCHANGE, as well as the known issue of ephemeral inodes, which may be fixed by a later revision of [1].
Suggestions for alternatives welcome. Maybe we need to also detect the fs, and disable known-unsupported tests like RENAME_EXCHANGE?
--- tools/testing/selftests/landlock/fs_test.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
tools/testing/selftests/landlock/fs_test.c +19 -1
@@ -285,6 +285,22 @@ static const struct mnt_opt mnt_tmp = { .data = MNT_TMP_DATA, }; +static struct mnt_opt get_tmp_mnt_opt (void ) +{ +const char *const tmp_bind_to =getenv ("TMP_BIND_TO" ); + +if (tmp_bind_to) { +struct mnt_opt mnt = { + .flags =MS_BIND , + .source = tmp_bind_to + }; + +return mnt; + } + +return mnt_tmp; +} +static int mount_opt (const struct mnt_opt *const mnt,const char *const target) { return mount(mnt->source ?: mnt->type, target, mnt->type, mnt->flags,
@@ -322,7 +338,9 @@ static void prepare_layout_opt(struct __test_metadata *const _metadata,static void prepare_layout (struct __test_metadata *const _metadata) { -prepare_layout_opt (_metadata, &mnt_tmp); +struct mnt_opt mnt =get_tmp_mnt_opt (); + +prepare_layout_opt (_metadata, &mnt); }static void cleanup_layout (struct __test_metadata *const _metadata)
base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
Signature · 1 line
2.51.0
Mickaël Salaün
maintainerQuoted 10 lines · Tingmao Wang
Adds a
TMP_BIND_TOenvironment variable which the test binary will check, and if present, instead of mounting a tmpfs on ./tmp, it will bind mount that path to ./tmp instead.Currently there is the
layout3_fstests which runs a few tests (but not the full set of Landlock tests) in separate filesystems, notably no file creation/write/rename etc. This is necessary for certain special fs such as proc or sysfs, as the tests can only read a specific path. However, for a more typical fs like v9fs, this is limitting.
Quoted 8 lines
This test makes it possible to run the full set on any filesystem (even though this is still not automated). Note that there are some expected failures, such as v9fs not supporting
RENAME_EXCHANGE, as well as the known issue of ephemeral inodes, which may be fixed by a later revision of [1].Suggestions for alternatives welcome. Maybe we need to also detect the fs, and disable known-unsupported tests like
RENAME_EXCHANGE?
Extending layout3_fs tests with new ones that make sense (i.e. those you listed) would make be more consistent whithout scaling issue. We can extend the fixture variants to skip some tests.
This patch should help:
https://lore.kernel.org/all/[email protected]/
Feel free to take it with your 9pfs patch series and add a new patch with extended checks.
Quoted 51 lines
Signed-off-by Tingmao Wang <[email protected]>--- tools/testing/selftests/landlock/fs_test.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)tools/testing/selftests/landlock/fs_test.c +19
-1@@ -285,6 +285,22 @@ static const struct mnt_opt mnt_tmp = { .data = MNT_TMP_DATA, }; +static struct mnt_opt get_tmp_mnt_opt (void ) +{ +const char *const tmp_bind_to =getenv ("TMP_BIND_TO" ); + +if (tmp_bind_to) { +struct mnt_opt mnt = { + .flags =MS_BIND , + .source = tmp_bind_to + }; + +return mnt; + } + +return mnt_tmp; +} +static int mount_opt (const struct mnt_opt *const mnt,const char *const target) { return mount(mnt->source ?: mnt->type, target, mnt->type, mnt->flags,@@ -322,7 +338,9 @@ static void prepare_layout_opt(struct __test_metadata *const _metadata,static void prepare_layout (struct __test_metadata *const _metadata) { -prepare_layout_opt (_metadata, &mnt_tmp); +struct mnt_opt mnt =get_tmp_mnt_opt (); + +prepare_layout_opt (_metadata, &mnt); }static void cleanup_layout (struct __test_metadata *const _metadata)base-commit:
1b237f190eb3d36f52dffe07a40b5eb210280e00Signature · 1 line
2.51.0