Subject: Re: bug#8788: Weird testsuite failure on NetBSD (parallel tests, background processes)

From: Stefano Lattarini <[email-masked]>
Date: Tue, 18 Oct 2011 23:32:35 +0200

[Dropping bug-autoconf from CC]
[Adding automake-patches to CC]

On Tuesday 18 October 2011, Stefano Lattarini wrote:
> Reference:
>  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8788>
> 
> On Thursday 02 June 2011, Stefano Lattarini wrote:
> > While teststing the `testsuite-work' branch on NetBSD 5, I've encountered
> > a weird failure in the test `parallel-tests3.test', which actually caused
> > the whole testsuite to crash (!) due to a stray SIGTERM.
> > 
> > [SNIP]
> > 
> > Any idea of what's going on?
> > 
> Ah ah, got it! (I think).  The failure is due to an interaction between some
> features of GNU make and some (mis)features the NetBSD Korn Shell.
>
> [SNIP]
> 
> Now, the right fix for the bug is *not* to work around this behaviour
> of the Korn shell; rather, we should fix the suspicious logic of the
> `parallel-tests3.test' script, which was also causing a testsuite hang
> on FreeBSD.  Patch coming up shortly.
> 
And here is the promised patch (see attachement).  I will allow a couple of
days for reviews before pushing.

Regards,
  Stefano
From f5b69b8a0d787cf798653fdb975affa9e7ff44b8 Mon Sep 17 00:00:00 2001
Message-Id: <f5b69b8a0[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Tue, 18 Oct 2011 21:05:24 +0200
Subject: [PATCH] tests: avoid spurious failure in 'parallel-tests3.test'

This fixes automake bug#8788.

* tests/parallel-tests3.test: To ensure that the serial run of
the dummy testsuite is still ongoing when the parallel run has
terminated, use `kill -0', not a bare `kill'.  This will prevent
a testsuite crash on NetBSD 5.1, and a testsuite hang on FreeBSD
8.2.  Also, since we are at it, try harder to avoid possible
hangs of the script in other unusual situations.
---
 ChangeLog                  |   11 +++++++++++
 tests/parallel-tests3.test |   19 +++++++++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a2ecefc..9ed30f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-10-18  Stefano Lattarini  <[email-masked]>
+
+	tests: avoid spurious failure in 'parallel-tests3.test'
+	This fixes automake bug#8788.
+	* tests/parallel-tests3.test: To ensure that the serial run of
+	the dummy testsuite is still ongoing when the parallel run has
+	terminated, use `kill -0', not a bare `kill'.  This will prevent
+	a testsuite crash on NetBSD 5.1, and a testsuite hang on FreeBSD
+	8.2.  Also, since we are at it, try harder to avoid possible
+	hangs of the script in other unusual situations.
+
 2011-10-17  Stefano Lattarini  <[email-masked]>
 
 	tests: fix spurious failure with autoconf 2.62
diff --git a/tests/parallel-tests3.test b/tests/parallel-tests3.test
index a138f90..69ba1d0 100755
--- a/tests/parallel-tests3.test
+++ b/tests/parallel-tests3.test
@@ -70,15 +70,22 @@ $sleep
 : >stdout
 $MAKE -j4 check >> stdout
 cd ..
-kill $!
+# Ensure the tests are really being run in parallel mode: if this is
+# the case, the serial run of the dummy testsuite started above should
+# still be ongoing when the parallel one has terminated.
+kill -0 $!
 cat parallel/stdout
 test `grep -c PASS parallel/stdout` -eq 8
 
-# Wait long enough so that there are no open files any more
-# when the post-test cleanup runs.
-while test ! -f serial/test-suite.log
-do
-  $sleep
+# Wait long enough so that there are no open files any more when the
+# post-test cleanup runs.  But exit after we've waited for two minutes
+# or more, to avoid testsuite hangs in unusual situations (this has
+# already happened).
+i=1
+while test ! -f serial/test-suite.log && test $i -le 120; do
+  i=`expr $i + 1`
+  sleep '1' # Extra quoting to please maintainer-check.
 done
 $sleep
+
 :
-- 
1.7.3.5