Subject: bug#8846: coreutils-8.12 on HP-UX 11.31: 3 of 365 tests failed

From: Stefano Lattarini <[email-masked]>
Date: Tue, 14 Jun 2011 10:33:17 +0200

On Tuesday 14 June 2011, Jim Meyering wrote:
> Here's what I expect to do for coreutils,
> along with an advice-update for gnulib's init.sh:
>
Thanks, I'll apply something similar to automake `tests/defs' soonish.
I have a doubt below, tough (see near the end).

> From e948173c1c461aac9f1c490061b257f55e42608d Mon Sep 17 00:00:00 2001
> From: Jim Meyering <[email-masked]>
> Date: Tue, 14 Jun 2011 09:59:14 +0200
> Subject: [PATCH] tests: accommodate HP-UX and Solaris shells
> 
> Running "make check" normally prints a diagnostic to the outermost
> stderr (usually a tty) to explain why a test is skipped.  It did this
> by redirecting FD 9 to stderr (via "exec 9>&2") before invoking the
> shell script.  Shell scripts write skip-explanation to FD 9 via
> init.sh's skip_ function.  However, with Solaris 10's ksh and HP-UX,
> the effects of "exec 9>&2" are canceled upon fork-and-exec,
>
BTW, this is true also for the default ksh on Debian GNU/Linux (but
note that this is just a "trivia fact", since on GNU/Linux basically
everybody uses either bash or dash as the non-interactive shell of
choice).

> so we would get a "Bad file number" diagnostic and no skip explanation
> on those systems.
> * tests/check.mk (TESTS_ENVIRONMENT): Redirect more portably, via
> $(SHELL) "$$1" 9>&2, rather than the prior
> exec 9>&2; $(SHELL) ...
> Actually, we use "shell_or_perl_ 9>&2", to make this effective
> also for the perl-based tests.
> * tests/init.sh (stderr_fileno_): Update the advice in comments.
> See http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22488
> for lots of discussion.  Stefano Lattarini suggested the solution
> of putting "9>&2" after the command.  Reported by Bruno Haible.
> ---
>  tests/check.mk |    3 +--
>  tests/init.sh  |    4 ++--
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/check.mk b/tests/check.mk
> index db7f067..9db96af 100644
> --- a/tests/check.mk
> +++ b/tests/check.mk
> @@ -58,7 +58,6 @@ TESTS_ENVIRONMENT =				\
>    test -d "$$tmp__" && test -w "$$tmp__" || tmp__=.;	\
>    . $(srcdir)/envvar-check;			\
>    TMPDIR=$$tmp__; export TMPDIR;		\
> -  exec 9>&2;					\
>    shell_or_perl_() {				\
>      if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then			\
>        if $(PERL) -e 'use warnings' > /dev/null 2>&1; then		\
> @@ -100,6 +99,6 @@ TESTS_ENVIRONMENT =				\
>    REPLACE_GETCWD=$(REPLACE_GETCWD)		\
>    ; test -d /usr/xpg4/bin && PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'"$$PATH"; \
>    PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
> -  ; shell_or_perl_
> +  ; shell_or_perl_ 9>&2
> 
>  VERBOSE = yes
> diff --git a/tests/init.sh b/tests/init.sh
> index 60d1bc1..a769d8b 100644
> --- a/tests/init.sh
> +++ b/tests/init.sh
> @@ -68,8 +68,8 @@ Exit () { set +e; (exit $1); exit $1; }
> 
>  # Print warnings (e.g., about skipped and failed tests) to this file number.
>  # Override by defining to say, 9, in init.cfg, and putting say,
> -# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition
> -# of TESTS_ENVIRONMENT in your tests/Makefile.am file.
> +#   export ...ENVVAR_SETTINGS...; $(SHELL) "$$1" 9>&2
>
What is this `$$1' here for?

> +# in the definition of TESTS_ENVIRONMENT in your tests/Makefile.am file.
>  # This is useful when using automake's parallel tests mode, to print
>  # the reason for skip/failure to console, rather than to the .log files.
>  : ${stderr_fileno_=2}
> --
> 1.7.6.rc0.293.g40857
> 

Regards,
  Stefano