tests: test more substitute headers
authorEric Blake <ebb9@byu.net>
Wed, 30 Dec 2009 00:01:09 +0000 (17:01 -0700)
committerEric Blake <ebb9@byu.net>
Wed, 30 Dec 2009 03:55:40 +0000 (20:55 -0700)
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>
15 files changed:
ChangeLog
lib/sys_file.in.h
m4/spawn_h.m4
modules/ctype-tests [new file with mode: 0644]
modules/dirent-tests [new file with mode: 0644]
modules/spawn-tests [new file with mode: 0644]
modules/sys_file-tests [new file with mode: 0644]
modules/sys_ioctl-tests [new file with mode: 0644]
modules/sys_wait-tests [new file with mode: 0644]
tests/test-ctype.c [new file with mode: 0644]
tests/test-dirent.c [new file with mode: 0644]
tests/test-spawn.c [new file with mode: 0644]
tests/test-sys_file.c [new file with mode: 0644]
tests/test-sys_ioctl.c [new file with mode: 0644]
tests/test-sys_wait.c [new file with mode: 0644]

index 496239c920fca972f89e0d78db1a1dd031ae5354..6e2b549cd1021293b6dd00072b9d3dc9e72df1f8 100644 (file)
--- 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.
index fbd87c75c4224fef4afdb54c68c2aa9776d691d6..44626640ff1aa03dc4f4579a793731d2d01d68cc 100644 (file)
 #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
index 4c0c610e206c7c164eb6df8147fb34c01cbf42a7..dd915fabdb96250801e6669427133b1874a7dfb2 100644 (file)
@@ -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 (file)
index 0000000..4b9f4af
--- /dev/null
@@ -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 (file)
index 0000000..2511f5f
--- /dev/null
@@ -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 (file)
index 0000000..c576fdd
--- /dev/null
@@ -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 (file)
index 0000000..f52629d
--- /dev/null
@@ -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 (file)
index 0000000..17363a7
--- /dev/null
@@ -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 (file)
index 0000000..9c877d8
--- /dev/null
@@ -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 (file)
index 0000000..2b11719
--- /dev/null
@@ -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;
+}
diff --git a/tests/test-dirent.c b/tests/test-dirent.c
new file mode 100644 (file)
index 0000000..716b201
--- /dev/null
@@ -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;
+}
diff --git a/tests/test-spawn.c b/tests/test-spawn.c
new file mode 100644 (file)
index 0000000..f7b919b
--- /dev/null
@@ -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;
+}
diff --git a/tests/test-sys_file.c b/tests/test-sys_file.c
new file mode 100644 (file)
index 0000000..56b547a
--- /dev/null
@@ -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;
+}
diff --git a/tests/test-sys_ioctl.c b/tests/test-sys_ioctl.c
new file mode 100644 (file)
index 0000000..1281690
--- /dev/null
@@ -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;
+}
diff --git a/tests/test-sys_wait.c b/tests/test-sys_wait.c
new file mode 100644 (file)
index 0000000..b11cf9d
--- /dev/null
@@ -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;
+}