m4-patches
[Top][All Lists]
Advanced

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

portability patch


From: Eric Blake
Subject: portability patch
Date: Tue, 27 May 2008 23:13:35 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

I fixed a couple of testsuite bugs on the master branch that I noticed on a 
static OpenBSD build and a shared Solaris 8 build.  This also fixes a problem 
with nested configure output when not using gmp.

I was unable to get a shared build on OpenBSD - the compiler complained that it 
was unable to find -ltraditional (even though libtool passed -Lmodules/.libs, 
and both modules/.libs/traditional.{a,so.0.0} existed).  I'm not sure if it 
might be a libtool bug, or just a Makefile.am usage bug (creating the library 
without a 'lib' prefix in its name), but I'll follow up on the libtool list 
with more details.

Getting the testsuite to work on Solaris proved rather interesting.  For 
starters, Solaris defaults to compiling system(2) to use /bin/sh rather 
than /usr/xpg4/bin/sh (ksh), but their /bin/sh is broken when it comes to 
detecting attempts to duplicate a closed fd.  We could force xpg behavior by 
linking with /usr/ccs/lib/values-xpg4.o (which defines the single variable 
__xpg4), and that would solve several testsuite skips.  I've got an open thread 
on the gnulib list trying to figure out whether this is worth pursuing.

Additionally, Solaris /bin/sh reopens stdin as /dev/null if it detects that 
stdin was closed at startup; even though /bin/sh is not setuid (this violates 
POSIX, since POSIX states that only setuid apps can reopen an otherwise closed 
stdin, but who expected anything less considering Solaris /bin/sh doesn't aim 
for POSIX compliance).  This has the interesting effect 'make install-check' 
succeeds on the 'stdin closed' test because the binary is invoked directly, 
but 'make check' skips the same test since it goes through the shell script 
wrapper tests/m4 that happens to "adjust" an inherited closed stdin.


>From a858ceb9ba54912fce6ab53706c719385e41f415 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 27 May 2008 10:57:01 -0600
Subject: [PATCH] Support 'make dist' with BSD make.

* Makefile.am (TESTSUITE_AT, MAINTAINERCLEANFILES): Qualify uses
of the generated file tests/generated.at.
(EXTRA_DIST, $(TESTSUITE)): Likewise for tests/package.m4.
* tests/others.at (stdout closed): Accomodate OpenBSD /bin/sh.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog       |    8 ++++++++
 Makefile.am     |    8 ++++----
 tests/others.at |    2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7041635..0a12e77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-27  Eric Blake  <address@hidden>
+
+       Support 'make dist' with BSD make.
+       * Makefile.am (TESTSUITE_AT, MAINTAINERCLEANFILES): Qualify uses
+       of the generated file tests/generated.at.
+       (EXTRA_DIST, $(TESTSUITE)): Likewise for tests/package.m4.
+       * tests/others.at (stdout closed): Accomodate OpenBSD /bin/sh.
+
 2008-05-24  Eric Blake  <address@hidden>
 
        Test NUL in frozen files.
diff --git a/Makefile.am b/Makefile.am
index 7606802..1548051 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -359,7 +359,7 @@ TESTSUITE = $(srcdir)/tests/testsuite
 TESTSUITE_AT   = \
                  tests/builtins.at \
                  tests/freeze.at \
-                 tests/generated.at \
+                 $(srcdir)/tests/generated.at \
                  tests/macros.at \
                  tests/modules.at \
                  tests/options.at \
@@ -369,7 +369,7 @@ TESTSUITE_AT        = \
 EXTRA_DIST     += $(TESTSUITE) $(TESTSUITE_AT) $(OTHER_FILES) \
                  tests/atlocal.in \
                  tests/generate.awk \
-                 tests/package.m4
+                 $(srcdir)/tests/package.m4
 
 # Be sure to reexport important environment variables:
 TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
@@ -391,7 +391,7 @@ $(srcdir)/tests/generated.at: tests/generate.awk 
$(m4_texinfo)
 
 AUTOM4TE = autom4te
 AUTOTEST = $(AUTOM4TE) --language=autotest
-$(TESTSUITE): tests/package.m4 $(TESTSUITE_AT)
+$(TESTSUITE): $(srcdir)/tests/package.m4 $(TESTSUITE_AT)
        $(AUTOTEST) -I '$(srcdir)/tests' -o address@hidden address@hidden
        mv address@hidden $@
 
@@ -436,6 +436,6 @@ OTHER_FILES = tests/iso8859.m4 tests/stackovf.test \
                tests/null.m4 tests/null.out tests/null.err
 
 DISTCLEANFILES += tests/atconfig tests/atlocal tests/m4
-MAINTAINERCLEANFILES += tests/generated.at '$(TESTSUITE)'
+MAINTAINERCLEANFILES += $(srcdir)/tests/generated.at '$(TESTSUITE)'
 
 clean-local: clean-local-tests
diff --git a/tests/others.at b/tests/others.at
index 68d58a3..5424131 100644
--- a/tests/others.at
+++ b/tests/others.at
@@ -704,7 +704,7 @@ AT_DATA([in.m4], [[syscmd(`cat <&1 >&2')dnl
 dnl this line should not be read by cat
 ]])
 AT_CHECK_M4([in.m4 >&-], [0], [], [stderr])
-AT_CHECK([sed -e 's/.*\(Bad file descriptor\)$/\1/' stderr], [0],
+AT_CHECK([[sed -e 's/.*[Bb]\(ad file descriptor\)$/B\1/' stderr]], [0],
 [[Bad file descriptor
 ]])
 
-- 
1.5.5.1


>From 619ee3771a036189a4a2a7372062d7bb6351a0f2 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 27 May 2008 13:59:24 -0600
Subject: [PATCH] Fix configure message nesting, broken since 2001-09-20.

* ltdl/m4/gmp.m4 (M4_LIB_GMP): Don't cache result; the test is
not expensive, and AC_MSG_WARN doesn't work in AC_CACHE_CHECK.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog      |    4 ++++
 ltdl/m4/gmp.m4 |    9 ++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0a12e77..2714351 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-05-27  Eric Blake  <address@hidden>
 
+       Fix configure message nesting, broken since 2001-09-20.
+       * ltdl/m4/gmp.m4 (M4_LIB_GMP): Don't cache result; the test is
+       not expensive, and AC_MSG_WARN doesn't work in AC_CACHE_CHECK.
+
        Support 'make dist' with BSD make.
        * Makefile.am (TESTSUITE_AT, MAINTAINERCLEANFILES): Qualify uses
        of the generated file tests/generated.at.
diff --git a/ltdl/m4/gmp.m4 b/ltdl/m4/gmp.m4
index c468d7c..38e2524 100644
--- a/ltdl/m4/gmp.m4
+++ b/ltdl/m4/gmp.m4
@@ -1,5 +1,6 @@
 ## -*- Autoconf -*-
-## Copyright (C) 2000, 2001, 2003, 2006, 2007 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001, 2003, 2006, 2007, 2008 Free Software
+## Foundation, Inc.
 ##
 ## This file is part of GNU M4.
 ##
@@ -16,7 +17,7 @@
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# serial 9
+# serial 10
 
 m4_define([_M4_LIB_GMP],
 [AC_ARG_WITH([gmp],
@@ -64,9 +65,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_GMP_H
 LIBS=$M4_gmp_save_LIBS
 AC_SUBST([LIBADD_GMP])
 
-AC_CACHE_CHECK([if using GNU multiple precision arithmetic library],
-              [M4_cv_using_lib_gmp],
-              [_M4_LIB_GMP])
+_M4_LIB_GMP
 
 # Don't try to link in libgmp if we are not using it after the last call
 if test "$M4_cv_using_lib_gmp" = yes; then
-- 
1.5.5.1


>From 19b3394db9c5c2f7087b5398a2319981d3f3544f Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 27 May 2008 16:38:42 -0600
Subject: [PATCH] Fix some testsuite failures on Solaris 8.

* tests/builtins.at (esyscmd, syscmd): Skip tests if system(2) is
broken.
* tests/others.at (stderr closed): Likewise.  Also support Solaris
wording for EBADF.
(stdin closed): Skip test if closed stdin gets reopened.
(stdout closed): Support Solaris wording for EBADF.
* tests/testsuite.at (AT_CHECK_M4): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog          |    9 +++++++++
 tests/builtins.at  |    8 ++++++--
 tests/others.at    |   30 +++++++++++++++++++++++++-----
 tests/testsuite.at |    5 +++++
 4 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2714351..b0f13a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-05-27  Eric Blake  <address@hidden>
 
+       Fix some testsuite failures on Solaris 8.
+       * tests/builtins.at (esyscmd, syscmd): Skip tests if system(2) is
+       broken.
+       * tests/others.at (stderr closed): Likewise.  Also support Solaris
+       wording for EBADF.
+       (stdin closed): Skip test if closed stdin gets reopened.
+       (stdout closed): Support Solaris wording for EBADF.
+       * tests/testsuite.at (AT_CHECK_M4): Likewise.
+
        Fix configure message nesting, broken since 2001-09-20.
        * ltdl/m4/gmp.m4 (M4_LIB_GMP): Don't cache result; the test is
        not expensive, and AC_MSG_WARN doesn't work in AC_CACHE_CHECK.
diff --git a/tests/builtins.at b/tests/builtins.at
index 3f67c2c..198a25d 100644
--- a/tests/builtins.at
+++ b/tests/builtins.at
@@ -437,7 +437,9 @@ hostname = >>www<<
 ]])
 
 dnl Ensure that esyscmd does not inherit any unnecessary fds from trace.
-AT_DATA([in.m4], [[esyscmd(`echo hi >&3')dnl
+AT_DATA([in.m4], [[esyscmd(`echo hi >&3')ifelse(sysval,
+`0', `skipping: sh cannot detect closed fds
+m4exit(`77')')dnl
 ]])
 AT_CHECK_M4([3>&-], [0], [], [stderr], [in.m4])
 mv stderr experr
@@ -1104,7 +1106,9 @@ AT_CLEANUP
 AT_SETUP([syscmd])
 
 dnl Ensure that syscmd does not inherit any unnecessary fds from trace.
-AT_DATA([in.m4], [[syscmd(`echo hi >&3')dnl
+AT_DATA([in.m4], [[syscmd(`echo hi >&3')ifelse(sysval,
+`0', `skipping: sh cannot detect closed fds
+m4exit(`77')')dnl
 ]])
 AT_CHECK_M4([3>&-], [0], [], [stderr], [in.m4])
 mv stderr experr
diff --git a/tests/others.at b/tests/others.at
index 5424131..3468044 100644
--- a/tests/others.at
+++ b/tests/others.at
@@ -488,6 +488,11 @@ goodbye
 ]])
 
 dnl command line input file must not collide with closed stderr
+AT_DATA([in.m4], [[syscmd(`echo <&2')ifelse(sysval,
+`0', `skipping: sh cannot detect closed fds
+m4exit(`77')')
+]])
+AT_CHECK_M4([2>&-], [0], [ignore], [ignore], [in.m4])
 AT_DATA([in.m4], [[syscmd(`cat <&2')sysval
 dnl this line should not be read by cat
 ]])
@@ -514,6 +519,17 @@ AT_DATA([in.m4], [[hello world
 AT_CHECK_M4([in.m4], [0], [[hello world
 ]], [], [-])
 
+dnl Some systems reopen closed stdin to /dev/null, particularly when using
+dnl the shell script tests/m4 instead of a binary src/m4.
+AT_CHECK([cat <&- && { echo "skipping: can't detect closed stdin"; exit 77; }],
+[1], [], [stderr])
+mv stderr experr
+AT_DATA([in.m4], [[syscmd(`cat')ifelse(sysval,
+`0', `skipping: unable to start with closed stdin
+m4exit(`77')')
+]])
+AT_CHECK_M4([in.m4], [0], [ignore], [ignore], [-])
+
 dnl error when stdin must be read
 AT_CHECK_M4([], [1], [],
 [[m4:stdin:1: error reading file `stdin'
@@ -527,6 +543,8 @@ m4: error closing file: Bad file descriptor
 ]], [-])
 
 dnl error once per command-line attempt to read stdin
+AT_DATA([in.m4], [[hello world
+]])
 AT_CHECK_M4([- in.m4 -], [1], [[hello world
 ]], [[m4:stdin:1: error reading file `stdin'
 m4:stdin:1: error reading file `stdin'
@@ -534,9 +552,6 @@ m4: error closing file: Bad file descriptor
 ]], [-])
 
 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], [-])
@@ -687,7 +702,7 @@ AT_DATA([hi], [[hi
 ]])
 AT_CHECK([cat hi >&- && { echo "skipping: can't detect closed stdout"; exit 
77; }],
 [1], [], [stderr])
-mv stderr experr
+AT_CHECK([sed 's/Bad file number/Bad file descriptor/' < stderr > experr])
 AT_DATA([in.m4], [[syscmd(`cat hi')dnl
 ]])
 AT_CHECK_M4([>&-], [0], [], [experr], [in.m4])
@@ -700,6 +715,11 @@ divert(`-1')undivert
 AT_CHECK_M4([>&-], [0], [], [experr], [in.m4])
 
 dnl command line input file must not collide with closed stdout
+AT_DATA([in.m4], [[syscmd(`echo <&2')ifelse(sysval,
+`0', `skipping: sh cannot detect closed fds
+m4exit(`77')')
+]])
+AT_CHECK_M4([2>&-], [0], [ignore], [ignore], [in.m4])
 AT_DATA([in.m4], [[syscmd(`cat <&1 >&2')dnl
 dnl this line should not be read by cat
 ]])
@@ -717,7 +737,7 @@ AT_CLEANUP
 
 AT_SETUP([stdout full])
 AT_CHECK([test -w /dev/full && test -c /dev/full || {
-  echo "Skipping: no /dev/full support";
+  echo "skipping: no /dev/full support";
   exit 77
 }])
 
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 60d8612..b510e96 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -57,6 +57,10 @@ fi]])
 # or m4.exe:file:line: message
 # to m4:file:line
 #
+# When testing closed file descriptors, the message is platform-dependent:
+#    m4: error closing file: Bad file number
+# to m4: error closing file: Bad file descriptor
+#
 # When tracing modules, the module name is platform-dependent:
 #    m4debug: module gnu: opening file `gnu.so'
 # or m4debug: module gnu: opening file `gnu.a'
@@ -74,6 +78,7 @@ m4_case([$4], [], [], [ignore], [],
 [AT_CHECK([[sed 's/^[^:]*[lt-]*m4[.ex]*:/m4:/
        /^m4debug: module/s/opening file.*/opening file/
        s/\(cannot open module [^:]*\):.*/\1/
+       s/Bad file number/Bad file descriptor/
     ' stderr >&2]], [0], [], [$4])])
 ])
 
-- 
1.5.5.1







reply via email to

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