Patchwork libgo patch committed: Add external timeout to gotest script

login
register
mail settings
Submitter Ian Taylor
Date April 5, 2011, 9:11 p.m.
Message ID <mcrk4f8bdys.fsf@google.com>
Download mbox | patch
Permalink /patch/89929/
State New
Headers show

Comments

Ian Taylor - April 5, 2011, 9:11 p.m.
This patch to the gotest test script adds an external timeout, which
will kill a test if the internal timeout fails due to some problem in
the runtime.  This patch is imperfect in that it will leave a sleep
command around after the test is complete.  The sleep command will
eventually terminate and disappear, but it would be nicer if it were
killed sooner.  Unfortunately I don't see a convenient way to do that.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r 03d5aa32694e libgo/testsuite/gotest
--- a/libgo/testsuite/gotest	Tue Apr 05 12:52:06 2011 -0700
+++ b/libgo/testsuite/gotest	Tue Apr 05 14:04:59 2011 -0700
@@ -377,7 +377,20 @@ 
 xno)
 	${GC} -g -c _testmain.go
 	${GL} *.o ${GOLIBS}
-	./a.out -test.short -test.timeout=$timeout "$@"
+
+	./a.out -test.short -test.timeout=$timeout "$@" &
+	pid=$!
+	(sleep `expr $timeout + 10`
+	    echo > gotest-timeout
+	    echo "timed out in gotest" 1>&2
+	    kill -9 $pid) &
+	alarmpid=$!
+	wait $pid
+	status=$?
+	if ! test -f gotest-timeout; then
+	    kill $alarmpid
+	fi
+	exit $status
 	;;
 xyes)
 	rm -rf ../testsuite/*.o