syscalls/pipe01: Cleanup && convert to new API.
PATCH 1/2 syscalls/pipe01: Cleanup && convert to new API.
--- testcases/kernel/syscalls/pipe/pipe01.c | 170 +++++++++++--------------------- 1 file changed, 56 insertions(+), 114 deletions(-)
testcases/kernel/syscalls/pipe/pipe01.c +56 -114
@@ -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 , +};
Signature · 1 line
1.8.3.1
PATCH 2/2 syscalls/fanotify*: Cleanup && fix compiler warnings
--- 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
testcases/kernel/syscalls/fanotify/fanotify.h deleted +0 -57
@@ -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__ */
testcases/kernel/syscalls/fanotify/fanotify01.c +2 -2
@@ -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 ;
testcases/kernel/syscalls/fanotify/fanotify02.c +0 -1
@@ -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" ;
testcases/kernel/syscalls/fanotify/fanotify03.c +1 -2
@@ -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
testcases/kernel/syscalls/fanotify/fanotify04.c +2 -3
@@ -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;
testcases/kernel/syscalls/fanotify/fanotify05.c +0 -1
@@ -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" ;
testcases/kernel/syscalls/fanotify/fanotify06.c +0 -1
@@ -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" ;
Signature · 1 line
1.8.3.1
PATCH 2/2 syscalls/fanotify*: Cleanup && fix compiler warnings
Hi!
Quoted 1 line
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.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 syscalls/fanotify*: Cleanup && fix compiler warnings
Quoted 14 lines
Hi!
Quoted 1 line
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.
Quoted 8 lines
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.hwhich 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 bothsys/fanotify.handlinux/fanotify.hwas misssing.
Hi Cyril
thanks for your response, so i will rewrite this patch.
PATCH v2 1/1 syscalls/fanotify*: Cleanup
In reply to Cyril Hrubis1) Skip the test compilation if both sys/fanotify.h and linux/fanotify.h are misssing.
2) Fix compiler warnings.
--- 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
configure.ac +1 -1
@@ -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
m4/ltp-fanotify.m4 new file +22 -0
@@ -0,0 +1,22 @@ +dnl +dnl Copyright (c) 2016 Fujitsu Ltd. +dnl Author: Xiao Yang <[email protected]> +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]) +])
testcases/kernel/syscalls/fanotify/fanotify.h deleted +0 -57
57 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify01.c +4 -4
@@ -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 ;
testcases/kernel/syscalls/fanotify/fanotify02.c +2 -3
@@ -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 */
testcases/kernel/syscalls/fanotify/fanotify03.c +3 -4
@@ -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
testcases/kernel/syscalls/fanotify/fanotify04.c +4 -5
@@ -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;
testcases/kernel/syscalls/fanotify/fanotify05.c +2 -3
@@ -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
testcases/kernel/syscalls/fanotify/fanotify06.c +2 -3
@@ -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 */
Signature · 1 line
1.8.3.1
PATCH v2 1/1 syscalls/fanotify*: Cleanup
Hi!
Quoted 37 lines
configure.ac +1
-1@@ -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_OUTPUTm4/ltp-fanotify.m4 new file +12
-0@@ -0,0 +1,22 @@ +dnl +dnl Copyright (c) 2016 Fujitsu Ltd. +dnl Author: Xiao Yang <[email protected]> +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
m4/ltp-fanotify.m4 line 22
Quoted 10 lines
m4/ltp-fanotify.m4 new file +10
-0+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().
Quoted 72 lines
testcases/kernel/syscalls/fanotify/fanotify.h deleted +0
-57@@ -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__ */ testcases/kernel/syscalls/fanotify/fanotify01.c +0
-1@@ -36,15 +36,14 @@#include <string.h> #include <sys/syscall.h> #include "test.h" -#include "linux_syscall_numbers.h"
testcases/kernel/syscalls/fanotify/fanotify01.c line 46
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify01.c +2
-2-#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)
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/2 syscalls/pipe01: Cleanup && convert to new API.
In reply to Xiao YangHi!
I've cleaned up the test even more and pushed, thanks.
The test does not need temporary directory, the SAFE_* macros cannot fail, etc..
Signature · 2 lines
Cyril Hrubis [email protected]