[Swift-commit] r3635 - in trunk/tests: . language-behaviour

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Sep 21 15:57:47 CDT 2010


Author: wozniak
Date: 2010-09-21 15:57:47 -0500 (Tue, 21 Sep 2010)
New Revision: 3635

Added:
   trunk/tests/language-behaviour/066-many.setup.sh
   trunk/tests/language-behaviour/066-many.timeout
Modified:
   trunk/tests/language-behaviour/066-many.swift
   trunk/tests/nightly.sh
Log:
Process management improvements


Added: trunk/tests/language-behaviour/066-many.setup.sh
===================================================================
--- trunk/tests/language-behaviour/066-many.setup.sh	                        (rev 0)
+++ trunk/tests/language-behaviour/066-many.setup.sh	2010-09-21 20:57:47 UTC (rev 3635)
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -x
+
+touch nop || exit 1
+
+exit 0


Property changes on: trunk/tests/language-behaviour/066-many.setup.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/tests/language-behaviour/066-many.swift
===================================================================
--- trunk/tests/language-behaviour/066-many.swift	2010-09-21 19:00:46 UTC (rev 3634)
+++ trunk/tests/language-behaviour/066-many.swift	2010-09-21 20:57:47 UTC (rev 3635)
@@ -1,9 +1,12 @@
 
-app p()
+type file;
+
+app p(file f)
 {
-  touch "nop";
+  touch @f;
 }
 
 foreach i in [1:3000] {
-    p();
+  file f<"nop">;
+  p(f);
 }

Added: trunk/tests/language-behaviour/066-many.timeout
===================================================================
--- trunk/tests/language-behaviour/066-many.timeout	                        (rev 0)
+++ trunk/tests/language-behaviour/066-many.timeout	2010-09-21 20:57:47 UTC (rev 3635)
@@ -0,0 +1 @@
+600

Modified: trunk/tests/nightly.sh
===================================================================
--- trunk/tests/nightly.sh	2010-09-21 19:00:46 UTC (rev 3634)
+++ trunk/tests/nightly.sh	2010-09-21 20:57:47 UTC (rev 3635)
@@ -21,8 +21,11 @@
 
 # Each *.swift test may be accompanied by a
 # *.setup.sh, *.check.sh, and/or *.clean.sh script
-# These may setup and inspect files in RUNDIR including exec.out
+# and a *.timeout specifier
+# The scripts may setup and inspect files in RUNDIR including exec.out
 # The GROUP scripts can read the GROUP variable
+# The timeout number in the *.timeout file overrides the default
+# timeout
 
 # Tests are GROUPed into directories
 # Each GROUP directory has:
@@ -37,8 +40,20 @@
 # 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 -9 java
+# WARNING: On timeout, this script will call killall on java and sleep
 
+# All timeouts in this script are in seconds
+
+# PID TREE:
+# Background processes are used so that hung Swift jobs can be killed
+# These are the background processes (PIDs are tracked)
+# nightly.sh
+# +-monitor()
+#   +-sleep
+# +-process_exec()
+#   +-bin/swift
+#     +-java
+
 printhelp() {
   echo "nightly.sh <options> <output>"
   echo ""
@@ -56,6 +71,7 @@
 }
 
 # Defaults:
+DEFAULT_TIMEOUT=30 # seconds
 RUN_ANT=1
 CLEAN=1
 SKIP_TESTS=0
@@ -511,30 +527,43 @@
   TIMEOUT=$2 # seconds
   OUTPUT=$3
 
-  sleep $TIMEOUT
-  EXITCODE=1
+  V=$SWIFTCOUNT
 
-#   /bin/kill -TERM $PID
-#   KILLCODE=$?
-#   if [ $KILLCODE == 0 ]; then
-#     echo "monitor(): killed process (TERM)"
-#     sleep 1
-#   fi
+  # Use background so kill/trap is immediate
+  sleep $TIMEOUT &
+  SLEEP_PID=$!
+  trap "monitor_trap $SLEEP_PID $V" SIGTERM
+  wait $SLEEP_PID
+  [ $? != 0 ] && echo "monitor($V) cancelled" && return 0
+
   /bin/kill -TERM $PID
   KILLCODE=$?
   if [ $KILLCODE == 0 ]; then
-    echo "monitor(): killed process_exec (TERM)"
+    echo "monitor($V): killed process_exec (TERM)"
   fi
 
   sleep 1
-  MSG="nightly.sh: monitor(): killed: exceeded $TIMEOUT seconds"
+  MSG="nightly.sh: monitor($V): killed: exceeded $TIMEOUT seconds"
   echo "$MSG" >> $OUTPUT
+  trap
+  return 1
 }
 
+monitor_trap() {
+  SLEEP_PID=$1
+  V=$2
+  echo "monitor_trap($V)"
+  /bin/kill -9 $SLEEP_PID
+}
+
 # Execute given command line in background with monitor
 # Otherwise equivalent to test_exec()
+# usage: monitored_exec <TIMEOUT> <command> <args>*
 monitored_exec()
 {
+  TIMEOUT=$1
+  shift
+
   banner "$TEST (part $SEQ)"
   echo "Executing $TEST (part $SEQ)"
 
@@ -543,7 +572,7 @@
   process_exec "$@" &
   PROCESS_PID=$!
 
-  monitor $PROCESS_PID 30 $OUTPUT &
+  monitor $PROCESS_PID $TIMEOUT $OUTPUT &
   MONITOR_PID=$!
 
   wait $PROCESS_PID
@@ -553,6 +582,7 @@
 
   # If EXITCODE != 0, monitor() may have work to do
   (( $EXITCODE != 0 )) && sleep 5
+  echo "Killing monitor..."
   /bin/kill -TERM $MONITOR_PID
 
   echo "TOOK: $(( STOP-START ))"
@@ -587,6 +617,7 @@
   SETUPSCRIPT=${SWIFTSCRIPT%.swift}.setup.sh
   CHECKSCRIPT=${SWIFTSCRIPT%.swift}.check.sh
   CLEANSCRIPT=${SWIFTSCRIPT%.swift}.clean.sh
+  TIMEOUTFILE=${SWIFTSCRIPT%.swift}.timeout
   if [ -x $GROUP/$SETUPSCRIPT ]; then
     script_exec $GROUP/$SETUPSCRIPT "S"
   fi
@@ -596,10 +627,13 @@
 
   (( SWIFTCOUNT++ ))
 
-  monitored_exec swift -wrapperlog.always.transfer true \
-                       -config swift.properties \
-                       -sites.file sites.xml \
-                       -tc.file tc.data \
+  TIMEOUT=$( gettimeout $GROUP/$TIMEOUTFILE )
+
+  monitored_exec $TIMEOUT swift                         \
+                       -wrapperlog.always.transfer true \
+                       -config swift.properties         \
+                       -sites.file sites.xml            \
+                       -tc.file tc.data                 \
                        $CDM $SWIFTSCRIPT
 
   if [ -x $GROUP/$CHECKSCRIPT ]; then
@@ -610,6 +644,18 @@
   fi
 }
 
+# All timeouts in this script are in seconds
+gettimeout() {
+  FILE=$1
+
+  if [ -f $FILE ]; then
+    cat $FILE
+  else
+    echo $DEFAULT_TIMEOUT
+  fi
+  return 0
+}
+
 ssexec() {
   SEQSAVE=$SEQ
   SEQ=$1




More information about the Swift-commit mailing list