6542634: TEST BUG: MISC_REGRESSION tests need to have minimum timeouts examined

Reviewed-by: sla, jbachorik, egahlin
This commit is contained in:
Katja Kantserova 2014-11-18 16:20:16 +01:00
parent f755ca6acc
commit fb6b965e86
6 changed files with 345 additions and 117 deletions

View File

@ -315,6 +315,9 @@ sun/tools/jstatd/TestJstatdExternalRegistry.java generic-all
# 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

View File

@ -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

View File

@ -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;
}
}

View File

@ -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");
}
}

View File

@ -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");
}
}

View File

@ -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);
}
}