summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrun.sh31
-rwxr-xr-xscript/dotnet-pending-clrtest-killer.sh92
2 files changed, 117 insertions, 6 deletions
diff --git a/run.sh b/run.sh
index 9be6100..56ecd9c 100755
--- a/run.sh
+++ b/run.sh
@@ -3,19 +3,21 @@
usage()
{
echo "Usage: $0 --device=[name]"
- echo "--device - You can get the name by using 'sdb devices' command"
- echo "--prefix-dir - You can specify the prefix directory for performing the unittest"
- echo " like /opt/usr/coreclr-tc"
- echo " Default is '/opt/usr/coreclr-tc'."
+ echo "--device - You can get the name by using 'sdb devices' command"
+ echo "--prefix-dir - You can specify the prefix directory for performing the unittest"
+ echo " like /opt/usr/coreclr-tc"
+ echo " Default is '/opt/usr/coreclr-tc'."
echo "--environment - You can specify the environment variable for performing the unittest"
- echo "--options - You can specify options for performing the unittest"
+ echo "--options - You can specify options for performing the unittest"
+ echo "--pending-timeout - You can specify hours for killing pending unittest"
exit 1
}
-opt="-d"
+opt=""
clrdir=""
environment=""
options=""
+timeout=""
for i in "$@"
do
@@ -40,6 +42,9 @@ do
--options=*)
options=${i#*=}
;;
+ --pending-timeout=*)
+ timeout=${i#*=}
+ ;;
*)
usage
@@ -82,6 +87,12 @@ $environment \
--testNativeBinDir=/usr/share/dotnet.tizen/test \
--coreOverlayDir=$overlaydir --show-time --no-lf-conversion | tee clr.log\""
+# start pending test killer
+if [ -n "${timeout}" ]; then
+ sdb ${opt} push script/dotnet-pending-clrtest-killer.sh $clrdir
+ sdb ${opt} shell "cd ${clrdir} && ./dotnet-pending-clrtest-killer.sh --timeout=${timeout} --quite" &
+fi
+
sdb ${opt} shell "cd $clrdir && \
$environment \
./runtest.sh --testRootDir=$tcdir \
@@ -89,3 +100,11 @@ sdb ${opt} shell "cd $clrdir && \
--testNativeBinDir=/usr/share/dotnet.tizen/test \
--coreOverlayDir=$overlaydir --show-time --no-lf-conversion | tee clr.log"
+# kill pending test killer
+if [ -n "${timeout}" ]; then
+ PIDS=$(sdb ${opt} shell "ps aux | grep 'dotnet-pending-clrtest-killer'" | awk '{print $2}')
+ for PID in ${PIDS[*]}
+ do
+ sdb ${opt} shell "kill ${PID}"
+ done
+fi
diff --git a/script/dotnet-pending-clrtest-killer.sh b/script/dotnet-pending-clrtest-killer.sh
new file mode 100755
index 0000000..30b378f
--- /dev/null
+++ b/script/dotnet-pending-clrtest-killer.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+QUITE_MODE=
+KILL_LOG_FILE=killed.log
+
+function message
+{
+ if [ ! "$QUITE_MODE" == "1" ]; then
+ echo $1 >> ${KILL_LOG_FILE}
+ fi
+}
+
+function usage
+{
+ echo ""
+ echo "Usage: $(basename $0) [option]"
+ echo ""
+ echo " [option]"
+ echo " --timeout : timeout interval 1 to 9 in hours. if omitted, use 2 as default."
+ echo " --pattern : process search pattern. if omitted, use 'corerun' as default."
+ echo " --quite : run in silent mode."
+ echo ""
+}
+
+if [ $# -lt 1 ]; then
+ usage
+ exit
+fi
+
+KILL_LOG_FILE=killed.log
+PATTERN=corerun
+TIMEOUT=2
+
+# check commandline options
+for i in "$@"
+do
+ if [ $# -le 0 ]; then
+ break
+ fi
+ case $i in
+ -\?|-h|--help)
+ usage
+ exit
+ ;;
+ --quite)
+ QUITE_MODE=1
+ ;;
+ --timeout=*)
+ TIMEOUT=${i#*=}
+ ;;
+ --pattern=*)
+ PATTERN=${i#*=}
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+if [ $TIMEOUT -lt 1 ] || [ $TIMEOUT -gt 9 ]; then
+ echo "ERROR: <timeout interval> out of range."
+ exit 1
+fi
+
+rm ${KILL_LOG_FILE}
+message "Start with pattern '${PATTERN}' and timeout interval as ${TIMEOUT} hours."
+while [ 1 ]
+do
+ PENDING_TESTS=$(ps -xo pid,etime,stat,args | grep -- $PATTERN | grep -e "[${TIMEOUT}-9]:[0-5][0-9]:[0-5][0-9]" | sed -e 's/^[ ]*//g' -e 's/[ ]\+/ /g')
+ PENDING_TESTS_PID=$(ps -xo pid,etime,stat,args | grep -- $PATTERN | grep -e "[${TIMEOUT}-9]:[0-5][0-9]:[0-5][0-9]" | sed -e 's/^[ ]*//g' -e 's/[ ]\+/ /g' | cut -d' ' -f 1 | paste -s | sed -e 's/^[ ]*//g' -e 's/[ ]\+/ /g')
+
+ message "$(date +%m/%d-%H:%M:%S): triggering pending test killer..."
+
+ if [ -n "$PENDING_TESTS_PID" ]; then
+ message ""
+ message "[PENDING_TESTS]"
+ message "$PENDING_TESTS"
+ message ""
+ message "Send kill signal to ${PENDING_TESTS_PID}"
+ message ""
+
+ if [ "$QUITE_MODE" == "1" ]; then
+ kill -9 $PENDING_TESTS_PID > /dev/null
+ else
+ kill -9 $PENDING_TESTS_PID
+ fi
+ fi
+
+ sleep 60
+done