From 2233a5dfb90328805fea25b6ff386f1be8e172f6 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 29 Dec 2009 17:01:09 -0700 Subject: [PATCH] tests: test more substitute headers Add tests of common headers, in preparation of always providing a gnulib wrapper (for improved LINK_WARNING support). * modules/ctype-tests: New file. * modules/dirent-tests: Likewise. * modules/spawn-tests: Likewise. * modules/sys_file-tests: Likewise. * modules/sys_ioctl-tests: Likewise. * modules/sys_wait-tests: Likewise. * tests/test-ctype.c: Likewise. * tests/test-dirent.c: Likewise. * tests/test-spawn.c: Likewise. * tests/test-sys_file.c: Likewise. * tests/test-sys_ioctl.c: Likewise. * tests/test-sys_wait.c: Likewise. * m4/spawn_h.m4 (gl_SPAWN_H): Replace header if it is missing. * lib/sys_file.in.h (LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB): Provide whether or not flock is in use. Signed-off-by: Eric Blake --- ChangeLog | 17 ++++++++++++++++ lib/sys_file.in.h | 18 ++++++++--------- m4/spawn_h.m4 | 3 ++- modules/ctype-tests | 10 +++++++++ modules/dirent-tests | 10 +++++++++ modules/spawn-tests | 10 +++++++++ modules/sys_file-tests | 10 +++++++++ modules/sys_ioctl-tests | 10 +++++++++ modules/sys_wait-tests | 10 +++++++++ tests/test-ctype.c | 27 +++++++++++++++++++++++++ tests/test-dirent.c | 32 +++++++++++++++++++++++++++++ tests/test-spawn.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/test-sys_file.c | 35 ++++++++++++++++++++++++++++++++ tests/test-sys_ioctl.c | 27 +++++++++++++++++++++++++ tests/test-sys_wait.c | 30 +++++++++++++++++++++++++++ 15 files changed, 293 insertions(+), 10 deletions(-) create mode 100644 modules/ctype-tests create mode 100644 modules/dirent-tests create mode 100644 modules/spawn-tests create mode 100644 modules/sys_file-tests create mode 100644 modules/sys_ioctl-tests create mode 100644 modules/sys_wait-tests create mode 100644 tests/test-ctype.c create mode 100644 tests/test-dirent.c create mode 100644 tests/test-spawn.c create mode 100644 tests/test-sys_file.c create mode 100644 tests/test-sys_ioctl.c create mode 100644 tests/test-sys_wait.c diff --git a/ChangeLog b/ChangeLog index 496239c92..6e2b549cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2009-12-29 Eric Blake + tests: test more substitute headers + * modules/ctype-tests: New file. + * modules/dirent-tests: Likewise. + * modules/spawn-tests: Likewise. + * modules/sys_file-tests: Likewise. + * modules/sys_ioctl-tests: Likewise. + * modules/sys_wait-tests: Likewise. + * tests/test-ctype.c: Likewise. + * tests/test-dirent.c: Likewise. + * tests/test-spawn.c: Likewise. + * tests/test-sys_file.c: Likewise. + * tests/test-sys_ioctl.c: Likewise. + * tests/test-sys_wait.c: Likewise. + * m4/spawn_h.m4 (gl_SPAWN_H): Replace header if it is missing. + * lib/sys_file.in.h (LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB): Provide + whether or not flock is in use. + tests: remove License section from module * modules/arpa_inet-tests: Remove unneeded section. * modules/byteswap-tests: Likewise. diff --git a/lib/sys_file.in.h b/lib/sys_file.in.h index fbd87c75c..44626640f 100644 --- a/lib/sys_file.in.h +++ b/lib/sys_file.in.h @@ -31,21 +31,21 @@ #ifndef _GL_SYS_FILE_H #define _GL_SYS_FILE_H +#ifndef LOCK_SH +/* Operations for the 'flock' call (same as Linux kernel constants). */ +# define LOCK_SH 1 /* Shared lock. */ +# define LOCK_EX 2 /* Exclusive lock. */ +# define LOCK_UN 8 /* Unlock. */ + +/* Can be OR'd in to one of the above. */ +# define LOCK_NB 4 /* Don't block when locking. */ +#endif #if @GNULIB_FLOCK@ /* Apply or remove advisory locks on an open file. Return 0 if successful, otherwise -1 and errno set. */ # if !@HAVE_FLOCK@ extern int flock (int fd, int operation); - -/* Operations for the 'flock' call (same as Linux kernel constants). */ -#define LOCK_SH 1 /* Shared lock. */ -#define LOCK_EX 2 /* Exclusive lock. */ -#define LOCK_UN 8 /* Unlock. */ - -/* Can be OR'd in to one of the above. */ -#define LOCK_NB 4 /* Don't block when locking. */ - # endif #elif defined GNULIB_POSIXCHECK # undef flock diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4 index 4c0c610e2..dd915fabd 100644 --- a/m4/spawn_h.m4 +++ b/m4/spawn_h.m4 @@ -1,4 +1,4 @@ -# spawn_h.m4 serial 2 +# spawn_h.m4 serial 3 dnl Copyright (C) 2008-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -21,6 +21,7 @@ AC_DEFUN([gl_SPAWN_H], HAVE_SPAWN_H=1 else HAVE_SPAWN_H=0 + gl_REPLACE_SPAWN_H fi AC_SUBST([HAVE_SPAWN_H]) diff --git a/modules/ctype-tests b/modules/ctype-tests new file mode 100644 index 000000000..4b9f4af87 --- /dev/null +++ b/modules/ctype-tests @@ -0,0 +1,10 @@ +Files: +tests/test-ctype.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-ctype +check_PROGRAMS += test-ctype diff --git a/modules/dirent-tests b/modules/dirent-tests new file mode 100644 index 000000000..2511f5f66 --- /dev/null +++ b/modules/dirent-tests @@ -0,0 +1,10 @@ +Files: +tests/test-dirent.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-dirent +check_PROGRAMS += test-dirent diff --git a/modules/spawn-tests b/modules/spawn-tests new file mode 100644 index 000000000..c576fdd3a --- /dev/null +++ b/modules/spawn-tests @@ -0,0 +1,10 @@ +Files: +tests/test-spawn.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-spawn +check_PROGRAMS += test-spawn diff --git a/modules/sys_file-tests b/modules/sys_file-tests new file mode 100644 index 000000000..f52629d54 --- /dev/null +++ b/modules/sys_file-tests @@ -0,0 +1,10 @@ +Files: +tests/test-sys_file.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-sys_file +check_PROGRAMS += test-sys_file diff --git a/modules/sys_ioctl-tests b/modules/sys_ioctl-tests new file mode 100644 index 000000000..17363a713 --- /dev/null +++ b/modules/sys_ioctl-tests @@ -0,0 +1,10 @@ +Files: +tests/test-sys_ioctl.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-sys_ioctl +check_PROGRAMS += test-sys_ioctl diff --git a/modules/sys_wait-tests b/modules/sys_wait-tests new file mode 100644 index 000000000..9c877d885 --- /dev/null +++ b/modules/sys_wait-tests @@ -0,0 +1,10 @@ +Files: +tests/test-sys_wait.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-sys_wait +check_PROGRAMS += test-sys_wait diff --git a/tests/test-ctype.c b/tests/test-ctype.c new file mode 100644 index 000000000..2b117190e --- /dev/null +++ b/tests/test-ctype.c @@ -0,0 +1,27 @@ +/* Test of substitute. + Copyright (C) 2009 Free Software Foundation, Inc. + + 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 3 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +int +main (void) +{ + return 0; +} diff --git a/tests/test-dirent.c b/tests/test-dirent.c new file mode 100644 index 000000000..716b20191 --- /dev/null +++ b/tests/test-dirent.c @@ -0,0 +1,32 @@ +/* Test of substitute. + Copyright (C) 2009 Free Software Foundation, Inc. + + 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 3 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +/* Check for existence of required types. */ +static DIR *dir _GL_UNUSED; +static struct dirent d; +static ino_t i; + +int +main (void) +{ + return d.d_name[0] + i; +} diff --git a/tests/test-spawn.c b/tests/test-spawn.c new file mode 100644 index 000000000..f7b919b79 --- /dev/null +++ b/tests/test-spawn.c @@ -0,0 +1,54 @@ +/* Test of substitute. + Copyright (C) 2009 Free Software Foundation, Inc. + + 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 3 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +/* Check for existence of required types. */ +struct check +{ + posix_spawnattr_t a; + posix_spawn_file_actions_t b; + mode_t c; + pid_t d; + sigset_t e; +} s; + +/* struct sched_param is allowed to be an incomplete type without + , but must have a forward declaration to avoid a + compilation error in the following usage. */ +extern void f (struct sched_param *g); +#include +extern void f (struct sched_param *g); + +int +main (void) +{ + switch (0) + { + case POSIX_SPAWN_RESETIDS: + case POSIX_SPAWN_SETPGROUP: + case POSIX_SPAWN_SETSIGDEF: + case POSIX_SPAWN_SETSIGMASK: + case POSIX_SPAWN_SETSCHEDPARAM: + case POSIX_SPAWN_SETSCHEDULER: + ; + } + return s.c + s.d; +} diff --git a/tests/test-sys_file.c b/tests/test-sys_file.c new file mode 100644 index 000000000..56b547a49 --- /dev/null +++ b/tests/test-sys_file.c @@ -0,0 +1,35 @@ +/* Test of substitute. + Copyright (C) 2009 Free Software Foundation, Inc. + + 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 3 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +int +main (void) +{ + switch (0) + { + case LOCK_SH: + case LOCK_EX: + case LOCK_NB: + case LOCK_UN: + ; + } + return 0; +} diff --git a/tests/test-sys_ioctl.c b/tests/test-sys_ioctl.c new file mode 100644 index 000000000..12816908a --- /dev/null +++ b/tests/test-sys_ioctl.c @@ -0,0 +1,27 @@ +/* Test of substitute. + Copyright (C) 2009 Free Software Foundation, Inc. + + 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 3 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +int +main (void) +{ + return 0; +} diff --git a/tests/test-sys_wait.c b/tests/test-sys_wait.c new file mode 100644 index 000000000..b11cf9d4f --- /dev/null +++ b/tests/test-sys_wait.c @@ -0,0 +1,30 @@ +/* Test of substitute. + Copyright (C) 2009 Free Software Foundation, Inc. + + 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 3 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +/* Check for existence of required types. */ +static pid_t a; + +int +main (void) +{ + return a; +} -- 2.11.0