OpenJDK / portola / portola
changeset 27795:85a256042ab2
Merge
author | amurillo |
---|---|
date | Tue, 02 Dec 2014 14:36:23 -0800 |
parents | 29d4cb4a8f5e c8bb28d30418 |
children | 5052f749052a |
files | jdk/test/sun/tools/jinfo/Basic.sh |
diffstat | 18 files changed, 431 insertions(+), 143 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/java/lang/Thread.java Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/src/java.base/share/classes/java/lang/Thread.java Tue Dec 02 14:36:23 2014 -0800 @@ -145,7 +145,7 @@ registerNatives(); } - private volatile char name[]; + private volatile String name; private int priority; private Thread threadQ; private long eetop; @@ -366,7 +366,7 @@ throw new NullPointerException("name cannot be null"); } - this.name = name.toCharArray(); + this.name = name; Thread parent = currentThread(); SecurityManager security = System.getSecurityManager(); @@ -1119,7 +1119,11 @@ */ public final synchronized void setName(String name) { checkAccess(); - this.name = name.toCharArray(); + if (name == null) { + throw new NullPointerException("name cannot be null"); + } + + this.name = name; if (threadStatus != 0) { setNativeName(name); } @@ -1132,7 +1136,7 @@ * @see #setName(String) */ public final String getName() { - return new String(name, true); + return name; } /**
--- a/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java Tue Dec 02 14:36:23 2014 -0800 @@ -767,7 +767,7 @@ JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs); connServer.start(); } catch (IOException e) { - if (connServer == null) { + if (connServer == null || connServer.getAddress() == null) { throw new AgentConfigurationError(CONNECTOR_SERVER_IO_ERROR, e, url.toString()); } else {
--- a/jdk/test/ProblemList.txt Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/ProblemList.txt Tue Dec 02 14:36:23 2014 -0800 @@ -319,6 +319,9 @@ # 6456333 sun/tools/jps/TestJpsJarRelative.java generic-all +# 6734748 +sun/tools/jinfo/JInfoRunningProcessFlagTest.java generic-all + # 8057732 sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java generic-all
--- a/jdk/test/TEST.groups Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/TEST.groups Tue Dec 02 14:36:23 2014 -0800 @@ -290,6 +290,65 @@ :jdk_sound \ :jdk_imageio +############################################################################### +# +# Serviceability sanity groups +# +# These groups specify a subset of Serviceability tests that are supposed to +# guard against breakage of Serviceability features by other component teams. +# They are added to the "hotspot" testset in JPRT so that they will run on all +# full-forest pushes through JPRT. +# + +jdk_svc_sanity = \ + :jdk_management_sanity \ + :jdk_instrument_sanity \ + :jdk_jmx_sanity \ + :jdk_jdi_sanity \ + :svc_tools_sanity + +jdk_management_sanity = + +jdk_instrument_sanity = + +jdk_jmx_sanity = + +jdk_jdi_sanity = \ + com/sun/jdi/AcceptTimeout.java \ + com/sun/jdi/AccessSpecifierTest.java \ + com/sun/jdi/AfterThreadDeathTest.java \ + com/sun/jdi/ArrayRangeTest.java \ + com/sun/jdi/ConstantPoolInfo.java \ + com/sun/jdi/CountFilterTest.java \ + com/sun/jdi/EarlyReturnNegativeTest.java \ + com/sun/jdi/EarlyReturnTest.java \ + com/sun/jdi/FieldWatchpoints.java \ + com/sun/jdi/FramesTest.java \ + com/sun/jdi/InstanceFilter.java \ + com/sun/jdi/InterfaceMethodsTest.java \ + com/sun/jdi/InvokeTest.java \ + com/sun/jdi/LocalVariableEqual.java \ + com/sun/jdi/LocationTest.java \ + com/sun/jdi/ModificationWatchpoints.java \ + com/sun/jdi/MonitorEventTest.java \ + com/sun/jdi/MonitorFrameInfo.java \ + com/sun/jdi/NullThreadGroupNameTest.java \ + com/sun/jdi/PopAndStepTest.java \ + com/sun/jdi/PopAsynchronousTest.java \ + com/sun/jdi/ProcessAttachTest.java \ + com/sun/jdi/ReferrersTest.java \ + com/sun/jdi/RequestReflectionTest.java \ + com/sun/jdi/ResumeOneThreadTest.java \ + com/sun/jdi/RunToExit.java \ + com/sun/jdi/SourceNameFilterTest.java \ + com/sun/jdi/VarargsTest.java \ + com/sun/jdi/Vars.java \ + com/sun/jdi/redefineMethod/RedefineTest.java \ + com/sun/jdi/sde/MangleTest.java \ + com/sun/jdi/sde/TemperatureTableTest.java + +svc_tools_sanity = + ############################# # # Stable test groups
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh Tue Dec 02 14:36:23 2014 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ # @test # @bug 4982128 # @summary Test low memory detection of non-heap memory pool -# +# @requires vm.gc=="null" # @run build LowMemoryTest2 MemoryUtil # @run shell/timeout=600 LowMemoryTest2.sh #
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh Tue Dec 02 14:36:23 2014 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ # @bug 4530538 # @summary Run MemoryManagement test with concurrent mark sweep GC # @author Mandy Chung -# +# @requires vm.gc=="ConcMarkSweep" | vm.gc=="null" # @run build MemoryManagement # @run shell/timeout=600 MemoryManagementConcMarkSweepGC.sh #
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh Tue Dec 02 14:36:23 2014 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ # @bug 4530538 # @summary Run MemoryManagement test with parallel GC # @author Mandy Chung -# +# @requires vm.gc=="Parallel" | vm.gc=="null" # @run build MemoryManagement # @run shell/timeout=600 MemoryManagementParallelGC.sh #
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh Tue Dec 02 14:36:23 2014 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ # @bug 4530538 # @summary Run MemoryManagement test with serial GC # @author Mandy Chung -# +# @requires vm.gc=="Serial" | vm.gc=="null" # @run build MemoryManagement # @run shell/timeout=600 MemoryManagementSerialGC.sh #
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh Tue Dec 02 14:36:23 2014 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ # @bug 4530538 # @summary # @author Mandy Chung -# +# @requires vm.gc=="Parallel" | vm.gc=="null" # @run compile MemoryTest.java # @run shell MemoryTestAllGC.sh # @@ -52,7 +52,5 @@ # Test MemoryTest with parallel scavenger collector runOne -XX:+UseParallelGC MemoryTest 2 -# Test MemoryTest with concurrent collector -#runOne -XX:+UseConcMarkSweepGC MemoryTest 3 exit 0
--- a/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh Tue Dec 02 14:36:23 2014 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ # @bug 4530538 # @summary # @author Mandy Chung -# +# @requires vm.gc=="null" # @run compile Pending.java # @run shell PendingAllGC.sh #
--- a/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh Tue Dec 02 14:36:23 2014 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ # @bug 4530538 # @summary # @author Mandy Chung -# # @run compile InputArgument.java # @run shell TestInputArgument.sh # @@ -48,8 +47,8 @@ runOne InputArgument -runOne -XX:+UseParallelGC -XX:+PrintGCDetails InputArgument -XX:+PrintGCDetails -runOne -XX:+UseParallelGC -XX:+PrintGCDetails InputArgument -XX:+UseParallelGC +runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+PrintGCDetails +runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+UseFastJNIAccessors runOne "-Dprops=one two three" InputArgument "-Dprops=one two three" exit 0
--- a/jdk/test/java/lang/ref/EnqueuePollRace.java Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/java/lang/ref/EnqueuePollRace.java Tue Dec 02 14:36:23 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @bug 8014890 * @summary Verify that a race between ReferenceQueue.enqueue() and poll() does not occur. * @author thomas.schatzl@oracle.com - * @run main/othervm -XX:+UseSerialGC -Xmx10M EnqueuePollRace + * @run main/othervm -Xmx10M EnqueuePollRace */ import java.lang.ref.*;
--- a/jdk/test/sun/tools/jinfo/Basic.sh Tue Dec 02 15:12:40 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - - -# @test -# @bug 6402766 -# @summary Unit test for jinfo utility -# -# @library ../common -# @build SimpleApplication ShutdownSimpleApplication -# @run shell Basic.sh - -. ${TESTSRC}/../common/CommonSetup.sh -. ${TESTSRC}/../common/ApplicationSetup.sh - -# Start application and use PORTFILE for coordination -PORTFILE="${TESTCLASSES}"/shutdown.port -startApplication SimpleApplication "${PORTFILE}" - -# all return statuses are checked in this test -set +e -set -x - -failed=0 - -runSA=true - -if [ $isMacos = true -o $isAIX = true -o `uname -m` = ppc64 ]; then - runSA=false -fi - -if [ $isLinux = true ]; then - # Some Linux systems disable non-child ptrace (see 7050524) - ptrace_scope=`/sbin/sysctl -n kernel.yama.ptrace_scope` - if [ $? = 0 ]; then - if [ $ptrace_scope = 1 ]; then - runSA=false - fi - fi -fi - -if [ $runSA = true ]; then - # -sysprops option - ${JINFO} -J-XX:+UsePerfData -F -sysprops $appJavaPid - if [ $? != 0 ]; then failed=1; fi - - # -flags option - ${JINFO} -J-XX:+UsePerfData -F -flags $appJavaPid - if [ $? != 0 ]; then failed=1; fi - - # no option - ${JINFO} -J-XX:+UsePerfData -F $appJavaPid - if [ $? != 0 ]; then failed=1; fi -fi - -# -sysprops option -${JINFO} -J-XX:+UsePerfData -sysprops $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -# -flags option -${JINFO} -J-XX:+UsePerfData -flags $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -# no option -${JINFO} -J-XX:+UsePerfData $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -# -flag option -${JINFO} -J-XX:+UsePerfData -flag +PrintGC $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -${JINFO} -J-XX:+UsePerfData -flag -PrintGC $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -${JINFO} -J-XX:+UsePerfData -flag PrintGC $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -if $isSolaris; then - - ${JINFO} -J-XX:+UsePerfData -flag +ExtendedDTraceProbes $appJavaPid - if [ $? != 0 ]; then failed=1; fi - - ${JINFO} -J-XX:+UsePerfData -flag -ExtendedDTraceProbes $appJavaPid - if [ $? != 0 ]; then failed=1; fi - - ${JINFO} -J-XX:+UsePerfData -flag ExtendedDTraceProbes $appJavaPid - if [ $? != 0 ]; then failed=1; fi - -fi - -set -e - -stopApplication "${PORTFILE}" -waitForApplication - -exit $failed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/tools/jinfo/JInfoHelper.java Tue Dec 02 14:36:23 2014 -0800 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Arrays; + +import jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; + +/** + * The helper class for running jinfo utility. + */ +public final class JInfoHelper { + + /** + * Print configuration information for the current process + * + * @param toolArgs List of jinfo options + */ + public static OutputAnalyzer jinfo(String... toolArgs) throws Exception { + return jinfo(true, toolArgs); + } + + /** + * Print usage information + * + * @param toolArgs List of jinfo options + */ + public static OutputAnalyzer jinfoNoPid(String... toolArgs) throws Exception { + return jinfo(false, toolArgs); + } + + private static OutputAnalyzer jinfo(boolean toPid, String... toolArgs) throws Exception { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo"); + if (toolArgs != null) { + for (String toolArg : toolArgs) { + launcher.addToolArg(toolArg); + } + } + if (toPid) { + launcher.addToolArg(Integer.toString(ProcessTools.getProcessId())); + } + + ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); + System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", "")); + OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); + System.out.println(output.getOutput()); + + return output; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java Tue Dec 02 14:36:23 2014 -0800 @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import sun.management.ManagementFactoryHelper; + +import com.sun.management.HotSpotDiagnosticMXBean; + +import jdk.testlibrary.OutputAnalyzer; +import static jdk.testlibrary.Platform.isSolaris; +import static jdk.testlibrary.Asserts.assertEquals; +import static jdk.testlibrary.Asserts.assertNotEquals; +import static jdk.testlibrary.Asserts.assertTrue; + +/** + * @test + * @summary The test sanity checks 'jinfo -flag' option. + * @library /lib/testlibrary + * @build jdk.testlibrary.* JInfoHelper + * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError JInfoRunningProcessFlagTest + */ +public class JInfoRunningProcessFlagTest { + + public static void main(String[] args) throws Exception { + testFlag(); + testFlagPlus(); + testFlagMinus(); + testFlagEqual(); + + testInvalidFlag(); + + testSolarisSpecificFlag(); + } + + private static void testFlag() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError"); + output.shouldHaveExitValue(0); + assertTrue(output.getStderr().isEmpty(), "'jinfo -flag HeapDumpOnOutOfMemoryError' stderr should be empty"); + output.shouldContain("+HeapDumpOnOutOfMemoryError"); + } + + private static void testFlagPlus() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+PrintGC"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo("-flag", "PrintGC"); + output.shouldHaveExitValue(0); + output.shouldContain("+PrintGC"); + verifyIsEnabled("PrintGC"); + } + + private static void testFlagMinus() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "-PrintGC"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo("-flag", "PrintGC"); + output.shouldHaveExitValue(0); + output.shouldContain("-PrintGC"); + verifyIsDisabled("PrintGC"); + } + + private static void testFlagEqual() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "PrintGC=1"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo("-flag", "PrintGC"); + output.shouldHaveExitValue(0); + output.shouldContain("+PrintGC"); + verifyIsEnabled("PrintGC"); + } + + private static void testInvalidFlag() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "monkey"); + assertNotEquals(output.getExitValue(), 0, "A non-zero exit code should be returned for invalid flag"); + } + + private static void testSolarisSpecificFlag() throws Exception { + if (!isSolaris()) + return; + + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+ExtendedDTraceProbes"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo(); + output.shouldContain("+ExtendedDTraceProbes"); + verifyIsEnabled("ExtendedDTraceProbes"); + + output = JInfoHelper.jinfo("-flag", "-ExtendedDTraceProbes"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo(); + output.shouldContain("-ExtendedDTraceProbes"); + verifyIsDisabled("ExtendedDTraceProbes"); + + output = JInfoHelper.jinfo("-flag", "ExtendedDTraceProbes"); + output.shouldContain("-ExtendedDTraceProbes"); + output.shouldHaveExitValue(0); + } + + private static void verifyIsEnabled(String flag) { + HotSpotDiagnosticMXBean hotspotDiagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); + String flagValue = hotspotDiagnostic.getVMOption(flag).getValue(); + assertEquals(flagValue, "true", "Expected '" + flag + "' flag be enabled"); + } + + private static void verifyIsDisabled(String flag) { + HotSpotDiagnosticMXBean hotspotDiagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); + String flagValue = hotspotDiagnostic.getVMOption(flag).getValue(); + assertEquals(flagValue, "false", "Expected '" + flag + "' flag be disabled"); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java Tue Dec 02 14:36:23 2014 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.testlibrary.OutputAnalyzer; +import static jdk.testlibrary.Asserts.assertTrue; + +/** + * @test + * @summary The test sanity checks functionality of 'jinfo', 'jinfo -sysprops' and 'jinfo -flags' + * @library /lib/testlibrary + * @build jdk.testlibrary.* JInfoHelper + * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError JInfoRunningProcessTest + */ +public class JInfoRunningProcessTest { + + public static void main(String[] args) throws Exception { + testNoOptions(); + testSysprops(); + testFlags(); + } + + private static void testNoOptions() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo(); + output.shouldHaveExitValue(0); + assertTrue(output.getStderr().isEmpty(), "'jinfo' stderr should be empty"); + output.shouldContain("+HeapDumpOnOutOfMemoryError"); + } + + private static void testSysprops() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-sysprops"); + output.shouldHaveExitValue(0); + assertTrue(output.getStderr().isEmpty(), "'jinfo -sysprops' stderr should be empty"); + } + + private static void testFlags() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flags"); + output.shouldHaveExitValue(0); + assertTrue(output.getStderr().isEmpty(), "'jinfo -flags' stderr should be empty"); + output.shouldContain("+HeapDumpOnOutOfMemoryError"); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/tools/jinfo/JInfoSanityTest.java Tue Dec 02 14:36:23 2014 -0800 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import static jdk.testlibrary.Asserts.assertNotEquals; +import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.testlibrary.Asserts.assertFalse; +import jdk.testlibrary.OutputAnalyzer; + +/** + * @test + * @summary The test sanity checks functionality of 'jinfo -h', 'jinfo -help', + * and verifies jinfo exits abnormally if started with invalid options. + * @library /lib/testlibrary + * @build jdk.testlibrary.* JInfoHelper + * @run main JInfoSanityTest + */ +public class JInfoSanityTest { + + public static void main(String[] args) throws Exception { + test_h(); + test_help(); + testVersion(); + testUnknownHost(); + } + + private static void test_h() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfoNoPid("-h"); + output.shouldHaveExitValue(0); + assertFalse(output.getStderr().isEmpty(), "'jinfo -h' stderr should not be empty"); + assertTrue(output.getStdout().isEmpty(), "'jinfo -h' stdout should be empty"); + } + + private static void test_help() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfoNoPid("-help"); + output.shouldHaveExitValue(0); + assertFalse(output.getStderr().isEmpty(), "'jinfo -help' stderr should not be empty"); + assertTrue(output.getStdout().isEmpty(), "'jinfo -help' stdout should be empty"); + } + + private static void testVersion() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfoNoPid("-version"); + output.shouldHaveExitValue(1); + assertFalse(output.getStderr().isEmpty(), "'jinfo -version' stderr should not be empty"); + assertTrue(output.getStdout().isEmpty(), "'jinfo -version' stdout should be empty"); + } + + private static void testUnknownHost() throws Exception { + String unknownHost = "Oja781nh2ev7vcvbajdg-Sda1-C"; + OutputAnalyzer output = JInfoHelper.jinfoNoPid("med@" + unknownHost); + assertNotEquals(output.getExitValue(), 0, "A non-zero exit code should be returned for invalid operation"); + output.shouldContain("UnknownHostException: " + unknownHost); + } + +}
--- a/jdk/test/sun/tools/jps/JpsHelper.java Tue Dec 02 15:12:40 2014 +0100 +++ b/jdk/test/sun/tools/jps/JpsHelper.java Tue Dec 02 14:36:23 2014 -0800 @@ -93,7 +93,7 @@ /** * VM arguments to start test application with */ - public static final String[] VM_ARGS = {"-Xmx512m", "-XX:+UseParallelGC"}; + public static final String[] VM_ARGS = {"-Xmx512m", "-XX:+PrintGCDetails"}; /** * VM flag to start test application with */