public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Matthew Bobrowski <repnop@google.com>,
	Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>, LTP List <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v3 1/3] syscalls/fanotify: Add a helper macro which checks for the presence of specific fanotify initialization flag(s)
Date: Mon, 15 Nov 2021 22:20:18 +0100	[thread overview]
Message-ID: <YZLPEjJkII1evtEc@pevik> (raw)
In-Reply-To: <CAOQ4uxiFsnvA-8y1mJ7uHccd4bqZUYJkK5Y2R1+KtgDK_OH4Sw@mail.gmail.com>

Hi Matthew, Amir,

Tested on two distro kernels with support (Tumbleweed and Debian unstable)
+ on various old kernels without support.

Merged with very minor fixes, see diff below.

NOTE: we now support basic static analysis + checkpatch formatting check - run
make check in fanotify directory or make check-fanotify20.

Thanks a lot!

Kind regards,
Petr

diff --git runtest/syscalls runtest/syscalls
index 1e6d46744..d57c73e39 100644
--- runtest/syscalls
+++ runtest/syscalls
@@ -605,6 +605,8 @@ fanotify16 fanotify16
 fanotify17 fanotify17
 fanotify18 fanotify18
 fanotify19 fanotify19
+fanotify20 fanotify20
+fanotify21 fanotify21
 
 ioperm01 ioperm01
 ioperm02 ioperm02
diff --git testcases/kernel/syscalls/fanotify/fanotify20.c testcases/kernel/syscalls/fanotify/fanotify20.c
index 9960d85eb..de0fdb782 100644
--- testcases/kernel/syscalls/fanotify/fanotify20.c
+++ testcases/kernel/syscalls/fanotify/fanotify20.c
@@ -12,6 +12,9 @@
  * returns an expected error code when provided an invalid initialization flag
  * alongside FAN_REPORT_PIDFD. Additionally, it checks that the operability with
  * existing FAN_REPORT_* flags is maintained and functioning as intended.
+ *
+ * NOTE: FAN_REPORT_PIDFD support was added in v5.15-rc1 in af579beb666a
+ * ("fanotify: add pidfd support to the fanotify API").
  */
 
 #define _GNU_SOURCE
@@ -39,7 +42,7 @@ static struct test_case_t {
 	},
 	{
 		"pass on FAN_REPORT_PIDFD | FAN_REPORT_FID | FAN_REPORT_DFID_NAME",
-		FAN_REPORT_PIDFD | FAN_REPORT_FID | FAN_REPORT_DFID_NAME ,
+		FAN_REPORT_PIDFD | FAN_REPORT_FID | FAN_REPORT_DFID_NAME,
 		0,
 		0,
 	},
diff --git testcases/kernel/syscalls/fanotify/fanotify21.c testcases/kernel/syscalls/fanotify/fanotify21.c
index e842dad17..6ae70c57e 100644
--- testcases/kernel/syscalls/fanotify/fanotify21.c
+++ testcases/kernel/syscalls/fanotify/fanotify21.c
@@ -11,6 +11,9 @@
  * A test which verifies whether the returned struct
  * fanotify_event_info_pidfd in FAN_REPORT_PIDFD mode contains the
  * expected set of information.
+ *
+ * NOTE: FAN_REPORT_PIDFD support was added in v5.15-rc1 in af579beb666a
+ * ("fanotify: add pidfd support to the fanotify API").
  */
 
 #define _GNU_SOURCE
@@ -56,7 +59,7 @@ struct test_case_t {
 
 static int fanotify_fd;
 static char event_buf[BUF_SZ];
-static struct pidfd_fdinfo_t *self_pidfd_fdinfo = NULL;
+static struct pidfd_fdinfo_t *self_pidfd_fdinfo;
 
 static struct pidfd_fdinfo_t *read_pidfd_fdinfo(int pidfd)
 {
@@ -158,7 +161,7 @@ static void do_test(unsigned int num)
 	 * buffer.
 	 */
 	len = SAFE_READ(0, fanotify_fd, event_buf, sizeof(event_buf));
-	while(i < len) {
+	while (i < len) {
 		struct fanotify_event_metadata *event;
 		struct fanotify_event_info_pidfd *info;
 		struct pidfd_fdinfo_t *event_pidfd_fdinfo = NULL;
@@ -197,7 +200,7 @@ static void do_test(unsigned int num)
 			tst_res(TFAIL,
 				"pidfd creation failed for pid: %u with pidfd error value "
 				"set to: %d",
-				(unsigned)event->pid,
+				(unsigned int)event->pid,
 				info->pidfd);
 			goto next_event;
 		} else if (tc->want_pidfd_err &&
@@ -205,14 +208,14 @@ static void do_test(unsigned int num)
 			tst_res(TFAIL,
 				"pidfd set to an unexpected error: %d for pid: %u",
 				info->pidfd,
-				(unsigned)event->pid);
+				(unsigned int)event->pid);
 			goto next_event;
 		} else if (tc->want_pidfd_err &&
 			   info->pidfd == tc->want_pidfd_err) {
 			tst_res(TPASS,
 				"pid: %u terminated before pidfd was created, "
 				"pidfd set to the value of: %d, as expected",
-				(unsigned)event->pid,
+				(unsigned int)event->pid,
 				FAN_NOPIDFD);
 			goto next_event;
 		}
@@ -227,15 +230,15 @@ static void do_test(unsigned int num)
 				"reading fdinfo for pidfd: %d "
 				"describing pid: %u failed",
 				info->pidfd,
-				(unsigned)event->pid);
+				(unsigned int)event->pid);
 			goto next_event;
 		} else if (event_pidfd_fdinfo->pid != event->pid) {
 			tst_res(TFAIL,
 				"pidfd provided for incorrect pid "
 				"(expected pidfd for pid: %u, got pidfd for "
 				"pid: %u)",
-				(unsigned)event->pid,
-				(unsigned)event_pidfd_fdinfo->pid);
+				(unsigned int)event->pid,
+				(unsigned int)event_pidfd_fdinfo->pid);
 			goto next_event;
 		} else if (memcmp(event_pidfd_fdinfo, self_pidfd_fdinfo,
 				  sizeof(struct pidfd_fdinfo_t))) {
@@ -261,7 +264,7 @@ static void do_test(unsigned int num)
 				"mask: %lld, pid: %u, fd: %d, "
 				"pidfd: %d, info_type: %d, info_len: %d",
 				(unsigned long long)event->mask,
-				(unsigned)event->pid,
+				(unsigned int)event->pid,
 				event->fd,
 				info->pidfd,
 				info->hdr.info_type,

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-11-15 21:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 10:04 [LTP] [PATCH v3 0/3] Add test support for the new fanotify FAN_REPORT_PIDFD feature Matthew Bobrowski via ltp
2021-11-09 10:04 ` [LTP] [PATCH v3 1/3] syscalls/fanotify: Add a helper macro which checks for the presence of specific fanotify initialization flag(s) Matthew Bobrowski via ltp
2021-11-09 11:05   ` Amir Goldstein
2021-11-15 21:20     ` Petr Vorel [this message]
2021-11-16  1:06       ` Matthew Bobrowski via ltp
2021-11-16  9:39         ` Petr Vorel
2021-11-09 10:05 ` [LTP] [PATCH v3 2/3] syscalls/fanotify20: add new test for FAN_REPORT_PIDFD Matthew Bobrowski via ltp
2021-11-09 10:05 ` [LTP] [PATCH v3 3/3] syscalls/fanotify21: test returned pidfd from fanotify in FAN_REPORT_PIDFD mode Matthew Bobrowski via ltp

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=YZLPEjJkII1evtEc@pevik \
    --to=pvorel@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=repnop@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox