From 41fc74b9ab67321453d103d056a6e8eb8897042a Mon Sep 17 00:00:00 2001
From: Eric Blake <ebb9@byu.net>
Date: Thu, 20 Aug 2009 23:19:20 -0600
Subject: [PATCH] test-fopen-safer: split from test-fopen

* tests/test-fopen.c (main): Move...
* tests/test-fopen.h: ...into new file.
* tests/test-fopen-safer.c: New file.
* modules/fopen-tests (Files): Add test-fopen.h.
* modules/fopen-safer-tests: New file.
Suggested by Bruno Haible.

Signed-off-by: Eric Blake <ebb9@byu.net>
---
 ChangeLog                 | 10 +++++++++
 modules/fopen-safer-tests | 11 ++++++++++
 modules/fopen-tests       |  1 +
 tests/test-fopen-safer.c  | 23 ++++++++++++++++++++
 tests/test-fopen.c        | 28 +------------------------
 tests/test-fopen.h        | 44 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 90 insertions(+), 27 deletions(-)
 create mode 100644 modules/fopen-safer-tests
 create mode 100644 tests/test-fopen-safer.c
 create mode 100644 tests/test-fopen.h

diff --git a/ChangeLog b/ChangeLog
index 565d70afa0..1530f828b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-08-21  Eric Blake  <ebb9@byu.net>
+
+	test-fopen-safer: split from test-fopen
+	* tests/test-fopen.c (main): Move...
+	* tests/test-fopen.h: ...into new file.
+	* tests/test-fopen-safer.c: New file.
+	* modules/fopen-tests (Files): Add test-fopen.h.
+	* modules/fopen-safer-tests: New file.
+	Suggested by Bruno Haible.
+
 2009-08-21  Paolo Bonzini  <bonzini@gnu.org>
 
 	popen-safer: test O_CLOEXEC at run-time.
diff --git a/modules/fopen-safer-tests b/modules/fopen-safer-tests
new file mode 100644
index 0000000000..21116e60ec
--- /dev/null
+++ b/modules/fopen-safer-tests
@@ -0,0 +1,11 @@
+Files:
+tests/test-fopen.h
+tests/test-fopen-safer.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-fopen-safer
+check_PROGRAMS += test-fopen-safer
diff --git a/modules/fopen-tests b/modules/fopen-tests
index cf87389a9e..fb0ee1d6a4 100644
--- a/modules/fopen-tests
+++ b/modules/fopen-tests
@@ -1,4 +1,5 @@
 Files:
+tests/test-fopen.h
 tests/test-fopen.c
 
 Depends-on:
diff --git a/tests/test-fopen-safer.c b/tests/test-fopen-safer.c
new file mode 100644
index 0000000000..701af354c1
--- /dev/null
+++ b/tests/test-fopen-safer.c
@@ -0,0 +1,23 @@
+/* Test of opening a file stream.
+   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
+   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 Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include "stdio--.h"
+
+#include "test-fopen.h"
diff --git a/tests/test-fopen.c b/tests/test-fopen.c
index b9e3694071..473d274f47 100644
--- a/tests/test-fopen.c
+++ b/tests/test-fopen.c
@@ -19,31 +19,5 @@
 #include <config.h>
 
 #include <stdio.h>
-#include <stdlib.h>
 
-#if GNULIB_FOPEN_SAFER
-# include "stdio--.h"
-#endif
-
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
-
-int
-main ()
-{
-  ASSERT (fopen ("nonexist.ent/", "w") == NULL);
-  ASSERT (fopen ("/dev/null/", "r") == NULL);
-
-  ASSERT (fopen ("/dev/null", "r") != NULL);
-
-  return 0;
-}
+#include "test-fopen.h"
diff --git a/tests/test-fopen.h b/tests/test-fopen.h
new file mode 100644
index 0000000000..b1dafbb213
--- /dev/null
+++ b/tests/test-fopen.h
@@ -0,0 +1,44 @@
+/* Test of opening a file stream.
+   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
+   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 Bruno Haible <bruno@clisp.org>, 2007.  */
+
+/* Include <config.h> and a form of <stdio.h> first.  */
+
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+  do									     \
+    {									     \
+      if (!(expr))							     \
+        {								     \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          fflush (stderr);						     \
+          abort ();							     \
+        }								     \
+    }									     \
+  while (0)
+
+int
+main ()
+{
+  ASSERT (fopen ("nonexist.ent/", "w") == NULL);
+  ASSERT (fopen ("/dev/null/", "r") == NULL);
+
+  ASSERT (fopen ("/dev/null", "r") != NULL);
+
+  return 0;
+}
-- 
2.30.2