changeset 223:2412c90533d0

Bug 3353: [TEST]Add a test runner for deadlock and thread-recording Reviewed-by: yasuenag https://github.com/HeapStats/heapstats/pull/87
author KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp>
date Tue, 11 Apr 2017 08:08:45 +0900
parents f3d7307b0ee3
children 1397192f0dc9
files ChangeLog agent/test/deadlock/testcase.sh agent/test/thread-recording/testcase.sh
diffstat 3 files changed, 54 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 25 23:42:22 2017 +0900
+++ b/ChangeLog	Tue Apr 11 08:08:45 2017 +0900
@@ -1,3 +1,7 @@
+2017-04-10 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp>
+
+	* Bug 3353: [TEST]Add a test runner for deadlock and thread-recording
+
 2017-03-25 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp>
 
 	* Bug 3342: Replace LDDQU instruction for uncached memory regions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/agent/test/deadlock/testcase.sh	Tue Apr 11 08:08:45 2017 +0900
@@ -0,0 +1,31 @@
+#!/bin/sh
+set -e
+
+pushd $(dirname $0) >/dev/null
+
+if [[ $1 == "--clean" ]]; then
+  rm -rf *class heapstats_log.csv heapstats_snapshot.dat result.log
+  exit
+fi
+
+THREAD_NUM=${1:-11}
+SLEEP_TIME=${2:-10}
+LOGFILE=result.log
+
+${JAVA_HOME:=/usr/lib/jvm/java-openjdk}/bin/javac DLSample.java
+
+${JAVA_HOME}/bin/java -agentpath:${HEAPSTATS_LIB:-/usr/lib64/heapstats/libheapstats.so}=./heapstats.conf \
+  DLSample $THREAD_NUM 1>$LOGFILE 2>&1 &
+TARGET_PID=$!
+
+sleep $SLEEP_TIME && kill -9 $TARGET_PID
+
+if [[ "cat $LOGFILE | grep 'heapstats CRIT: ALERT(DEADLOCK): occurred deadlock. threadCount: $THREAD_NUM'" ]]; then
+  echo "Detected deadlock correctly."
+  exit 0
+else
+  echo "Could not detect deadlock or deadlock did not occure."
+  exit 1
+fi
+
+popd > /dev/null
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/agent/test/thread-recording/testcase.sh	Tue Apr 11 08:08:45 2017 +0900
@@ -0,0 +1,19 @@
+#!/bin/sh
+set -e
+
+pushd $(dirname $0) >/dev/null
+
+if [[ $1 == "--clean" ]]; then
+  rm -rf *class parser/*class heapstats-thread-records.htr test.txt
+  exit
+fi
+
+${JAVA_HOME:=/usr/lib/jvm/java-openjdk}/bin/javac -cp . *.java parser/*java
+
+${JAVA_HOME}/bin/java -agentpath:${HEAPSTATS_LIB:=/usr/lib64/heapstats/libheapstats.so}=./heapstats.conf Test
+${JAVA_HOME}/bin/java -cp parser ThreadRecordParser heapstats-thread-records.htr
+
+${JAVA_HOME}/bin/java -agentpath:${HEAPSTATS_LIB}=./heapstats.conf IOTest testcase.sh
+${JAVA_HOME}/bin/java -cp parser ThreadRecordParser heapstats-thread-records.htr
+
+popd > /dev/null