[LTP] [PATCH v3 2/2] fanotify14: Improve check for unsupported init flags
Martin Doucha
mdoucha@suse.cz
Fri Oct 20 17:06:03 CEST 2023
Test case 8 of fanotify14 uses init flags supported only on kernel 5.9+
but does not properly check for their support. Rewrite fanotify feature
checks using new helper function.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
Changes since v1:
- Added FAN_CLASS_* constants to support check in setup()
- Added longer patch description
Changes since v2: None
I'd rather not squash this patch so that it can be reverted without
potentially breaking other tests.
testcases/kernel/syscalls/fanotify/fanotify14.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
index 4596511f0..0bb789188 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify14.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -45,8 +45,8 @@
static int pipes[2] = {-1, -1};
static int fanotify_fd;
-static int fan_report_target_fid_unsupported;
static int ignore_mark_unsupported;
+static unsigned int supported_init_flags;
struct test_case_flags_t {
unsigned long long flags;
@@ -246,9 +246,8 @@ static void do_test(unsigned int number)
tst_res(TINFO, "Test case %d: fanotify_init(%s, O_RDONLY)", number,
tc->init.desc);
- if (fan_report_target_fid_unsupported && tc->init.flags & FAN_REPORT_TARGET_FID) {
- FANOTIFY_INIT_FLAGS_ERR_MSG(FAN_REPORT_TARGET_FID,
- fan_report_target_fid_unsupported);
+ if (tc->init.flags & ~supported_init_flags) {
+ tst_res(TCONF, "Unsupported init flags");
return;
}
@@ -317,11 +316,15 @@ out:
static void do_setup(void)
{
+ unsigned int all_init_flags = FAN_REPORT_DFID_NAME_TARGET |
+ FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT;
+
/* Require FAN_REPORT_FID support for all tests to simplify per test case requirements */
REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(FAN_REPORT_FID, MNTPOINT);
- fan_report_target_fid_unsupported =
- fanotify_init_flags_supported_on_fs(FAN_REPORT_DFID_NAME_TARGET, MNTPOINT);
+ supported_init_flags = fanotify_get_supported_init_flags(all_init_flags,
+ MNTPOINT);
+
ignore_mark_unsupported = fanotify_mark_supported_by_kernel(FAN_MARK_IGNORE_SURV);
/* Create temporary test file to place marks on */
--
2.42.0
More information about the ltp
mailing list