changeset 12522:9c72e4d90613

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 <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Tue, 29 Dec 2009 17:01:09 -0700
parents 15712244d6dc
children 803f92dd00a1
files ChangeLog lib/sys_file.in.h m4/spawn_h.m4 modules/ctype-tests modules/dirent-tests modules/spawn-tests modules/sys_file-tests modules/sys_ioctl-tests modules/sys_wait-tests tests/test-ctype.c tests/test-dirent.c tests/test-spawn.c tests/test-sys_file.c tests/test-sys_ioctl.c tests/test-sys_wait.c
diffstat 15 files changed, 293 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2009-12-29  Eric Blake  <ebb9@byu.net>
 
+	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.
--- 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
--- 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 @@
     HAVE_SPAWN_H=1
   else
     HAVE_SPAWN_H=0
+    gl_REPLACE_SPAWN_H
   fi
   AC_SUBST([HAVE_SPAWN_H])
 
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /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
new file mode 100644
--- /dev/null
+++ b/tests/test-ctype.c
@@ -0,0 +1,27 @@
+/* Test of <ctype.h> 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 <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <ctype.h>
+
+int
+main (void)
+{
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/test-dirent.c
@@ -0,0 +1,32 @@
+/* Test of <dirent.h> 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 <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <dirent.h>
+
+/* 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;
+}
new file mode 100644
--- /dev/null
+++ b/tests/test-spawn.c
@@ -0,0 +1,54 @@
+/* Test of <spawn.h> 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 <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <spawn.h>
+
+/* 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
+   <sched.h>, but must have a forward declaration to avoid a
+   compilation error in the following usage.  */
+extern void f (struct sched_param *g);
+#include <sched.h>
+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;
+}
new file mode 100644
--- /dev/null
+++ b/tests/test-sys_file.c
@@ -0,0 +1,35 @@
+/* Test of <sys/file.h> 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 <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <sys/file.h>
+
+int
+main (void)
+{
+  switch (0)
+    {
+    case LOCK_SH:
+    case LOCK_EX:
+    case LOCK_NB:
+    case LOCK_UN:
+      ;
+    }
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/test-sys_ioctl.c
@@ -0,0 +1,27 @@
+/* Test of <sys/ioctl.h> 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 <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <sys/ioctl.h>
+
+int
+main (void)
+{
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/test-sys_wait.c
@@ -0,0 +1,30 @@
+/* Test of <sys/wait.h> 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 <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <sys/wait.h>
+
+/* Check for existence of required types.  */
+static pid_t a;
+
+int
+main (void)
+{
+  return a;
+}