[LTP] [PATCH v4 2/3] fanotify: rewrite old cases with new lib
Cyril Hrubis
chrubis@suse.cz
Fri Aug 18 12:24:46 CEST 2017
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
More information about the ltp
mailing list