[LTP] [PATCH v2 2/3] fanotify14: Use named initializers
Amir Goldstein
amir73il@gmail.com
Sun Jul 16 07:35:29 CEST 2023
In preparation for adding a new optional test case struct member.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
.../kernel/syscalls/fanotify/fanotify14.c | 160 +++++++++++++-----
1 file changed, 114 insertions(+), 46 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
index 08cd94858..2c6f6afea 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify14.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -62,92 +62,160 @@ static struct test_case_t {
int expected_errno;
} test_cases[] = {
/* FAN_REPORT_FID without class FAN_CLASS_NOTIF is not valid */
- {FLAGS_DESC(FAN_CLASS_CONTENT | FAN_REPORT_FID), {}, {}, EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_CONTENT | FAN_REPORT_FID),
+ .expected_errno = EINVAL,
+ },
/* FAN_REPORT_FID without class FAN_CLASS_NOTIF is not valid */
- {FLAGS_DESC(FAN_CLASS_PRE_CONTENT | FAN_REPORT_FID), {}, {}, EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_PRE_CONTENT | FAN_REPORT_FID),
+ .expected_errno = EINVAL,
+ },
/* INODE_EVENTS in mask without class FAN_REPORT_FID are not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF), FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(INODE_EVENTS),
- EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF),
+ .mark = FLAGS_DESC(FAN_MARK_INODE),
+ .mask = FLAGS_DESC(INODE_EVENTS),
+ .expected_errno = EINVAL,
+ },
/* INODE_EVENTS in mask with FAN_MARK_MOUNT are not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_FID),
- FLAGS_DESC(FAN_MARK_MOUNT), FLAGS_DESC(INODE_EVENTS), EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_FID),
+ .mark = FLAGS_DESC(FAN_MARK_MOUNT),
+ .mask = FLAGS_DESC(INODE_EVENTS),
+ .expected_errno = EINVAL,
+ },
/* FAN_REPORT_NAME without FAN_REPORT_DIR_FID is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_NAME), {}, {}, EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_NAME),
+ .expected_errno = EINVAL,
+ },
/* FAN_REPORT_NAME without FAN_REPORT_DIR_FID is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_FID | FAN_REPORT_NAME), {},
- {}, EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_FID | FAN_REPORT_NAME),
+ .expected_errno = EINVAL,
+ },
/* FAN_REPORT_TARGET_FID without FAN_REPORT_FID is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_NAME),
- {}, {}, EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_NAME),
+ .expected_errno = EINVAL,
+ },
/* FAN_REPORT_TARGET_FID without FAN_REPORT_NAME is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_FID),
- {}, {}, EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_FID),
+ .expected_errno = EINVAL,
+ },
/* FAN_RENAME without FAN_REPORT_NAME is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_FID), FLAGS_DESC(FAN_MARK_INODE),
- FLAGS_DESC(FAN_RENAME), EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_FID),
+ .mark = FLAGS_DESC(FAN_MARK_INODE),
+ .mask = FLAGS_DESC(FAN_RENAME),
+ .expected_errno = EINVAL,
+ },
/* With FAN_MARK_ONLYDIR on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF), FLAGS_DESC(FAN_MARK_ONLYDIR),
- FLAGS_DESC(FAN_OPEN), ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF),
+ .mark = FLAGS_DESC(FAN_MARK_ONLYDIR),
+ .mask = FLAGS_DESC(FAN_OPEN),
+ .expected_errno = ENOTDIR,
+ },
/* With FAN_REPORT_TARGET_FID, FAN_DELETE on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
- FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_DELETE), ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
+ .mark = FLAGS_DESC(FAN_MARK_INODE),
+ .mask = FLAGS_DESC(FAN_DELETE),
+ .expected_errno = ENOTDIR,
+ },
/* With FAN_REPORT_TARGET_FID, FAN_RENAME on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
- FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_RENAME), ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
+ .mark = FLAGS_DESC(FAN_MARK_INODE),
+ .mask = FLAGS_DESC(FAN_RENAME),
+ .expected_errno = ENOTDIR,
+ },
/* With FAN_REPORT_TARGET_FID, FAN_ONDIR on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
- FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_OPEN | FAN_ONDIR), ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
+ .mark = FLAGS_DESC(FAN_MARK_INODE),
+ .mask = FLAGS_DESC(FAN_OPEN | FAN_ONDIR),
+ .expected_errno = ENOTDIR,
+ },
/* With FAN_REPORT_TARGET_FID, FAN_EVENT_ON_CHILD on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
- FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD),
- ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
+ .mark = FLAGS_DESC(FAN_MARK_INODE),
+ .mask = FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD),
+ .expected_errno = ENOTDIR,
+ },
/* FAN_MARK_IGNORE_SURV with FAN_DELETE on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
- FLAGS_DESC(FAN_MARK_IGNORE_SURV), FLAGS_DESC(FAN_DELETE),
- ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
+ .mark = FLAGS_DESC(FAN_MARK_IGNORE_SURV),
+ .mask = FLAGS_DESC(FAN_DELETE),
+ .expected_errno = ENOTDIR,
+ },
/* FAN_MARK_IGNORE_SURV with FAN_RENAME on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
- FLAGS_DESC(FAN_MARK_IGNORE_SURV), FLAGS_DESC(FAN_RENAME),
- ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
+ .mark = FLAGS_DESC(FAN_MARK_IGNORE_SURV),
+ .mask = FLAGS_DESC(FAN_RENAME),
+ .expected_errno = ENOTDIR,
+ },
/* FAN_MARK_IGNORE_SURV with FAN_ONDIR on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
- FLAGS_DESC(FAN_MARK_IGNORE_SURV),
- FLAGS_DESC(FAN_OPEN | FAN_ONDIR), ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
+ .mark = FLAGS_DESC(FAN_MARK_IGNORE_SURV),
+ .mask = FLAGS_DESC(FAN_OPEN | FAN_ONDIR),
+ .expected_errno = ENOTDIR,
+ },
/* FAN_MARK_IGNORE_SURV with FAN_EVENT_ON_CHILD on non-dir is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
- FLAGS_DESC(FAN_MARK_IGNORE_SURV),
- FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD), ENOTDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
+ .mark = FLAGS_DESC(FAN_MARK_IGNORE_SURV),
+ .mask = FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD),
+ .expected_errno = ENOTDIR,
+ },
/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on directory is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF), FLAGS_DESC(FAN_MARK_IGNORE),
- FLAGS_DESC(FAN_OPEN), EISDIR},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF),
+ .mark = FLAGS_DESC(FAN_MARK_IGNORE),
+ .mask = FLAGS_DESC(FAN_OPEN),
+ .expected_errno = EISDIR,
+ },
/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on mount mark is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF),
- FLAGS_DESC(FAN_MARK_MOUNT | FAN_MARK_IGNORE),
- FLAGS_DESC(FAN_OPEN), EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF),
+ .mark = FLAGS_DESC(FAN_MARK_MOUNT | FAN_MARK_IGNORE),
+ .mask = FLAGS_DESC(FAN_OPEN),
+ .expected_errno = EINVAL,
+ },
/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on filesystem mark is not valid */
- {FLAGS_DESC(FAN_CLASS_NOTIF),
- FLAGS_DESC(FAN_MARK_FILESYSTEM | FAN_MARK_IGNORE),
- FLAGS_DESC(FAN_OPEN), EINVAL},
+ {
+ .init = FLAGS_DESC(FAN_CLASS_NOTIF),
+ .mark = FLAGS_DESC(FAN_MARK_FILESYSTEM | FAN_MARK_IGNORE),
+ .mask = FLAGS_DESC(FAN_OPEN),
+ .expected_errno = EINVAL,
+ },
};
static void do_test(unsigned int number)
--
2.34.1
More information about the ltp
mailing list