public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 2/3] fanotify: rewrite old cases with new lib
Date: Fri, 18 Aug 2017 12:24:46 +0200	[thread overview]
Message-ID: <20170818102446.GB22319@rei.lan> (raw)
In-Reply-To: <1502867737-26158-3-git-send-email-xzhou@redhat.com>

Hi!
Pushed with minor fixes (mostly warnings), thanks.

diff --git a/testcases/kernel/syscalls/fanotify/fanotify01.c b/testcases/kernel/syscalls/fanotify/fanotify01.c
index 205a999fe..24fc214f5 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify01.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
@@ -256,7 +256,7 @@ void test01(void)
 			if (event->fd == -2)
 				goto pass;
 			ret = read(event->fd, buf, BUF_SIZE);
-			if (ret != strlen(fname)) {
+			if (ret != (int)strlen(fname)) {
 				tst_res(TFAIL,
 					 "cannot read from returned fd "
 					 "of event: mask=%llx pid=%u "
diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c
index ce3566167..90478bc5b 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify03.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify03.c
@@ -38,6 +38,7 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/syscall.h>
+#include <stdlib.h>
 #include "tst_test.h"
 #include "fanotify.h"
 
@@ -86,6 +87,7 @@ static void generate_events(void)
 
 static void child_handler(int tmp)
 {
+	(void)tmp;
 	/*
 	 * Close notification fd so that we cannot block while reading
 	 * from it
@@ -107,14 +109,12 @@ static void run_child(void)
 			 "sigaction(SIGCHLD, &child_action, NULL) failed");
 	}
 
-	switch (child_pid = fork()) {
-	case 0:
+	child_pid = SAFE_FORK();
+	if (child_pid == 0) {
 		/* Child will generate events now */
 		close(fd_notify);
 		generate_events();
 		exit(0);
-	case -1:
-		tst_brk(TBROK | TERRNO, "fork() failed");
 	}
 }
 
diff --git a/testcases/kernel/syscalls/fanotify/fanotify04.c b/testcases/kernel/syscalls/fanotify/fanotify04.c
index 302f1246b..68f65da0c 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify04.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify04.c
@@ -105,7 +105,7 @@ static void check_mark(char *file, unsigned long long flag, char *flagstr,
 
 #define CHECK_MARK(file, flag, expect, func) check_mark(file, flag, #flag, expect, func)
 
-static void do_open(char *file, int flag, char *flagstr)
+static void do_open(char *file, int flag)
 {
 	int fd;
 
@@ -113,16 +113,14 @@ static void do_open(char *file, int flag, char *flagstr)
 	SAFE_CLOSE(fd);
 }
 
-#define DO_OPEN(file, flag) do_open(file, flag, #flag)
-
 static void open_file(char *file)
 {
-	DO_OPEN(file, 0);
+	do_open(file, 0);
 }
 
 static void open_dir(char *file)
 {
-	DO_OPEN(file, O_DIRECTORY);
+	do_open(file, O_DIRECTORY);
 }
 
 static void verify_event(int mask)
@@ -143,7 +141,7 @@ static void verify_event(int mask)
 	} else if (fstat(event->fd, &st) < 0) {
 		tst_res(TFAIL, "failed to stat event->fd (%s)",
 			 strerror(errno));
-	} else if ((st.st_mode & S_IFMT) != mask) {
+	} else if ((int)(st.st_mode & S_IFMT) != mask) {
 		tst_res(TFAIL, "event->fd points to object of different type "
 			 "(%o != %o)", st.st_mode & S_IFMT, mask);
 	} else {
@@ -152,18 +150,16 @@ static void verify_event(int mask)
 	close(event->fd);
 }
 
-static void do_open_test(char *file, int flag, char *flagstr, int mask)
+static void do_open_test(char *file, int flag, int mask)
 {
-	do_open(file, flag, flagstr);
+	do_open(file, flag);
 
 	verify_event(mask);
 }
 
-#define DO_OPEN_TEST(file, flag, mask) do_open_test(file, flag, #flag, mask)
-
 static void test_open_file(char *file)
 {
-	DO_OPEN_TEST(file, 0, S_IFREG);
+	do_open_test(file, 0, S_IFREG);
 }
 
 static void verify_no_event(void)
@@ -190,7 +186,7 @@ static void verify_no_event(void)
 static void test_open_symlink(char *file)
 {
 	/* Since mark is on a symlink, no event should be generated by opening a file */
-	DO_OPEN(file, 0);
+	do_open(file, 0);
 	verify_no_event();
 }
 
diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
index 7b9d6325d..e63e457a1 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify06.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
@@ -237,8 +237,7 @@ static void cleanup(void)
 {
 	cleanup_fanotify_groups();
 
-	if (chdir(tst_get_tmpdir()) < 0)
-		tst_brk(TBROK, "chdir(tmpdir) failed");
+	SAFE_CHDIR("../");
 
 	if (mount_created && tst_umount(MOUNT_NAME) < 0)
 		tst_brk(TBROK | TERRNO, "umount failed");

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2017-08-18 10:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02  9:24 [LTP] [PATCH] syscalls/fanotify08: add sanity check for FAN_CLOEXEC Xiong Zhou
2017-06-05 14:03 ` Cyril Hrubis
2017-08-11  3:13   ` [LTP] [PATCH v2] " Xiong Zhou
2017-08-11  8:41     ` Cyril Hrubis
2017-08-14 14:01       ` [LTP] [PATCH v3 0/3] add SAFE_FANOTIFY_INIT and FAN_CLOEXEC cases Xiong Zhou
2017-08-14 14:01         ` [LTP] [PATCH v3 1/3] lib: add helper SAFE_FANOTIFY_INIT Xiong Zhou
2017-08-15 13:23           ` Cyril Hrubis
2017-08-14 14:01         ` [LTP] [PATCH v3 2/3] fanotify: rewrite old cases with new lib Xiong Zhou
2017-08-15 13:33           ` Cyril Hrubis
2017-08-14 14:01         ` [LTP] [PATCH v3 3/3] syscalls/fanotify0[89]: add sanity check for FAN_CLOEXEC Xiong Zhou
2017-08-15 13:36           ` Cyril Hrubis
2017-08-16  7:15             ` [LTP] [PATCH v4 0/3] add SAFE_FANOTIFY_INIT and FAN_CLOEXEC check Xiong Zhou
2017-08-16  7:15               ` [LTP] [PATCH v4 1/3] lib: add helper SAFE_FANOTIFY_INIT Xiong Zhou
2017-08-18 10:22                 ` Cyril Hrubis
2017-08-21  3:12                   ` Xiong Zhou
2017-08-21 11:45                     ` Cyril Hrubis
2017-08-16  7:15               ` [LTP] [PATCH v4 2/3] fanotify: rewrite old cases with new lib Xiong Zhou
2017-08-18 10:24                 ` Cyril Hrubis [this message]
2017-08-16  7:15               ` [LTP] [PATCH v4 3/3] syscalls/fanotify08: add sanity check for FAN_CLOEXEC Xiong Zhou
2017-08-18 10:25                 ` Cyril Hrubis

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=20170818102446.GB22319@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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