Hi,
--- On Wed, 12/24/08, Masatake YAMATO <yam...@redhat.com> wrote: > From: Masatake YAMATO <yam...@redhat.com> > Subject: [LTP] Introduce autoconf to eventfd test case > To: ltp-list@lists.sourceforge.net > Date: Wednesday, December 24, 2008, 5:19 PM > Makefile of eventfd test case uses cond.mk. I introduce > ltp-eventfd.m4 instead of cond.mk. > > To pass a library name to Makefile, I introduced > config.mk.in. The > purpose of config.mk.in is very similar to config.h.in; > config.h.in is > for C source code and config.mk.in is for Makefile. > > > > In addition I changed following points: > > 1. Some "Note..." messages in Makefile are > removed. > 2. don't use the kernel version in headers to detect > whether the system call is available or not. > 3. Use flags passed to ltp own eventfd wrapper. > > > Before my change ltp own eventfd wrapper calls eventfd > system call like this: > > static int > myeventfd(unsigned int initval, int flags) > { > return syscall(__NR_eventfd, initval); > } > > As you can see, FLAGS argument is not used. I guess > this is a bug. So I changed like: > > static int > myeventfd(unsigned int initval, int flags) > { > return syscall(__NR_eventfd, initval, flags); > } > > If I should provide a separated patch for this FLAGS > issue from autoconf/configure related modification, tell > me. > > > > Signed-off-by: Masatake YAMATO <yam...@redhat.com> > > > > diff --git a/config.mk.in b/config.mk.in > new file mode 100644 > index 0000000..22bad68 > --- /dev/null > +++ b/config.mk.in > @@ -0,0 +1 @@ > +AIO_LIBS = @AIO_LIBS@ > diff --git a/configure.ac b/configure.ac > index 05df57d..bc710b3 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1,6 +1,7 @@ > AC_PREREQ([2.61]) > AC_INIT([ltp], [cvs], [ltp-resu...@lists.sourceforge.net]) > AC_CONFIG_HEADERS([include/config.h]) > +AC_CONFIG_FILES([config.mk]) > > > m4_include([m4/ltp-signalfd.m4]) > @@ -9,5 +10,8 @@ LTP_CHECK_SYSCALL_SIGNALFD > m4_include([m4/ltp-modify_ldt.m4]) > LTP_CHECK_SYSCALL_MODIFY_LDT > > +m4_include([m4/ltp-eventfd.m4]) > +LTP_CHECK_SYSCALL_EVENTFD > + > > AC_OUTPUT > diff --git a/m4/ltp-eventfd.m4 b/m4/ltp-eventfd.m4 > new file mode 100644 > index 0000000..07dbd9b > --- /dev/null > +++ b/m4/ltp-eventfd.m4 > @@ -0,0 +1,40 @@ > +dnl > +dnl Copyright (c) Red Hat Inc., 2008 > +dnl > +dnl This program is free software; you can redistribute > it and/or modify > +dnl it under the terms of the GNU General Public License > as published by > +dnl the Free Software Foundation; either version 2 of the > License, or > +dnl (at your option) any later version. > +dnl > +dnl This program is distributed in the hope that it will > be useful, > +dnl but WITHOUT ANY WARRANTY; without even the implied > warranty of > +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > See > +dnl the GNU General Public License for more details. > +dnl > +dnl You should have received a copy of the GNU General > Public License > +dnl along with this program; if not, write to the Free > Software > +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, > MA 02111-1307 USA > +dnl > +dnl Author: Masatake YAMATO <yam...@redhat.com> > +dnl > + > +dnl > +dnl LTP_CHECK_SYSCALL_EVENTFD > +dnl ---------------------------- > +dnl > +AC_DEFUN([LTP_CHECK_SYSCALL_EVENTFD], > +[dnl > +AC_CHECK_HEADERS(sys/eventfd.h) > + > +AC_CHECK_HEADERS(libaio.h) > + > +AC_CHECK_LIB(aio,io_setup) > +for x in $LIBS; do > + if test "$x" = -laio; then > + AIO_LIBS="$AIO_LIBS -laio" > + fi > +done > +AC_SUBST(AIO_LIBS) > + > +AC_CHECK_FUNCS(io_set_eventfd) > +])dnl > diff --git a/testcases/kernel/syscalls/eventfd/Makefile > b/testcases/kernel/syscalls/eventfd/Makefile > index fc31597..e533fec 100644 > --- a/testcases/kernel/syscalls/eventfd/Makefile > +++ b/testcases/kernel/syscalls/eventfd/Makefile > @@ -16,42 +16,17 @@ > # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, > MA 02110-1301 USA > # > > -include ../utils/cond.mk > + > +include ../../../../config.mk > > > CFLAGS += -I../../../../include -Wall > LDLIBS += -L../../../../lib -lltp > > -check_aio_eventfd = $(shell \ > - if printf \ > - "\#include <libaio.h>\n\ > - int main() \ > - { \ > - io_set_eventfd(NULL, 0); \ > - return 0; \ > - }" | $(CC) -xc -laio - > /dev/null 2>&1 ; > \ > - then echo yes ; \ > - else echo no ; fi) > - > -HAS_LIBAIO = $(call check_header,libaio.h) > -HAS_LIBAIO_EVENTFD = $(call check_aio_eventfd) > - > -ifeq ($(HAS_LIBAIO_EVENTFD),yes) > -CFLAGS += -DHAS_AIO_EVENTFD > -LDLIBS += -laio > -endif > - > SRCS = $(wildcard *.c) > TARGETS = $(patsubst %.c, %, $(wildcard *.c)) > > all: $(TARGETS) > -ifeq ($(HAS_LIBAIO),no) > - @echo "Note: Libaio is required for eventfd overflow > testing."; > -else > -ifeq ($(HAS_LIBAIO_EVENTFD),no) > - @echo "Note: Eventfd support is required in libaio > for overflow testing."; > -endif > -endif > > install: > @set -e; for i in $(TARGETS); do ln -f $$i > ../../../bin/$$i ; done > diff --git a/testcases/kernel/syscalls/eventfd/eventfd01.c > b/testcases/kernel/syscalls/eventfd/eventfd01.c > index 4cf0bc4..863023d 100644 > --- a/testcases/kernel/syscalls/eventfd/eventfd01.c > +++ b/testcases/kernel/syscalls/eventfd/eventfd01.c > @@ -44,6 +44,8 @@ > * None > */ > > +#include "config.h" > + > #include <sys/select.h> > #include <sys/signal.h> > #include <sys/types.h> > @@ -59,21 +61,32 @@ > #include <usctest.h> > #include <linux_syscall_numbers.h> > > -#ifdef HAS_AIO_EVENTFD > +#ifdef HAVE_SYS_EVENTFD_H > +#include <sys/eventfd.h> > +#endif > + > +#ifdef HAVE_LIBAIO_H > #include <libaio.h> > #endif > > static void setup(void); > static void cleanup(void); > > -char *TCID = "eventfd01"; > +TCID_DEFINE(eventfd01); > int TST_TOTAL = 15; > extern int Tst_count; > > static int > myeventfd(unsigned int initval, int flags) > { > - return syscall(__NR_eventfd, initval); > +#if defined HAVE_SYS_EVENTFD_H > + return eventfd(initval, flags); > +#elif defined (__NR_eventfd) > + return syscall(__NR_eventfd, initval, flags); > +#else > + errno = ENOSYS; > + return -1; > +#endif > } > > /* > @@ -512,7 +525,7 @@ child_inherit_test(int fd) > } > } > > -#ifdef HAS_AIO_EVENTFD > +#ifdef HAVE_IO_SET_EVENTFD > /* > * Test whether counter overflow is detected and handled > correctly. > * > @@ -776,9 +789,6 @@ setup(void) > /* capture signals */ > tst_sig(FORK, DEF_HANDLER, cleanup); > > - if (tst_kvercmp(2, 6, 22) < 0) > - tst_brkm(TCONF, cleanup, "2.6.22 or greater kernel > required"); > - > /* Pause if that option was specified > * TEST_PAUSE contains the code to fork the test with the > -c option. > */ > Looks like I have problem to apply this patch on top of the current CVS version. $ patch -Np1 <eventfd.patch patching file config.mk.in patching file configure.ac Hunk #2 FAILED at 10. 1 out of 2 hunks FAILED -- saving rejects to file configure.ac.rej $ cat configure.ac.rej *************** *** 1,6 **** AC_PREREQ([2.61]) AC_INIT([ltp], [cvs], [ltp-resu...@lists.sourceforge.net]) AC_CONFIG_HEADERS([include/config.h]) m4_include([m4/ltp-signalfd.m4]) --- 1,7 ---- AC_PREREQ([2.61]) AC_INIT([ltp], [cvs], [ltp-resu...@lists.sourceforge.net]) AC_CONFIG_HEADERS([include/config.h]) + AC_CONFIG_FILES([config.mk]) m4_include([m4/ltp-signalfd.m4]) *************** *** 9,13 **** m4_include([m4/ltp-modify_ldt.m4]) LTP_CHECK_SYSCALL_MODIFY_LDT AC_OUTPUT --- 10,17 ---- m4_include([m4/ltp-modify_ldt.m4]) LTP_CHECK_SYSCALL_MODIFY_LDT + m4_include([m4/ltp-eventfd.m4]) + LTP_CHECK_SYSCALL_EVENTFD + AC_OUTPUT In addition, I have seen you remove the previous checking of kernel version. Since I can't apply the patch, I need to ask. what happens when the kernel does not support this system call? Does it still give us a TCONF if the system call is unavailable? CAI Qian > ------------------------------------------------------------------------------ > _______________________________________________ > Ltp-list mailing list > Ltp-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ltp-list ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list