[Swift-commit] r4215 - trunk/tests

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Wed Mar 23 09:58:10 CDT 2011


Author: wozniak
Date: 2011-03-23 09:58:09 -0500 (Wed, 23 Mar 2011)
New Revision: 4215

Modified:
   trunk/tests/nightly.sh
Log:
Minor improvements to nightly.sh


Modified: trunk/tests/nightly.sh
===================================================================
--- trunk/tests/nightly.sh	2011-03-23 08:34:53 UTC (rev 4214)
+++ trunk/tests/nightly.sh	2011-03-23 14:58:09 UTC (rev 4215)
@@ -194,6 +194,13 @@
 
 TESTCOUNT=0
 
+# PIDs to kill if nightly.sh is killed:
+PROCESS_PID=
+MONITOR_PID=
+
+# When true, we should exit:
+SHUTDOWN=0
+
 echo "RUNNING_IN:  $RUNDIR"
 echo "HTML_OUTPUT: $HTML"
 
@@ -233,6 +240,14 @@
   return 0
 }
 
+shutdown_trap() {
+  SHUTDOWN=1
+  printf "\n\nshutdown_trap... $MONITOR_PID $PROCESS_PID\n\n"
+  ps -f
+  kill -INT $MONITOR_PID
+  kill -INT $PROCESS_PID
+}
+
 header() {
   CURRENT=$SCRIPTDIR/html/current.html
   sed "s at _HTMLBASE_@$HTMLPATH@" < $CURRENT > $TOPDIR/current.html
@@ -575,7 +590,7 @@
   "$@" > $OUTPUT 2>&1 &
   EXEC_PID=$!
 
-  trap "process_exec_trap $EXEC_PID" SIGTERM
+  trap "process_exec_trap $EXEC_PID" SIGTERM SIGINT
 
   wait $EXEC_PID
   EXITCODE=$?
@@ -594,9 +609,11 @@
 # Rationale: Killing bin/swift does not kill the Swift java process
 process_exec_trap() {
   EXEC_PID=$1
-  echo "process_exec_trap()"
-  kill -KILL $EXEC_PID
-  killall_swift
+  ps -f
+  echo "process_exec_trap($EXEC_PID)"
+  kill -TERM $EXEC_PID
+  ps -f
+  # killall_swift
 }
 
 # Kill all subordinate swift/java processes
@@ -663,15 +680,15 @@
   # Use background so kill/trap is immediate
   sleep $TIMEOUT > /dev/null 2>&1 &
   SLEEP_PID=$!
-  trap "monitor_trap $SLEEP_PID $V > /dev/null 2>&1" SIGTERM
+  trap "monitor_trap $SLEEP_PID" SIGTERM SIGINT
   wait $SLEEP_PID
   [ $? != 0 ] && verbose "monitor($V) cancelled" && return 0
 
   if ps | grep $PID
   then
-    echo "monitor($V): killing test process..."
+    echo "monitor($V): killing test process $PID"
     touch killed_test
-    /bin/kill -TERM $PID
+    /bin/kill -INT $PID
     KILLCODE=$?
     if [ $KILLCODE == 0 ]; then
       echo "monitor($V): killed process_exec (TERM)"
@@ -687,9 +704,8 @@
 
 monitor_trap() {
   SLEEP_PID=$1
-  V=$2
-  verbose "monitor_trap(): kill sleep"
-  /bin/kill -KILL $SLEEP_PID
+  echo "monitor_trap(SLEEP_PID)..."
+  /bin/kill -INT $SLEEP_PID
 }
 
 # Execute given command line in background with monitor
@@ -707,9 +723,11 @@
 
   process_exec "$@" &
   PROCESS_PID=$!
+  echo PROCESS_PID: $PROCESS_PID
 
   monitor $PROCESS_PID $TIMEOUT $OUTPUT &
   MONITOR_PID=$!
+  echo MONITOR_PID: $MONITOR_PID
 
   wait $PROCESS_PID
   EXITCODE=$?
@@ -718,8 +736,8 @@
 
   # If the test was killed, monitor() may have work to do
   rm killed_test > /dev/null 2>&1 && sleep 5
-  verbose "Killing monitor..."
-  /bin/kill -TERM $MONITOR_PID
+  echo "Killing monitor..."
+  /bin/kill -INT $MONITOR_PID
 
   echo "TOOK: $(( STOP-START ))"
 
@@ -963,6 +981,7 @@
     for (( i=0; $i<$ITERS_LOCAL; i=$i+1 )); do
       swift_test_case $TESTNAME
       (( $TESTCOUNT >= $NUMBER_OF_TESTS )) && return
+      (( $SHUTDOWN )) && return
     done
     end_row
   done
@@ -981,6 +1000,7 @@
     for ((i=0; $i<$ITERS_LOCAL; i=$i+1)); do
       script_test_case $TESTNAME
       (( $TESTCOUNT >= $NUMBER_OF_TESTS )) && return
+      (( $SHUTDOWN )) && return
     done
     end_row
   done
@@ -1054,6 +1074,8 @@
   EXITONFAILURE=false
 fi
 
+trap "shutdown_trap" SIGINT SIGTERM
+
 SKIP_COUNTER=0
 
 GROUPCOUNT=1
@@ -1064,6 +1086,7 @@
   test_group
   (( GROUPCOUNT++ ))
   (( $TESTCOUNT >= $NUMBER_OF_TESTS )) && break
+  (( $SHUTDOWN )) && break
 done
 
 if [ $GRID_TESTS == "0" ]; then




More information about the Swift-commit mailing list