From 8acde446848206ec97e253a2455bceff04c55183 Mon Sep 17 00:00:00 2001 From: ohair Date: Mon, 4 Jan 2010 15:56:42 -0800 Subject: [PATCH] 6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools Reviewed-by: tbell, alanb --- .../com/sun/tools/attach/ApplicationSetup.sh | 8 ++++++-- jdk/test/com/sun/tools/attach/BasicTests.sh | 2 +- jdk/test/com/sun/tools/attach/CommonSetup.sh | 6 ++++++ .../com/sun/tools/attach/PermissionTests.sh | 4 ++-- jdk/test/com/sun/tools/attach/ProviderTests.sh | 2 +- jdk/test/sun/jvmstat/testlibrary/utils.sh | 4 ++-- jdk/test/sun/tools/common/ApplicationSetup.sh | 6 +++++- jdk/test/sun/tools/common/CommonSetup.sh | 5 +++++ jdk/test/sun/tools/jps/jps-help.sh | 4 ++-- jdk/test/sun/tools/jstat/jstatHelp.sh | 4 ++-- jdk/test/sun/tools/jstat/jstatOptions1.sh | 2 +- jdk/test/sun/tools/jstatd/jstatdUsage1.sh | 4 ++-- .../tools/native2ascii/Native2AsciiTests.sh | 10 ++++++---- jdk/test/tools/launcher/ChangeDataModel.sh | 15 +++++++++------ jdk/test/tools/launcher/ClassPathWildCard.sh | 2 +- jdk/test/tools/launcher/DefaultLocaleTest.sh | 18 +++++++++++++++++- jdk/test/tools/launcher/UnicodeTest.sh | 2 +- 17 files changed, 69 insertions(+), 29 deletions(-) diff --git a/jdk/test/com/sun/tools/attach/ApplicationSetup.sh b/jdk/test/com/sun/tools/attach/ApplicationSetup.sh index fa8509ec39..0bd7a1b569 100644 --- a/jdk/test/com/sun/tools/attach/ApplicationSetup.sh +++ b/jdk/test/com/sun/tools/attach/ApplicationSetup.sh @@ -49,7 +49,11 @@ startApplication() # "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 @@ startApplication() 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 diff --git a/jdk/test/com/sun/tools/attach/BasicTests.sh b/jdk/test/com/sun/tools/attach/BasicTests.sh index a960b40e15..f5c4076581 100644 --- a/jdk/test/com/sun/tools/attach/BasicTests.sh +++ b/jdk/test/com/sun/tools/attach/BasicTests.sh @@ -48,7 +48,7 @@ failures=0 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 diff --git a/jdk/test/com/sun/tools/attach/CommonSetup.sh b/jdk/test/com/sun/tools/attach/CommonSetup.sh index 1520ca72b5..66d90fafdd 100644 --- a/jdk/test/com/sun/tools/attach/CommonSetup.sh +++ b/jdk/test/com/sun/tools/attach/CommonSetup.sh @@ -49,6 +49,12 @@ case "$OS" in OS="Windows" FS="\\" ;; + CYGWIN* ) + PS=";" + OS="Windows" + FS="\\" + isCygwin=true + ;; * ) echo "Unrecognized system!" exit 1; diff --git a/jdk/test/com/sun/tools/attach/PermissionTests.sh b/jdk/test/com/sun/tools/attach/PermissionTests.sh index 908e93ec07..54a7e61a7e 100644 --- a/jdk/test/com/sun/tools/attach/PermissionTests.sh +++ b/jdk/test/com/sun/tools/attach/PermissionTests.sh @@ -48,7 +48,7 @@ startApplication 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 @@ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi # 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 diff --git a/jdk/test/com/sun/tools/attach/ProviderTests.sh b/jdk/test/com/sun/tools/attach/ProviderTests.sh index caca75af0e..36a90b1353 100644 --- a/jdk/test/com/sun/tools/attach/ProviderTests.sh +++ b/jdk/test/com/sun/tools/attach/ProviderTests.sh @@ -46,6 +46,6 @@ $JAR -cf ${TESTCLASSES}/SimpleProvider.jar \ 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 diff --git a/jdk/test/sun/jvmstat/testlibrary/utils.sh b/jdk/test/sun/jvmstat/testlibrary/utils.sh index d3b0495637..8bd4215d08 100644 --- a/jdk/test/sun/jvmstat/testlibrary/utils.sh +++ b/jdk/test/sun/jvmstat/testlibrary/utils.sh @@ -40,7 +40,7 @@ setup() { OS=`uname -s` case ${OS} in - Windows_*) + Windows_* | CYGWIN*) PS=";" FS="\\" ;; @@ -54,7 +54,7 @@ setup() { 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 ;; diff --git a/jdk/test/sun/tools/common/ApplicationSetup.sh b/jdk/test/sun/tools/common/ApplicationSetup.sh index b5c0ad2314..9c8e9d2bbc 100644 --- a/jdk/test/sun/tools/common/ApplicationSetup.sh +++ b/jdk/test/sun/tools/common/ApplicationSetup.sh @@ -45,7 +45,11 @@ startApplication() # "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 diff --git a/jdk/test/sun/tools/common/CommonSetup.sh b/jdk/test/sun/tools/common/CommonSetup.sh index 861289c08d..3876affc5a 100644 --- a/jdk/test/sun/tools/common/CommonSetup.sh +++ b/jdk/test/sun/tools/common/CommonSetup.sh @@ -67,6 +67,11 @@ case "$OS" in PS=";" OS="Windows" ;; + CYGWIN* ) + PS=";" + OS="Windows" + isCygwin=true + ;; * ) PS=":" ;; diff --git a/jdk/test/sun/tools/jps/jps-help.sh b/jdk/test/sun/tools/jps/jps-help.sh index 28a4786428..0303954343 100644 --- a/jdk/test/sun/tools/jps/jps-help.sh +++ b/jdk/test/sun/tools/jps/jps-help.sh @@ -35,7 +35,7 @@ JPS="${TESTJAVA}/bin/jps" 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 @@ fi 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." diff --git a/jdk/test/sun/tools/jstat/jstatHelp.sh b/jdk/test/sun/tools/jstat/jstatHelp.sh index 545970e311..3ec7906c0e 100644 --- a/jdk/test/sun/tools/jstat/jstatHelp.sh +++ b/jdk/test/sun/tools/jstat/jstatHelp.sh @@ -35,7 +35,7 @@ JSTAT="${TESTJAVA}/bin/jstat" 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 @@ fi 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." diff --git a/jdk/test/sun/tools/jstat/jstatOptions1.sh b/jdk/test/sun/tools/jstat/jstatOptions1.sh index e38c413790..ad3df13ca3 100644 --- a/jdk/test/sun/tools/jstat/jstatOptions1.sh +++ b/jdk/test/sun/tools/jstat/jstatOptions1.sh @@ -35,4 +35,4 @@ JSTAT="${TESTJAVA}/bin/jstat" 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 diff --git a/jdk/test/sun/tools/jstatd/jstatdUsage1.sh b/jdk/test/sun/tools/jstatd/jstatdUsage1.sh index 22d309b62c..074ec5ce2b 100644 --- a/jdk/test/sun/tools/jstatd/jstatdUsage1.sh +++ b/jdk/test/sun/tools/jstatd/jstatdUsage1.sh @@ -37,7 +37,7 @@ JSTATD_2_OUT="jstatd_$$_2.out" ${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 @@ fi ${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." diff --git a/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh b/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh index 1fa7f6c000..26281ba724 100644 --- a/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh +++ b/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh @@ -32,7 +32,7 @@ if [ "${TESTSRC}" = "" ]; then TESTSRC=.; fi 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 @@ check() { # 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" diff --git a/jdk/test/tools/launcher/ChangeDataModel.sh b/jdk/test/tools/launcher/ChangeDataModel.sh index eddc38d7cf..1fc689f403 100644 --- a/jdk/test/tools/launcher/ChangeDataModel.sh +++ b/jdk/test/tools/launcher/ChangeDataModel.sh @@ -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 @@ $JAVAC GetDataModel.java # 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 @@ case "$DM" in ;; 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 @@ then 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 @@ else ;; 64 ) - DM2=`${JAVA} -d32 GetDataModel` + DM2=`${JAVA} -d32 GetDataModel | ${SED_CR}` if [ "x${DM2}" != "x" ] then echo "Data model flag -d32 was accepted." diff --git a/jdk/test/tools/launcher/ClassPathWildCard.sh b/jdk/test/tools/launcher/ClassPathWildCard.sh index 46a4866e48..4b3b0dfb5e 100644 --- a/jdk/test/tools/launcher/ClassPathWildCard.sh +++ b/jdk/test/tools/launcher/ClassPathWildCard.sh @@ -145,7 +145,7 @@ CreateClassFiles D OS=`uname -s` case $OS in - Windows*|Cygwin*) + Windows*|CYGWIN*) PATHSEP=";" ExecJava "" "${PATHSEP}NOOPDIR" ExecJava "w" "${PATHSEP}NOOPDIR" diff --git a/jdk/test/tools/launcher/DefaultLocaleTest.sh b/jdk/test/tools/launcher/DefaultLocaleTest.sh index 97eddd5bf6..31af0aa319 100644 --- a/jdk/test/tools/launcher/DefaultLocaleTest.sh +++ b/jdk/test/tools/launcher/DefaultLocaleTest.sh @@ -48,7 +48,7 @@ fi 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 @@ case "$OS" in 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; diff --git a/jdk/test/tools/launcher/UnicodeTest.sh b/jdk/test/tools/launcher/UnicodeTest.sh index 7b4789772f..8f77f4b739 100644 --- a/jdk/test/tools/launcher/UnicodeTest.sh +++ b/jdk/test/tools/launcher/UnicodeTest.sh @@ -54,7 +54,7 @@ mkdir UnicodeTest-src UnicodeTest-classes 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 -- GitLab