author | ohair |
Tue, 25 May 2010 15:58:33 -0700 | |
changeset 5506 | 202f599c92aa |
parent 4663 | dfea6ffdb0dc |
child 9035 | 1255eb81cc2f |
child 9259 | f63768ad58c5 |
permissions | -rw-r--r-- |
2 | 1 |
#!/bin/sh |
2 |
||
3 |
# |
|
5506 | 4 |
# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. |
2 | 5 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6 |
# |
|
7 |
# This code is free software; you can redistribute it and/or modify it |
|
8 |
# under the terms of the GNU General Public License version 2 only, as |
|
9 |
# published by the Free Software Foundation. |
|
10 |
# |
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
# accompanied this code). |
|
16 |
# |
|
17 |
# You should have received a copy of the GNU General Public License version |
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
# |
|
5506 | 21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
2 | 24 |
# |
25 |
||
26 |
||
27 |
# |
|
28 |
# |
|
29 |
# Application Setup - creates ${TESTCLASSES}/Application.jar and the following |
|
30 |
# procedures: |
|
31 |
# startApplication - starts target application |
|
32 |
# stopApplication $1 - stops application via TCP shutdown port $1 |
|
33 |
||
34 |
$JAVAC -d "${TESTCLASSES}" "${TESTSRC}"/Application.java "${TESTSRC}"/Shutdown.java |
|
35 |
$JAR -cfm "${TESTCLASSES}"/Application.jar "${TESTSRC}"/application.mf \ |
|
36 |
-C "${TESTCLASSES}" Application.class |
|
37 |
||
38 |
OUTPUTFILE=${TESTCLASSES}/Application.out |
|
39 |
rm -f ${OUTPUTFILE} |
|
40 |
||
41 |
startApplication() |
|
42 |
{ |
|
43 |
${JAVA} $1 $2 $3 -jar "${TESTCLASSES}"/Application.jar > ${OUTPUTFILE} & |
|
44 |
pid="$!" |
|
45 |
||
46 |
# MKS creates an intermediate shell to launch ${JAVA} so |
|
47 |
# ${pid} is not the actual pid. We have put in a small sleep |
|
48 |
# to give the intermediate shell process time to launch the |
|
49 |
# "java" process. |
|
50 |
if [ "$OS" = "Windows" ]; then |
|
51 |
sleep 2 |
|
4663
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
52 |
if [ "${isCygwin}" = "true" ] ; then |
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
53 |
realpid=`ps -p ${pid} | tail -1 | awk '{print $4;}'` |
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
54 |
else |
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
55 |
realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6` |
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
56 |
fi |
2 | 57 |
pid=${realpid} |
58 |
fi |
|
59 |
||
60 |
echo "Waiting for Application to initialize..." |
|
61 |
attempts=0 |
|
62 |
while true; do |
|
63 |
sleep 1 |
|
4663
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
64 |
port=`tail -1 ${OUTPUTFILE} | sed -e 's@\\r@@g' ` |
2 | 65 |
if [ ! -z "$port" ]; then |
66 |
# In case of errors wait time for output to be flushed |
|
67 |
sleep 1 |
|
68 |
cat ${OUTPUTFILE} |
|
69 |
break |
|
70 |
fi |
|
71 |
attempts=`expr $attempts + 1` |
|
72 |
echo "Waiting $attempts second(s) ..." |
|
73 |
done |
|
74 |
echo "Application is process $pid, shutdown port is $port" |
|
75 |
return $port |
|
76 |
} |
|
77 |
||
78 |
stopApplication() |
|
79 |
{ |
|
80 |
$JAVA -classpath "${TESTCLASSES}" Shutdown $1 |
|
81 |
} |
|
82 |