All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] syscalls/pipe01: Cleanup && convert to new API.
@ 2016-05-12  7:18 Xiao Yang
  2016-05-12  7:18 ` [LTP] [PATCH 2/2] syscalls/fanotify*: Cleanup && fix compiler warnings Xiao Yang
  2016-05-17 11:44 ` [LTP] [PATCH 1/2] syscalls/pipe01: Cleanup && convert to new API Cyril Hrubis
  0 siblings, 2 replies; 7+ messages in thread
From: Xiao Yang @ 2016-05-12  7:18 UTC (permalink / raw)
  To: ltp

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/pipe/pipe01.c | 170 +++++++++++---------------------
 1 file changed, 56 insertions(+), 114 deletions(-)

diff --git a/testcases/kernel/syscalls/pipe/pipe01.c b/testcases/kernel/syscalls/pipe/pipe01.c
index 18cda6f..36902be 100644
--- a/testcases/kernel/syscalls/pipe/pipe01.c
+++ b/testcases/kernel/syscalls/pipe/pipe01.c
@@ -1,145 +1,87 @@
 /*
+ * Copyright (c) International Business Machines Corp., 2001
  *
- *   Copyright (c) International Business Machines  Corp., 2001
+ * This program is free software;  you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY;  without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
  *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  */
 
 /*
- * NAME
- *	pipe01.c
- *
- * DESCRIPTION
- *	Testcase to check the basic functionality of the pipe(2) syscall:
- *	Check that both ends of the pipe (both file descriptors) are
- *	available to a process opening the pipe.
- *
- * ALGORITHM
- *	Write a string of characters down a pipe; read the string from the
- *	other file descriptor. Test passes if both can be done, as reported
- *	by the number of characters written and read.
- *
- * USAGE:  <for command-line>
- *  pipe01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * RESTRICITONS
- *	NONE
+ * Basic test for pipe().
  */
-#include <unistd.h>
+
 #include <errno.h>
 #include <string.h>
-#include "test.h"
-
-char *TCID = "pipe01";
-int TST_TOTAL = 1;
+#include "tst_test.h"
 
-void setup(void);
-void cleanup(void);
+#define SIZE	27
 
-ssize_t do_read(int fd, void *buf, size_t count)
-{
-	ssize_t n;
-
-	do {
-		n = read(fd, buf, count);
-	} while (n < 0 && errno == EINTR);
-
-	return n;
-}
+static int fildes[2];
+static char wrbuf[SIZE], rebuf[SIZE];
 
-int main(int ac, char **av)
+static void verify_pipe(void)
 {
-	int lc;
-
-	int fildes[2];		/* fds for pipe read and write */
-	char wrbuf[BUFSIZ], rebuf[BUFSIZ];
-	int red, written;	/* no. of chars read/written to pipe */
-	int greater, length;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
+	int red, written;
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
+	strcpy(rebuf, "00000000000000000000000000");
 
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
+	TEST(pipe(fildes));
 
-		TEST(pipe(fildes));
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "pipe() failed unexpectedly - errno %d",
-				 TEST_ERRNO);
-			continue;
-		}
-
-		strcpy(wrbuf, "abcdefghijklmnopqrstuvwxyz");
-		length = strlen(wrbuf);
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL, "pipe() failed unexpectedly - errno %d",
+			 TEST_ERRNO);
+		return;
+	}
 
-		if ((written = write(fildes[1], wrbuf, length)) == -1) {
-			tst_brkm(TBROK, cleanup, "write() failed");
-		}
+	written = SAFE_WRITE(1, fildes[1], wrbuf, strlen(wrbuf));
 
-		if (written < 0 || written > 26) {
-			tst_resm(TFAIL, "Condition #1 test failed");
-			continue;
-		}
+	if (written < 0 || written > 26) {
+		tst_res(TFAIL, "Condition #1 test failed");
+		return;
+	}
 
-		if ((red = do_read(fildes[0], rebuf, written)) == -1) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "read() failed");
-		}
+	red = SAFE_READ(1, fildes[0], rebuf, written);
 
-		if (red < 0 || red > written) {
-			tst_resm(TFAIL, "Condition #2 test failed");
-			continue;
-		}
+	if (red < 0 || red > written) {
+		tst_res(TFAIL, "Condition #2 test failed");
+		return;
+	}
 
-		/* are the strings written and read equal */
-		if ((greater = strncmp(rebuf, wrbuf, red)) != 0) {
-			tst_resm(TFAIL, "Condition #3 test failed");
-			continue;
-		}
-		tst_resm(TPASS, "pipe() functionality is correct");
+	if ((strncmp(rebuf, wrbuf, red)) != 0) {
+		tst_res(TFAIL, "Condition #3 test failed");
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	tst_res(TPASS, "pipe() functionality is correct");
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
+static void setup(void)
 {
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
+	strcpy(wrbuf, "abcdefghijklmnopqrstuvwxyz");
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *	       completion or premature exit.
- */
-void cleanup(void)
+static void cleanup(void)
 {
+	if (fildes[0] > 0 && close(fildes[0]))
+		tst_res(TWARN | TERRNO, "Failed to close file");
+
+	if (fildes[1] > 0 && close(fildes[1]))
+		tst_res(TWARN | TERRNO, "Failed to close file");
 }
+
+static struct tst_test test = {
+	.tid = "pipe01",
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_pipe,
+	.needs_tmpdir = 1,
+};
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH 2/2] syscalls/fanotify*: Cleanup && fix compiler warnings
  2016-05-12  7:18 [LTP] [PATCH 1/2] syscalls/pipe01: Cleanup && convert to new API Xiao Yang
@ 2016-05-12  7:18 ` Xiao Yang
  2016-05-17 12:11   ` Cyril Hrubis
  2016-05-17 11:44 ` [LTP] [PATCH 1/2] syscalls/pipe01: Cleanup && convert to new API Cyril Hrubis
  1 sibling, 1 reply; 7+ messages in thread
From: Xiao Yang @ 2016-05-12  7:18 UTC (permalink / raw)
  To: ltp

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/fanotify/fanotify.h   | 57 -------------------------
 testcases/kernel/syscalls/fanotify/fanotify01.c |  4 +-
 testcases/kernel/syscalls/fanotify/fanotify02.c |  1 -
 testcases/kernel/syscalls/fanotify/fanotify03.c |  3 +-
 testcases/kernel/syscalls/fanotify/fanotify04.c |  5 +--
 testcases/kernel/syscalls/fanotify/fanotify05.c |  1 -
 testcases/kernel/syscalls/fanotify/fanotify06.c |  1 -
 7 files changed, 5 insertions(+), 67 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/fanotify/fanotify.h

diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
deleted file mode 100644
index 518d05e..0000000
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * fanotify testcase common definitions.
- *
- * Copyright (c) 2012 Linux Test Project.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Jan Kara, November 2013
- */
-
-#ifndef	__FANOTIFY_H__
-#define	__FANOTIFY_H__
-
-#include "config.h"
-
-#if defined(HAVE_SYS_FANOTIFY_H)
-
-#include <sys/fanotify.h>
-
-#else /* HAVE_SYS_FANOTIFY_H */
-
-/* fanotify(7) wrappers */
-
-#include <stdint.h>
-#include "linux_syscall_numbers.h"
-
-static int fanotify_init(unsigned int flags, unsigned int event_f_flags)
-{
-	return syscall(__NR_fanotify_init, flags, event_f_flags);
-}
-
-static long fanotify_mark(int fd, unsigned int flags, uint64_t mask,
-                     int dfd, const char *pathname)
-{
-	return syscall(__NR_fanotify_mark, fd, flags, mask, dfd, pathname);
-}
-
-#endif /* HAVE_SYS_FANOTIFY_H */
-
-#endif /* __FANOTIFY_H__ */
diff --git a/testcases/kernel/syscalls/fanotify/fanotify01.c b/testcases/kernel/syscalls/fanotify/fanotify01.c
index fb0f6eb..24e702a 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify01.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
@@ -37,7 +37,6 @@
 #include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify01";
@@ -73,7 +72,8 @@ int main(int ac, char **av)
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		int ret, len, i = 0, test_num = 0;
+		int len, i = 0, test_num = 0;
+		unsigned int ret;
 
 		tst_count = 0;
 
diff --git a/testcases/kernel/syscalls/fanotify/fanotify02.c b/testcases/kernel/syscalls/fanotify/fanotify02.c
index 5de49f2..997d806 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify02.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify02.c
@@ -37,7 +37,6 @@
 #include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify02";
diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c
index 8310198..ab26ed5 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify03.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify03.c
@@ -40,7 +40,6 @@
 #include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify03";
@@ -90,7 +89,7 @@ static void generate_events(void)
 		exit(4);
 }
 
-static void child_handler(int tmp)
+static void child_handler(int tmp LTP_ATTRIBUTE_UNUSED)
 {
 	/*
 	 * Close notification fd so that we cannot block while reading
diff --git a/testcases/kernel/syscalls/fanotify/fanotify04.c b/testcases/kernel/syscalls/fanotify/fanotify04.c
index 9451be3..c92718d 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify04.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify04.c
@@ -38,7 +38,6 @@
 #include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify04";
@@ -111,7 +110,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, char *flagstr LTP_ATTRIBUTE_UNUSED)
 {
 	int fd;
 
@@ -131,7 +130,7 @@ static void open_dir(char *file)
 	DO_OPEN(file, O_DIRECTORY);
 }
 
-static void verify_event(int mask)
+static void verify_event(unsigned int mask)
 {
 	int ret;
 	struct fanotify_event_metadata *event;
diff --git a/testcases/kernel/syscalls/fanotify/fanotify05.c b/testcases/kernel/syscalls/fanotify/fanotify05.c
index 517bd26..4cd162c 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify05.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify05.c
@@ -36,7 +36,6 @@
 #include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify05";
diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
index 93c9602..e8b1652 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify06.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
@@ -45,7 +45,6 @@
 #include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify06";
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH 1/2] syscalls/pipe01: Cleanup && convert to new API.
  2016-05-12  7:18 [LTP] [PATCH 1/2] syscalls/pipe01: Cleanup && convert to new API Xiao Yang
  2016-05-12  7:18 ` [LTP] [PATCH 2/2] syscalls/fanotify*: Cleanup && fix compiler warnings Xiao Yang
@ 2016-05-17 11:44 ` Cyril Hrubis
  1 sibling, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2016-05-17 11:44 UTC (permalink / raw)
  To: ltp

Hi!
I've cleaned up the test even more and pushed, thanks.

The test does not need temporary directory, the SAFE_* macros cannot
fail, etc..

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH 2/2] syscalls/fanotify*: Cleanup && fix compiler warnings
  2016-05-12  7:18 ` [LTP] [PATCH 2/2] syscalls/fanotify*: Cleanup && fix compiler warnings Xiao Yang
@ 2016-05-17 12:11   ` Cyril Hrubis
  2016-05-18  0:51     ` Xiao Yang
  2016-06-16  2:30     ` [LTP] [PATCH v2] syscalls/fanotify*: Cleanup Xiao Yang
  0 siblings, 2 replies; 7+ messages in thread
From: Cyril Hrubis @ 2016-05-17 12:11 UTC (permalink / raw)
  To: ltp

Hi!
>  testcases/kernel/syscalls/fanotify/fanotify.h   | 57 -------------------------

Looking at the code indeed the testcases have

#if defined(HAVE_SYS_FANOTIFY_H)

#endif

Around the whole test code so the wrappers are not used at all.

But you should really describe exactly that in the commit description so
that it's clear why this header could be removed.

We may also try to remove the #ifdefs from the testcases so they are
compiled even on glibc 2.12 and older (which is not that old). I guess
is that these testcases will compile fine, but we would have to add
configure check for linux/fanotify.h which would have to be included
before the fanotify wrappers to get the FAN_* constants defined. And
also create fallback definitions or skip the test compilation if both
sys/fanotify.h and linux/fanotify.h was misssing.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH 2/2] syscalls/fanotify*: Cleanup && fix compiler warnings
  2016-05-17 12:11   ` Cyril Hrubis
@ 2016-05-18  0:51     ` Xiao Yang
  2016-06-16  2:30     ` [LTP] [PATCH v2] syscalls/fanotify*: Cleanup Xiao Yang
  1 sibling, 0 replies; 7+ messages in thread
From: Xiao Yang @ 2016-05-18  0:51 UTC (permalink / raw)
  To: ltp


> Hi!
>>   testcases/kernel/syscalls/fanotify/fanotify.h   | 57 -------------------------
> Looking at the code indeed the testcases have
>
> #if defined(HAVE_SYS_FANOTIFY_H)
>
> #endif
>
> Around the whole test code so the wrappers are not used at all.
>
> But you should really describe exactly that in the commit description so
> that it's clear why this header could be removed.
>
> We may also try to remove the #ifdefs from the testcases so they are
> compiled even on glibc 2.12 and older (which is not that old). I guess
> is that these testcases will compile fine, but we would have to add
> configure check for linux/fanotify.h which would have to be included
> before the fanotify wrappers to get the FAN_* constants defined. And
> also create fallback definitions or skip the test compilation if both
> sys/fanotify.h and linux/fanotify.h was misssing.
>
Hi Cyril
thanks for your response, so i will rewrite this patch.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v2] syscalls/fanotify*: Cleanup
  2016-05-17 12:11   ` Cyril Hrubis
  2016-05-18  0:51     ` Xiao Yang
@ 2016-06-16  2:30     ` Xiao Yang
  2016-09-22 14:27       ` Cyril Hrubis
  1 sibling, 1 reply; 7+ messages in thread
From: Xiao Yang @ 2016-06-16  2:30 UTC (permalink / raw)
  To: ltp

1) Skip the test compilation if both sys/fanotify.h and
   linux/fanotify.h are misssing.
2) Fix compiler warnings.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 configure.ac                                    |  2 +-
 m4/ltp-fanotify.m4                              | 22 ++++++++++
 testcases/kernel/syscalls/fanotify/fanotify.h   | 57 -------------------------
 testcases/kernel/syscalls/fanotify/fanotify01.c |  8 ++--
 testcases/kernel/syscalls/fanotify/fanotify02.c |  5 +--
 testcases/kernel/syscalls/fanotify/fanotify03.c |  7 ++-
 testcases/kernel/syscalls/fanotify/fanotify04.c |  9 ++--
 testcases/kernel/syscalls/fanotify/fanotify05.c |  5 +--
 testcases/kernel/syscalls/fanotify/fanotify06.c |  5 +--
 9 files changed, 40 insertions(+), 80 deletions(-)
 create mode 100644 m4/ltp-fanotify.m4
 delete mode 100644 testcases/kernel/syscalls/fanotify/fanotify.h

diff --git a/configure.ac b/configure.ac
index e0e9c1b..548bc3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,7 +43,6 @@ AC_CHECK_HEADERS([ \
     linux/netlink.h \
     sys/epoll.h \
     sys/inotify.h \
-    sys/fanotify.h \
     sys/jfsdmapi.h \
     sys/prctl.h \
 ])
@@ -188,5 +187,6 @@ LTP_CHECK_PWRITEV
 LTP_CHECK_EPOLL_PWAIT
 LTP_CHECK_KEYUTILS_SUPPORT
 LTP_CHECK_SYNC_ADD_AND_FETCH
+LTP_CHECK_FANOTIFY
 
 AC_OUTPUT
diff --git a/m4/ltp-fanotify.m4 b/m4/ltp-fanotify.m4
new file mode 100644
index 0000000..f9e26a0
--- /dev/null
+++ b/m4/ltp-fanotify.m4
@@ -0,0 +1,22 @@
+dnl
+dnl Copyright (c) 2016 Fujitsu Ltd.
+dnl Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify it
+dnl under the terms of version 2 of the GNU General Public License as
+dnl published by the Free Software Foundation.
+dnl
+dnl This program is distributed in the hope that it would be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl alone with this program.
+dnl
+dnl
+dnl LTP_CHECK_FANOTIFY
+dnl ----------------------------
+dnl
+AC_DEFUN([LTP_CHECK_FANOTIFY],[
+AC_CHECK_HEADERS([sys/fanotify.h linux/fanotify.h])
+])
diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
deleted file mode 100644
index 518d05e..0000000
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * fanotify testcase common definitions.
- *
- * Copyright (c) 2012 Linux Test Project.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Jan Kara, November 2013
- */
-
-#ifndef	__FANOTIFY_H__
-#define	__FANOTIFY_H__
-
-#include "config.h"
-
-#if defined(HAVE_SYS_FANOTIFY_H)
-
-#include <sys/fanotify.h>
-
-#else /* HAVE_SYS_FANOTIFY_H */
-
-/* fanotify(7) wrappers */
-
-#include <stdint.h>
-#include "linux_syscall_numbers.h"
-
-static int fanotify_init(unsigned int flags, unsigned int event_f_flags)
-{
-	return syscall(__NR_fanotify_init, flags, event_f_flags);
-}
-
-static long fanotify_mark(int fd, unsigned int flags, uint64_t mask,
-                     int dfd, const char *pathname)
-{
-	return syscall(__NR_fanotify_mark, fd, flags, mask, dfd, pathname);
-}
-
-#endif /* HAVE_SYS_FANOTIFY_H */
-
-#endif /* __FANOTIFY_H__ */
diff --git a/testcases/kernel/syscalls/fanotify/fanotify01.c b/testcases/kernel/syscalls/fanotify/fanotify01.c
index fb0f6eb..e8c3c1d 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify01.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
@@ -36,15 +36,14 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify01";
 int TST_TOTAL = 12;
 
-#if defined(HAVE_SYS_FANOTIFY_H)
+#if defined(HAVE_SYS_FANOTIFY_H) && defined(HAVE_LINUX_FANOTIFY_H)
 #include <sys/fanotify.h>
+#include <linux/fanotify.h>
 
 #define EVENT_MAX 1024
 /* size of the event structure, not counting name */
@@ -73,7 +72,8 @@ int main(int ac, char **av)
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		int ret, len, i = 0, test_num = 0;
+		int len, i = 0, test_num = 0;
+		unsigned int ret;
 
 		tst_count = 0;
 
diff --git a/testcases/kernel/syscalls/fanotify/fanotify02.c b/testcases/kernel/syscalls/fanotify/fanotify02.c
index 5de49f2..593a251 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify02.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify02.c
@@ -36,15 +36,14 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify02";
 int TST_TOTAL = 8;
 
-#if defined(HAVE_SYS_FANOTIFY_H)
+#if defined(HAVE_SYS_FANOTIFY_H) && defined(HAVE_LINUX_FANOTIFY_H)
 #include <sys/fanotify.h>
+#include <linux/fanotify.h>
 
 #define EVENT_MAX 1024
 /* size of the event structure, not counting name */
diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c
index 8310198..54a6eb9 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify03.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify03.c
@@ -39,15 +39,14 @@
 #include <signal.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify03";
 int TST_TOTAL = 3;
 
-#if defined(HAVE_SYS_FANOTIFY_H)
+#if defined(HAVE_SYS_FANOTIFY_H) && defined(HAVE_LINUX_FANOTIFY_H)
 #include <sys/fanotify.h>
+#include <linux/fanotify.h>
 
 #define EVENT_MAX 1024
 /* size of the event structure, not counting name */
@@ -90,7 +89,7 @@ static void generate_events(void)
 		exit(4);
 }
 
-static void child_handler(int tmp)
+static void child_handler(int tmp LTP_ATTRIBUTE_UNUSED)
 {
 	/*
 	 * Close notification fd so that we cannot block while reading
diff --git a/testcases/kernel/syscalls/fanotify/fanotify04.c b/testcases/kernel/syscalls/fanotify/fanotify04.c
index 9451be3..41feea0 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify04.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify04.c
@@ -37,15 +37,14 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify04";
 int TST_TOTAL = 9;
 
-#if defined(HAVE_SYS_FANOTIFY_H)
+#if defined(HAVE_SYS_FANOTIFY_H) && defined(HAVE_LINUX_FANOTIFY_H)
 #include <sys/fanotify.h>
+#include <linux/fanotify.h>
 
 #define EVENT_MAX 1024
 /* size of the event structure, not counting name */
@@ -111,7 +110,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, char *flagstr LTP_ATTRIBUTE_UNUSED)
 {
 	int fd;
 
@@ -131,7 +130,7 @@ static void open_dir(char *file)
 	DO_OPEN(file, O_DIRECTORY);
 }
 
-static void verify_event(int mask)
+static void verify_event(unsigned int mask)
 {
 	int ret;
 	struct fanotify_event_metadata *event;
diff --git a/testcases/kernel/syscalls/fanotify/fanotify05.c b/testcases/kernel/syscalls/fanotify/fanotify05.c
index 517bd26..c2ecf9d 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify05.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify05.c
@@ -35,15 +35,14 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify05";
 int TST_TOTAL = 1;
 
-#if defined(HAVE_SYS_FANOTIFY_H)
+#if defined(HAVE_SYS_FANOTIFY_H) && defined(HAVE_LINUX_FANOTIFY_H)
 #include <sys/fanotify.h>
+#include <linux/fanotify.h>
 
 /* Currently this is fixed in kernel... */
 #define MAX_EVENTS 16384
diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
index 93c9602..5fa982a 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify06.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
@@ -44,14 +44,13 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
-#include "fanotify.h"
 #include "safe_macros.h"
 
 char *TCID = "fanotify06";
 
-#if defined(HAVE_SYS_FANOTIFY_H)
+#if defined(HAVE_SYS_FANOTIFY_H) && defined(HAVE_LINUX_FANOTIFY_H)
 #include <sys/fanotify.h>
+#include <linux/fanotify.h>
 
 #define EVENT_MAX 1024
 /* size of the event structure, not counting name */
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v2] syscalls/fanotify*: Cleanup
  2016-06-16  2:30     ` [LTP] [PATCH v2] syscalls/fanotify*: Cleanup Xiao Yang
@ 2016-09-22 14:27       ` Cyril Hrubis
  0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2016-09-22 14:27 UTC (permalink / raw)
  To: ltp

Hi!
> diff --git a/configure.ac b/configure.ac
> index e0e9c1b..548bc3a 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -43,7 +43,6 @@ AC_CHECK_HEADERS([ \
>      linux/netlink.h \
>      sys/epoll.h \
>      sys/inotify.h \
> -    sys/fanotify.h \
>      sys/jfsdmapi.h \
>      sys/prctl.h \
>  ])
> @@ -188,5 +187,6 @@ LTP_CHECK_PWRITEV
>  LTP_CHECK_EPOLL_PWAIT
>  LTP_CHECK_KEYUTILS_SUPPORT
>  LTP_CHECK_SYNC_ADD_AND_FETCH
> +LTP_CHECK_FANOTIFY
>  
>  AC_OUTPUT
> diff --git a/m4/ltp-fanotify.m4 b/m4/ltp-fanotify.m4
> new file mode 100644
> index 0000000..f9e26a0
> --- /dev/null
> +++ b/m4/ltp-fanotify.m4
> @@ -0,0 +1,22 @@
> +dnl
> +dnl Copyright (c) 2016 Fujitsu Ltd.
> +dnl Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
> +dnl
> +dnl This program is free software; you can redistribute it and/or modify it
> +dnl under the terms of version 2 of the GNU General Public License as
> +dnl published by the Free Software Foundation.
> +dnl
> +dnl This program is distributed in the hope that it would be useful, but
> +dnl WITHOUT ANY WARRANTY; without even the implied warranty of
> +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> +dnl
> +dnl You should have received a copy of the GNU General Public License
> +dnl alone with this program.
> +dnl
> +dnl
> +dnl LTP_CHECK_FANOTIFY
> +dnl ----------------------------
> +dnl
> +AC_DEFUN([LTP_CHECK_FANOTIFY],[
> +AC_CHECK_HEADERS([sys/fanotify.h linux/fanotify.h])
> +])

No need to start a new m4 file just for one more hader, it's much easier
just to add the linux/fanotify.h into the AC_CHECK_HEADERS().

> diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
> deleted file mode 100644
> index 518d05e..0000000
> --- a/testcases/kernel/syscalls/fanotify/fanotify.h
> +++ /dev/null
> @@ -1,57 +0,0 @@
> -/*
> - * fanotify testcase common definitions.
> - *
> - * Copyright (c) 2012 Linux Test Project.  All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms of version 2 of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> - *
> - * Further, this software is distributed without any warranty that it is
> - * free of the rightful claim of any third person regarding infringement
> - * or the like.  Any license provided herein, whether implied or
> - * otherwise, applies only to this software file.  Patent licenses, if
> - * any, provided herein do not apply to combinations of this program with
> - * other software, or any other product whatsoever.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, write the Free Software Foundation, Inc.,
> - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> - *
> - * Jan Kara, November 2013
> - */
> -
> -#ifndef	__FANOTIFY_H__
> -#define	__FANOTIFY_H__
> -
> -#include "config.h"
> -
> -#if defined(HAVE_SYS_FANOTIFY_H)
> -
> -#include <sys/fanotify.h>
> -
> -#else /* HAVE_SYS_FANOTIFY_H */
> -
> -/* fanotify(7) wrappers */
> -
> -#include <stdint.h>
> -#include "linux_syscall_numbers.h"
> -
> -static int fanotify_init(unsigned int flags, unsigned int event_f_flags)
> -{
> -	return syscall(__NR_fanotify_init, flags, event_f_flags);
> -}
> -
> -static long fanotify_mark(int fd, unsigned int flags, uint64_t mask,
> -                     int dfd, const char *pathname)
> -{
> -	return syscall(__NR_fanotify_mark, fd, flags, mask, dfd, pathname);
> -}
> -
> -#endif /* HAVE_SYS_FANOTIFY_H */
> -
> -#endif /* __FANOTIFY_H__ */
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify01.c b/testcases/kernel/syscalls/fanotify/fanotify01.c
> index fb0f6eb..e8c3c1d 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify01.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
> @@ -36,15 +36,14 @@
>  #include <string.h>
>  #include <sys/syscall.h>
>  #include "test.h"
> -#include "linux_syscall_numbers.h"
> -#include "fanotify.h"
>  #include "safe_macros.h"
>  
>  char *TCID = "fanotify01";
>  int TST_TOTAL = 12;
>  
> -#if defined(HAVE_SYS_FANOTIFY_H)
> +#if defined(HAVE_SYS_FANOTIFY_H) && defined(HAVE_LINUX_FANOTIFY_H)
>  #include <sys/fanotify.h>
> +#include <linux/fanotify.h>

This is not correct either.

The reasoning should be:

* If sys/fanotify.h is present, just include it and be done with it
  (as this defines all that is needed)

* If linux/fanotify.h is present but sys/fanotify.h is missing
  include linux/fanotify.h + define fanotify_init() and fanotify_mark()
  wrappers

* If none of them is present, we either have to define the wrappers +
  fanotify constants and structures, or skip the test compilation and
  just report TCONF

Which is nearly what the fanotify.h in the test directory does. We just
have to include linux/fanotify.h there, if it's present and the
sys/fanotify.h is not present. And also strip the sys/fanotify.h include
from the testcases. Then we can let the testcase code compile if either
of the sys/fanotify.h or linux/fanotify.h is present:

#if defined(HAVE_SYS_FANOTIFY_H) || defined(HAVE_LINUX_FANOTIFY_H)

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-09-22 14:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-12  7:18 [LTP] [PATCH 1/2] syscalls/pipe01: Cleanup && convert to new API Xiao Yang
2016-05-12  7:18 ` [LTP] [PATCH 2/2] syscalls/fanotify*: Cleanup && fix compiler warnings Xiao Yang
2016-05-17 12:11   ` Cyril Hrubis
2016-05-18  0:51     ` Xiao Yang
2016-06-16  2:30     ` [LTP] [PATCH v2] syscalls/fanotify*: Cleanup Xiao Yang
2016-09-22 14:27       ` Cyril Hrubis
2016-05-17 11:44 ` [LTP] [PATCH 1/2] syscalls/pipe01: Cleanup && convert to new API Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.