From 9c0e333ce19b9c3778badab75ead275a4b25dfbc Mon Sep 17 00:00:00 2001
From: Michael Wetherell <mike.wetherell@ntlworld.com>
Date: Sun, 18 Apr 2010 17:19:06 +0000
Subject: [PATCH] Try to provide backtraces on unix buildbots if the test
 program crashes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64034 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 build/buildbot/config/include/defs.xml | 33 ++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/build/buildbot/config/include/defs.xml b/build/buildbot/config/include/defs.xml
index 5b854d5aee..fc251c3122 100644
--- a/build/buildbot/config/include/defs.xml
+++ b/build/buildbot/config/include/defs.xml
@@ -335,7 +335,8 @@
 -->
 <xsl:template name="run-tests">
     <xsl:param name="content"/>
-    <xsl:param name="options"/>
+    <xsl:param name="options" select="'-t'"/>
+    <xsl:param name="guioptions" select="$options"/>
     <xsl:param name="msw"><is-msw/></xsl:param>
     <test>
         <defaults content="{$content}">
@@ -347,10 +348,10 @@
             <command>
                 <xsl:choose>
                     <xsl:when test="$msw = 'true'">
-                        <run-tests-win options="{$options}"/>
+                        <run-tests-win options="{$options}" guioptions="{$guioptions}"/>
                     </xsl:when>
                     <xsl:otherwise>
-                        <run-tests-unix options="{$options}"/>
+                        <run-tests-unix options="{$options}" guioptions="{$guioptions}"/>
                     </xsl:otherwise>
                 </xsl:choose>
             </command>
@@ -360,6 +361,7 @@
 
 <xsl:template name="run-tests-win">
     <xsl:param name="options"/>
+    <xsl:param name="guioptions"/>
 <normalize-space>
 cd tests &amp;&amp; runtests.bat
 </normalize-space>
@@ -367,10 +369,31 @@ cd tests &amp;&amp; runtests.bat
 
 <xsl:template name="run-tests-unix">
     <xsl:param name="options"/>
+    <xsl:param name="guioptions"/>
 ERR=0
 cd tests || exit 0
-./test <xsl:value-of select="normalize-space($options)"/> || ERR=$?
-if [ -n "$DISPLAY" -a -x test_gui ]; then ./test_gui || ERR=$?; fi
+ulimit -c unlimited
+
+try()
+{
+    rm -f core
+    echo Running: "$@"
+    "$@" || ERR=$?
+
+    if [ -f core -a -x "`which gdb`" ]; then
+        echo Crashed, attempting to display backtrace:
+        gdb -batch -c core -ex 'set pagination off' -ex bt "$1"
+    fi
+
+    echo
+}
+
+try ./test <xsl:value-of select="normalize-space($options)"/>
+
+if [ -n "$DISPLAY" -a -x test_gui ]; then
+    try ./test_gui <xsl:value-of select="normalize-space($guioptions)"/>
+fi
+
 exit $ERR
 </xsl:template>
 
-- 
2.45.2