6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
Reviewed-by: tbell, alanb
--- a/jdk/test/com/sun/tools/attach/ApplicationSetup.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/ApplicationSetup.sh Mon Jan 04 15:56:42 2010 -0800
@@ -49,7 +49,11 @@
# "java" process.
if [ "$OS" = "Windows" ]; then
sleep 2
- realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
+ if [ "${isCygwin}" = "true" ] ; then
+ realpid=`ps -p ${pid} | tail -1 | awk '{print $4;}'`
+ else
+ realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
+ fi
pid=${realpid}
fi
@@ -57,7 +61,7 @@
attempts=0
while true; do
sleep 1
- port=`tail -1 ${OUTPUTFILE}`
+ port=`tail -1 ${OUTPUTFILE} | sed -e 's@\\r@@g' `
if [ ! -z "$port" ]; then
# In case of errors wait time for output to be flushed
sleep 1
--- a/jdk/test/com/sun/tools/attach/BasicTests.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/BasicTests.sh Mon Jan 04 15:56:42 2010 -0800
@@ -48,7 +48,7 @@
echo "Running tests ..."
-$JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
BasicTests $pid $agent $badagent $redefineagent 2>&1
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
--- a/jdk/test/com/sun/tools/attach/CommonSetup.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/CommonSetup.sh Mon Jan 04 15:56:42 2010 -0800
@@ -49,6 +49,12 @@
OS="Windows"
FS="\\"
;;
+ CYGWIN* )
+ PS=";"
+ OS="Windows"
+ FS="\\"
+ isCygwin=true
+ ;;
* )
echo "Unrecognized system!"
exit 1;
--- a/jdk/test/com/sun/tools/attach/PermissionTests.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/PermissionTests.sh Mon Jan 04 15:56:42 2010 -0800
@@ -48,7 +48,7 @@
echo "Deny test"
# deny
-$JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
-Djava.security.manager \
-Djava.security.policy=${TESTSRC}/java.policy.deny \
PermissionTest $pid true 2>&1
@@ -56,7 +56,7 @@
# allow
echo "Allow test"
-$JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
-Djava.security.manager \
-Djava.security.policy=${TESTSRC}/java.policy.allow \
PermissionTest $pid false 2>&1
--- a/jdk/test/com/sun/tools/attach/ProviderTests.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/ProviderTests.sh Mon Jan 04 15:56:42 2010 -0800
@@ -46,6 +46,6 @@
echo "Running test ..."
$JAVA -classpath \
- ${TESTCLASSES}${PS}${TESTCLASSES}/SimpleProvider.jar${PS}${TESTJAVA}/lib/tools.jar \
+ "${TESTCLASSES}${PS}${TESTCLASSES}/SimpleProvider.jar${PS}${TESTJAVA}/lib/tools.jar" \
ProviderTest
--- a/jdk/test/sun/jvmstat/testlibrary/utils.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/sun/jvmstat/testlibrary/utils.sh Mon Jan 04 15:56:42 2010 -0800
@@ -40,7 +40,7 @@
OS=`uname -s`
case ${OS} in
- Windows_*)
+ Windows_* | CYGWIN*)
PS=";"
FS="\\"
;;
@@ -54,7 +54,7 @@
verify_os() {
OS=`uname -s`
case ${OS} in
- Windows_95 | Windows_98 | Windows_ME)
+ Windows_95 | Windows_98 | Windows_ME | CYGWIN* )
echo "Test bypassed: jvmstat feature not supported on ${OS}"
exit 0
;;
--- a/jdk/test/sun/tools/common/ApplicationSetup.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/sun/tools/common/ApplicationSetup.sh Mon Jan 04 15:56:42 2010 -0800
@@ -45,7 +45,11 @@
# "java" process.
if [ "$OS" = "Windows" ]; then
sleep 2
- realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
+ if [ "${isCygwin}" = "true" ] ; then
+ realpid=`ps -p ${pid} | tail -1 | awk '{print $4;}'`
+ else
+ realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
+ fi
pid=${realpid}
fi
--- a/jdk/test/sun/tools/common/CommonSetup.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/sun/tools/common/CommonSetup.sh Mon Jan 04 15:56:42 2010 -0800
@@ -67,6 +67,11 @@
PS=";"
OS="Windows"
;;
+ CYGWIN* )
+ PS=";"
+ OS="Windows"
+ isCygwin=true
+ ;;
* )
PS=":"
;;
--- a/jdk/test/sun/tools/jps/jps-help.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/sun/tools/jps/jps-help.sh Mon Jan 04 15:56:42 2010 -0800
@@ -35,7 +35,7 @@
rm -f jps.out 2>/dev/null
${JPS} -? > jps.out 2>&1
-diff jps.out ${TESTSRC}/usage.out
+diff -w jps.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jps -? differ from expected output. Failed."
@@ -46,7 +46,7 @@
rm -f jps.out 2>/dev/null
${JPS} -help > jps.out 2>&1
-diff jps.out ${TESTSRC}/usage.out
+diff -w jps.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jps -help differ from expected output. Failed."
--- a/jdk/test/sun/tools/jstat/jstatHelp.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/sun/tools/jstat/jstatHelp.sh Mon Jan 04 15:56:42 2010 -0800
@@ -35,7 +35,7 @@
rm -f jstat.out 2>/dev/null
${JSTAT} -? > jstat.out 2>&1
-diff jstat.out ${TESTSRC}/usage.out
+diff -w jstat.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jstat -? differ from expected output. Failed."
@@ -45,7 +45,7 @@
rm -f jstat.out 2>/dev/null
${JSTAT} -help > jstat.out 2>&1
-diff jstat.out ${TESTSRC}/usage.out
+diff -w jstat.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jstat -help differ from expected output. Failed."
--- a/jdk/test/sun/tools/jstat/jstatOptions1.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/sun/tools/jstat/jstatOptions1.sh Mon Jan 04 15:56:42 2010 -0800
@@ -35,4 +35,4 @@
rm -f jstat.out 2>/dev/null
${JSTAT} -options > jstat.out 2>&1
-diff jstat.out ${TESTSRC}/options1.out
+diff -w jstat.out ${TESTSRC}/options1.out
--- a/jdk/test/sun/tools/jstatd/jstatdUsage1.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/sun/tools/jstatd/jstatdUsage1.sh Mon Jan 04 15:56:42 2010 -0800
@@ -37,7 +37,7 @@
${JSTATD} -? > ${JSTATD_1_OUT} 2>&1
-diff ${JSTATD_1_OUT} ${TESTSRC}/usage.out
+diff -w ${JSTATD_1_OUT} ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jstatd -? differs from expected output. Failed."
@@ -46,7 +46,7 @@
${JSTATD} -help > ${JSTATD_2_OUT} 2>&1
-diff ${JSTATD_2_OUT} ${TESTSRC}/usage.out
+diff -w ${JSTATD_2_OUT} ${TESTSRC}/usage.out
if [ $? != 0 ]
then
echo "Output of jstatd -help differs from expected output. Failed."
--- a/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh Mon Jan 04 15:56:42 2010 -0800
@@ -32,7 +32,7 @@
if [ "${TESTJAVA}" = "" ]; then TESTJAVA=$1; shift; fi
case `uname -s` in
- Windows*) OS=Windows;;
+ Windows* | CYGWIN*) OS=Windows;;
SunOS|Linux) OS=Unix;;
esac
@@ -45,12 +45,14 @@
# Strip carriage returns from output when comparing with n2a test output
# on win32 systems
- if [ OS = Windows ]; then
- tr -d '\015' <$out >$out.1
+ if [ ${OS} = Windows ]; then
+ sed -e 's@\\r@@g' $out >$out.1
+ sed -e 's@\\r@@g' $expected >$out.expected
else
cp $out $out.1
+ cp $expected $out.expected
fi
- if (set -x; diff -c $expected $out.1); then
+ if (set -x; diff -c $out.expected $out.1); then
echo "$bug passed"
else
echo "$bug failed"
--- a/jdk/test/tools/launcher/ChangeDataModel.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/tools/launcher/ChangeDataModel.sh Mon Jan 04 15:56:42 2010 -0800
@@ -29,6 +29,9 @@
OS=`uname -s`;
+# To remove CR from output, needed for java apps in CYGWIN, harmless otherwise
+SED_CR="sed -e s@\\r@@g"
+
case "$OS" in
Windows* | CYGWIN* )
PATHSEP=";"
@@ -79,10 +82,10 @@
# Verify data model flag for default data model is accepted
-DM=`$JAVA GetDataModel`
+DM=`$JAVA GetDataModel | ${SED_CR}`
case "$DM" in
32 )
- DM2=`${JAVA} -d32 GetDataModel`
+ DM2=`${JAVA} -d32 GetDataModel | ${SED_CR}`
if [ "${DM2}" != "32" ]
then
echo "Data model flag -d32 not accepted or had improper effect."
@@ -91,7 +94,7 @@
;;
64 )
- DM2=`${JAVA} -d64 GetDataModel`
+ DM2=`${JAVA} -d64 GetDataModel | ${SED_CR}`
if [ "${DM2}" != "64" ]
then
echo "Data model flag -d64 not accepted or had improper effect."
@@ -227,10 +230,10 @@
else
# Negative tests for non-dual mode platforms to ensure the other data model is
# rejected
- DM=`$JAVA GetDataModel`
+ DM=`$JAVA GetDataModel | ${SED_CR}`
case "$DM" in
32 )
- DM2=`${JAVA} -d64 GetDataModel`
+ DM2=`${JAVA} -d64 GetDataModel | ${SED_CR}`
if [ "x${DM2}" != "x" ]
then
echo "Data model flag -d64 was accepted."
@@ -239,7 +242,7 @@
;;
64 )
- DM2=`${JAVA} -d32 GetDataModel`
+ DM2=`${JAVA} -d32 GetDataModel | ${SED_CR}`
if [ "x${DM2}" != "x" ]
then
echo "Data model flag -d32 was accepted."
--- a/jdk/test/tools/launcher/ClassPathWildCard.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/tools/launcher/ClassPathWildCard.sh Mon Jan 04 15:56:42 2010 -0800
@@ -145,7 +145,7 @@
OS=`uname -s`
case $OS in
- Windows*|Cygwin*)
+ Windows*|CYGWIN*)
PATHSEP=";"
ExecJava "" "${PATHSEP}NOOPDIR"
ExecJava "w" "${PATHSEP}NOOPDIR"
--- a/jdk/test/tools/launcher/DefaultLocaleTest.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/tools/launcher/DefaultLocaleTest.sh Mon Jan 04 15:56:42 2010 -0800
@@ -48,7 +48,7 @@
OS=`uname`
case "$OS" in
- Windows* | CYGWIN* )
+ Windows* )
JAVAC="${TESTJAVA}/bin/javac -d . "
JAVA="${TESTJAVA}/bin/java -classpath . "
JAVAW="${TESTJAVA}/bin/javaw -classpath . "
@@ -64,6 +64,22 @@
echo "Test passes"
exit 0
;;
+ CYGWIN* )
+ JAVAC="${TESTJAVA}/bin/javac -d . "
+ JAVA="${TESTJAVA}/bin/java -classpath . "
+ JAVAW="${TESTJAVA}/bin/javaw -classpath . "
+
+ ${JAVAC} ${TESTSRC}/DefaultLocaleTest.java
+ ${JAVA} DefaultLocaleTest | sed -e s@\\r@@g > x.out
+ ${JAVAW} DefaultLocaleTest `cat x.out`
+ if [ $? -ne 0 ]
+ then
+ echo "Test fails"
+ exit 1
+ fi
+ echo "Test passes"
+ exit 0
+ ;;
* )
echo "Non-windows environment; test vacuously succeeds."
exit 0;
--- a/jdk/test/tools/launcher/UnicodeTest.sh Mon Jan 04 15:52:38 2010 -0800
+++ b/jdk/test/tools/launcher/UnicodeTest.sh Mon Jan 04 15:56:42 2010 -0800
@@ -54,7 +54,7 @@
echo "creating test source files"
"$JAVAC" -d . "${TESTSRC}"/UnicodeTest.java
-CLASS_NAME=`"$JAVA" UnicodeTest`
+CLASS_NAME=`"$JAVA" UnicodeTest | sed -e 's@\\r@@g' `
if [ "$CLASS_NAME" = "" ]
then