m4-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to m4/tests/others.at,v


From: Eric Blake
Subject: Changes to m4/tests/others.at,v
Date: Thu, 05 Oct 2006 23:07:31 +0000

CVSROOT:        /sources/m4
Module name:    m4
Changes by:     Eric Blake <ericb>      06/10/05 23:07:28

Index: tests/others.at
===================================================================
RCS file: /sources/m4/m4/tests/others.at,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- tests/others.at     4 Oct 2006 23:30:46 -0000       1.20
+++ tests/others.at     5 Oct 2006 23:07:28 -0000       1.21
@@ -16,7 +16,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301, USA.
 
-AT_BANNER([Composite macros.])
+AT_BANNER([Composite macros and other tests.])
 
 
 ## ---------- ##
@@ -350,38 +350,69 @@
 dnl no error when stderr is not used
 AT_DATA([in.m4], [[hello world
 ]])
-AT_CHECK_M4([in.m4], [0], [[hello world
-]])
+AT_CHECK_M4([2>&-], [0], [[hello world
+]], [], [in.m4])
 
 dnl must exit nonzero when error issued
-AT_CHECK([--unknown], [1])
+AT_CHECK_M4([--unknown 2>&-], [1])
 
 dnl must exit nonzero if stderr used
 AT_DATA([in.m4], [[errprint(`hello world
 ')dnl
 ]])
-AT_CHECK_M4([in.m4 2>&-], [1])
+AT_CHECK_M4([2>&-], [1], [], [], [in.m4])
 
 dnl must exit nonzero if stderr used
-AT_DATA([in.m4], [[dnl(`hello world')
+AT_DATA([in.m4], [[hello
+dnl(`world')
 ]])
-AT_CHECK_M4([in.m4 2>&-], [1])
+AT_CHECK_M4([2>&-], [1], [[hello
+]], [], [in.m4])
 
-dnl must exit nonzero on error, in spite of m4exit
+dnl must exit nonzero on error, in spite of m4exit requesting 0
 AT_DATA([in.m4], [[errprint(`hello world
 ')m4exit(`0')
 ]])
-AT_CHECK_M4([in.m4 2>&-], [1])
+AT_CHECK_M4([2>&-], [1], [], [], [in.m4])
+
+dnl preserve m4exit's failure value
+AT_DATA([in.m4], [[errprint(`hello world
+')m4exit(`2')
+]])
+AT_CHECK_M4([2>&-], [2], [], [], [in.m4])
 
 dnl trace file must not collide with closed stderr
 AT_DATA([in.m4], [[errprint(`hello world
 ')dnl
 ]])
-AT_CHECK_M4([--debugfile=trace -terrprint in.m4 2>&-], [1])
+AT_CHECK_M4([--debugfile=trace -terrprint 2>&-], [1], [], [], [in.m4])
 AT_CHECK([cat trace], [0], [[m4trace: -1- errprint(`hello world
 ')
 ]])
 
+dnl spilled diversion file must not collide with closed stderr
+AT_DATA([in.m4], [M4_ONE_MEG_DEFN[divert(1)f
+and
+divert
+hello`'dnl(world)
+undivert
+goodbye
+]])
+AT_CHECK_M4([2>&-], [1],
+[[hello
+and
+goodbye
+]], [], [in.m4 | sed -ne '/./p'])
+
+dnl command line input file must not collide with closed stderr
+AT_DATA([in.m4], [[syscmd(`cat <&2')sysval
+dnl this line should not be read by cat
+]])
+AT_CHECK_M4([2>&-], [0], [[1
+]], [], [in.m4])
+AT_CHECK_M4([in.m4 2>&-], [0], [[1
+]])
+
 AT_CLEANUP
 
 
@@ -415,6 +446,33 @@
 ]], [[m4:stdin:1: error reading file `stdin'
 ]], [-])
 
+dnl command line and trace file must not collide with stdin
+AT_CHECK([cat <&- && { echo "skipping: can't detect closed stdin"; exit 77; }],
+[1], [], [stderr])
+mv stderr experr
+AT_DATA([in.m4], [[syscmd(`cat')dnl
+]])
+AT_CHECK_M4([--debugfile=trace -tdnl in.m4], [0], [], [experr], [-])
+AT_CHECK([cat trace], [0], [[m4trace: -1- dnl
+]])
+
+dnl diversions must not collide with stdin
+AT_DATA([in.m4], [M4_ONE_MEG_DEFN[divert(`1')f
+syscmd(`cat')dnl
+divert(`-1')undivert
+]])
+AT_CHECK_M4([in.m4], [0], [], [experr], [-])
+
+dnl diversions must not collide with stdin
+AT_DATA([in.m4], [M4_ONE_MEG_DEFN[hello divert(`1')f
+]])
+AT_DATA([in2.m4], [[divert(`-1')undivert
+divert`'world
+]])
+AT_CHECK_M4([in.m4 - in2.m4], [1], [[hello world
+]], [[m4:stdin:1: error reading file `stdin'
+]], [-])
+
 AT_CLEANUP
 
 ## ------------- ##
@@ -435,29 +493,124 @@
 AT_DATA([in.m4], [[errprint(`hello world
 ')dnl
 ]])
-AT_CHECK_M4([in.m4 >&-], [0], [], [[hello world
-]])
+AT_CHECK_M4([>&-], [0], [], [[hello world
+]], [in.m4])
 
 dnl error when stdout must be used
-AT_CHECK_M4([-P in.m4 >&-], [1], [],
+AT_CHECK_M4([-P >&-], [1], [],
 [[m4: write error: Bad file descriptor
-]])
+]], [in.m4])
 
 dnl error must occur in spite of m4exit requesting 0
 AT_DATA([in.m4], [[hello world
 m4exit(`0')
 ]])
-AT_CHECK_M4([in.m4 >&-], [1], [],
+AT_CHECK_M4([>&-], [1], [],
 [[m4: write error: Bad file descriptor
+]], [in.m4])
+
+dnl preserve m4exit's failure value
+AT_DATA([in.m4], [[hello world
+m4exit(`2')
 ]])
+AT_CHECK_M4([>&-], [2], [],
+[[m4: write error: Bad file descriptor
+]], [in.m4])
 
 dnl trace file must not collide with closed stdout
 AT_DATA([in.m4], [[hello world
+dnl
 ]])
-AT_CHECK_M4([--debugfile=trace in.m4 >&-], [1], [],
+AT_CHECK_M4([--debugfile=trace -tdnl >&-], [1], [],
 [[m4: write error: Bad file descriptor
+]], [in.m4])
+AT_CHECK([cat trace], [0], [[m4trace: -1- dnl
+]])
+
+dnl esyscmd always has valid stdout
+AT_DATA([in.m4], [[errprint(esyscmd(`echo hello'))dnl
+]])
+AT_CHECK_M4([>&-], [0], [], [[hello
+]], [in.m4])
+
+dnl syscmd inherits closed stdout
+AT_CHECK([cat >&- && { echo "skipping: can't detect closed stdout"; exit 77; 
}],
+[1], [], [stderr])
+mv stderr experr
+AT_DATA([in.m4], [[syscmd(`cat')dnl
+]])
+AT_CHECK_M4([>&-], [0], [], [experr], [in.m4])
+
+dnl command line input file must not collide with closed stdout
+AT_DATA([in.m4], [[syscmd(`cat <&1 >&2')
+dnl this line should not be read by cat
+]])
+AT_CHECK_M4([in.m4 >&-], [0], [], [stderr])
+AT_CHECK([sed -ne '/should not be read/p' stderr], [0])
+
+AT_CLEANUP
+
+
+## ----------- ##
+## stdout full ##
+## ----------- ##
+
+AT_SETUP([stdout full])
+AT_CHECK([test -w /dev/full && test -c /dev/full || {
+  echo "Skipping: no /dev/full support";
+  exit 77
+}])
+
+dnl detect write failures on --help
+AT_CHECK_M4([--help >/dev/full], [1], [],
+[[m4: write error: No space left on device
+]])
+
+dnl detect write failures on --version
+AT_CHECK_M4([--version >/dev/full], [1], [],
+[[m4: write error: No space left on device
+]])
+
+dnl detect ordinary write failures
+AT_DATA([in.m4], [[hello world
+]])
+AT_CHECK_M4([in.m4 >/dev/full], [1], [],
+[[m4: write error: No space left on device
+]])
+
+dnl detect stderr write failures
+AT_DATA([in.m4], [[dnl(hello world)
+]])
+AT_CHECK_M4([in.m4 2>/dev/full], [1])
+
+dnl detect trace write failures
+AT_DATA([in.m4], [[dnl
+]])
+AT_CHECK_M4([-tdnl in.m4 2>/dev/full], [1])
+
+dnl detect trace write failures
+AT_DATA([in.m4], [[dnl
+]])
+AT_CHECK_M4([--debugfile=/dev/full -tdnl in.m4], [1], [],
+[[m4: error writing to debug stream: No space left on device
+]])
+
+dnl too hard to test for spilled diversion failures, without requiring the
+dnl user to have a nearly full partition that we can assign to $TMPDIR.
+
+dnl write failures must override m4exit requesting 0
+AT_DATA([in.m4], [[hello world m4exit(`0')
+]])
+AT_CHECK_M4([in.m4 >/dev/full], [1], [],
+[[m4: write error: No space left on device
+]])
+
+dnl preserve m4exit's failure value
+AT_DATA([in.m4], [[hello world m4exit(`2')
+]])
+AT_CHECK_M4([in.m4 >/dev/full], [2], [],
+[[m4: write error: No space left on device
 ]])
-AT_CHECK([cat trace])
 
 AT_CLEANUP
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]