[Swift-commit] r3664 - trunk/tests

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Thu Oct 7 15:22:24 CDT 2010


Author: wozniak
Date: 2010-10-07 15:22:23 -0500 (Thu, 07 Oct 2010)
New Revision: 3664

Modified:
   trunk/tests/nightly.sh
Log:
Better process mgmt


Modified: trunk/tests/nightly.sh
===================================================================
--- trunk/tests/nightly.sh	2010-10-07 17:49:18 UTC (rev 3663)
+++ trunk/tests/nightly.sh	2010-10-07 20:22:23 UTC (rev 3664)
@@ -42,8 +42,6 @@
 # stdout.txt retains stdout from the previous test (for *.clean.sh)
 # output_*.txt is the HTML-linked permanent output from a test
 
-# WARNING: On timeout, this script will call killall on java and sleep
-
 # All timeouts in this script are in seconds
 
 # PID TREE:
@@ -544,9 +542,24 @@
   EXEC_PID=$1
   echo "process_exec_trap()"
   kill -KILL $EXEC_PID
-  # killall -9 java
+  killall_swift
 }
 
+# Kill all subordinate swift/java processes
+killall_swift() {
+  echo "killing all swifts..."
+  set -x
+  echo $$
+  ps -f
+  kill_this $( ps -f | grep $$'.*'java  | grep -v grep )
+  set +x
+}
+
+# Kill a process given its line output from "ps -f"
+kill_this() {
+  [ -n $2 ] && /bin/kill -KILL $2
+}
+
 # Execute as part of test set
 # Equivalent to monitored_exec() (but w/o monitoring)
 test_exec() {
@@ -585,11 +598,15 @@
   wait $SLEEP_PID
   [ $? != 0 ] && verbose "monitor($V) cancelled" && return 0
 
-  echo "monitor($V): killing test process..."
-  /bin/kill -TERM $PID
-  KILLCODE=$?
-  if [ $KILLCODE == 0 ]; then
-    echo "monitor($V): killed process_exec (TERM)"
+  if ps | grep $PID
+  then
+    echo "monitor($V): killing test process..."
+    touch killed_test
+    /bin/kill -TERM $PID
+    KILLCODE=$?
+    if [ $KILLCODE == 0 ]; then
+      echo "monitor($V): killed process_exec (TERM)"
+    fi
   fi
 
   sleep 1
@@ -602,7 +619,8 @@
 monitor_trap() {
   SLEEP_PID=$1
   V=$2
-  /bin/kill -9 $SLEEP_PID
+  verbose "monitor_trap(): kill sleep"
+  /bin/kill -KILL $SLEEP_PID
 }
 
 # Execute given command line in background with monitor
@@ -629,8 +647,8 @@
 
   STOP=$( date +%s )
 
-  # If EXITCODE != 0, monitor() may have work to do
-  (( $EXITCODE != 0 )) && sleep 5
+  # If the test was killed, monitor() may have work to do
+  rm killed_test && sleep 5
   verbose "Killing monitor..."
   /bin/kill -TERM $MONITOR_PID
 
@@ -877,9 +895,6 @@
 
 SKIP_COUNTER=0
 
-# GROUPLIST=( $TESTDIR/functions $TESTDIR/local $TESTDIR/cdm $TESTDIR/cdm/star  )
-# $TESTDIR/cdm/ps/pinned
-
 GROUPLIST=( $TESTDIR/language-behaviour
             $TESTDIR/language/working \
             $TESTDIR/local \




More information about the Swift-commit mailing list