changeset 11849:18b5c404aa04

tests: test some of the *-safer modules * modules/fopen-safer (Depends-on): Add fopen. * modules/fcntl-safer (Depends-on): Add fcntl. * modules/stdlib-safer (Depends-on): Add stdlib. (configure.ac): Set indicator. * modules/unistd-safer (configure.ac): Likewise. * modules/tmpfile-safer (configure.ac): Likewise. (Depends-on): Add tmpfile. * lib/stdio--.h (fopen, tmpfile): Don't override unless module is active. * tests/test-fopen.c (includes): Test safer versions when they are in use. * tests/test-open.c (includes): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Wed, 19 Aug 2009 09:54:54 -0600
parents 9e3299dad578
children 9ebc8e9eca64
files ChangeLog lib/stdio--.h modules/fcntl-safer modules/fopen-safer modules/stdlib-safer modules/tmpfile-safer modules/unistd-safer tests/test-fopen.c tests/test-open.c
diffstat 9 files changed, 39 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2009-08-19  Eric Blake  <ebb9@byu.net>
 
+	tests: test some of the *-safer modules
+	* modules/fopen-safer (Depends-on): Add fopen.
+	* modules/fcntl-safer (Depends-on): Add fcntl.
+	* modules/stdlib-safer (Depends-on): Add stdlib.
+	(configure.ac): Set indicator.
+	* modules/unistd-safer (configure.ac): Likewise.
+	* modules/tmpfile-safer (configure.ac): Likewise.
+	(Depends-on): Add tmpfile.
+	* lib/stdio--.h (fopen, tmpfile): Don't override unless module is
+	active.
+	* tests/test-fopen.c (includes): Test safer versions when they are
+	in use.
+	* tests/test-open.c (includes): Likewise.
+
 	popen: fix cygwin 1.5 bug when stdin closed
 	* doc/posix-functions/popen.texi (popen): Document cygwin bugs.
 	* modules/popen: New file.
--- a/lib/stdio--.h
+++ b/lib/stdio--.h
@@ -1,6 +1,6 @@
 /* Like stdio.h, but redefine some names to avoid glitches.
 
-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 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
@@ -20,8 +20,12 @@
 #include <stdio.h>
 #include "stdio-safer.h"
 
-#undef fopen
-#define fopen fopen_safer
+#if GNULIB_FOPEN_SAFER
+# undef fopen
+# define fopen fopen_safer
+#endif
 
-#undef tmpfile
-#define tmpfile tmpfile_safer
+#if GNULIB_TMPFILE_SAFER
+# undef tmpfile
+# define tmpfile tmpfile_safer
+#endif
--- a/modules/fcntl-safer
+++ b/modules/fcntl-safer
@@ -10,6 +10,7 @@
 m4/mode_t.m4
 
 Depends-on:
+fcntl
 open
 unistd-safer
 
--- a/modules/fopen-safer
+++ b/modules/fopen-safer
@@ -8,6 +8,7 @@
 m4/stdio-safer.m4
 
 Depends-on:
+fopen
 unistd-safer
 
 configure.ac:
--- a/modules/stdlib-safer
+++ b/modules/stdlib-safer
@@ -9,10 +9,12 @@
 
 Depends-on:
 mkstemp
+stdlib
 unistd-safer
 
 configure.ac:
 gl_STDLIB_SAFER
+gl_MODULE_INDICATOR([stdlib-safer])
 
 Makefile.am:
 
--- a/modules/tmpfile-safer
+++ b/modules/tmpfile-safer
@@ -9,10 +9,12 @@
 
 Depends-on:
 binary-io
+tmpfile
 unistd-safer
 
 configure.ac:
 gl_TMPFILE_SAFER
+gl_MODULE_INDICATOR([tmpfile-safer])
 
 Makefile.am:
 
--- a/modules/unistd-safer
+++ b/modules/unistd-safer
@@ -14,6 +14,7 @@
 
 configure.ac:
 gl_UNISTD_SAFER
+gl_MODULE_INDICATOR([unistd-safer])
 
 Makefile.am:
 
--- a/tests/test-fopen.c
+++ b/tests/test-fopen.c
@@ -1,5 +1,5 @@
 /* Test of opening a file stream.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-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
@@ -21,6 +21,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#if GNULIB_FOPEN_SAFER
+# include "stdio--.h"
+#endif
+
 #define ASSERT(expr) \
   do									     \
     {									     \
--- a/tests/test-open.c
+++ b/tests/test-open.c
@@ -23,6 +23,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#if GNULIB_FCNTL_SAFER
+# include "fcntl--.h"
+#endif
+
 #define ASSERT(expr) \
   do									     \
     {									     \