8209813: [TESTBUG] rewrite JFR shell tests in Java
Converted shell tests to Java Reviewed-by: lmesnik, egahlin
This commit is contained in:
parent
fc2a8abcc0
commit
d5dce23506
@ -30,6 +30,20 @@ import jdk.test.lib.jfr.EventVerifier;
|
||||
import jdk.test.lib.jfr.GCHelper;
|
||||
import sun.hotspot.WhiteBox;
|
||||
|
||||
/*
|
||||
* @test TestGCHeapConfigurationEventWith32BitOops
|
||||
* @key jfr
|
||||
* @requires vm.hasJFR
|
||||
* @requires vm.gc == "Parallel" | vm.gc == null
|
||||
* @requires os.family == "linux" | os.family == "windows"
|
||||
* @requires sun.arch.data.model == "64"
|
||||
* @library /test/lib /test/jdk
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx100m -Xms100m -XX:InitialHeapSize=100m -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWith32BitOops
|
||||
*/
|
||||
|
||||
|
||||
/* See the shell script wrapper for the flags used when invoking the JVM */
|
||||
public class TestGCHeapConfigurationEventWith32BitOops extends GCHeapConfigurationEventTester {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -1,61 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2013, 2018, 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 TestGCHeapConfigurationEventWith32BitOops
|
||||
# @key jfr
|
||||
# @requires vm.hasJFR
|
||||
# @requires vm.gc == "Parallel" | vm.gc == null
|
||||
# @library /test/lib /test/jdk
|
||||
# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWith32BitOops sun.hotspot.WhiteBox
|
||||
# @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
# @run shell TestGCHeapConfigurationEventWith32BitOops.sh
|
||||
|
||||
uses_64_bit_testjava() {
|
||||
${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null
|
||||
}
|
||||
|
||||
uses_windows_or_linux() {
|
||||
case `uname -s` in
|
||||
Linux | CYGWIN* | Windows* )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWith32BitOops'
|
||||
|
||||
OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx100m -Xms100m -XX:InitialHeapSize=100m -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI'
|
||||
|
||||
if [ -z "${TESTCLASSPATH}" ]; then
|
||||
echo "Using TESTCLASSES"
|
||||
MY_CLASSPATH=${TESTCLASSES}
|
||||
else
|
||||
echo "Using TESTCLASSPATH"
|
||||
MY_CLASSPATH=${TESTCLASSPATH}
|
||||
fi
|
||||
|
||||
if uses_windows_or_linux && uses_64_bit_testjava; then
|
||||
printenv
|
||||
echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}"
|
||||
${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}
|
||||
fi
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, 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
|
||||
@ -28,6 +28,19 @@ package jdk.jfr.event.gc.configuration;
|
||||
import jdk.jfr.consumer.RecordedEvent;
|
||||
import jdk.test.lib.jfr.EventVerifier;
|
||||
|
||||
/*
|
||||
* @test TestGCHeapConfigurationEventWith32BitOops
|
||||
* @key jfr
|
||||
* @requires vm.hasJFR
|
||||
* @requires vm.gc == "Parallel" | vm.gc == null
|
||||
* @requires os.family == "linux" | os.family == "windows"
|
||||
* @requires sun.arch.data.model == "64"
|
||||
* @library /test/lib /test/jdk
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx31g jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithHeapBasedOops
|
||||
*/
|
||||
|
||||
/* See the shell script wrapper for the flags used when invoking the JVM */
|
||||
public class TestGCHeapConfigurationEventWithHeapBasedOops extends GCHeapConfigurationEventTester {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -1,63 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2013, 2018, 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 TestGCHeapConfigurationEventWithHeapBasedOops
|
||||
# @key jfr
|
||||
# @requires vm.hasJFR
|
||||
# @requires vm.gc == "Parallel" | vm.gc == null
|
||||
# @library /test/lib /test/jdk
|
||||
# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithHeapBasedOops
|
||||
# @run shell TestGCHeapConfigurationEventWithHeapBasedOops.sh
|
||||
|
||||
uses_64_bit_testjava() {
|
||||
${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null
|
||||
}
|
||||
|
||||
uses_windows_or_linux() {
|
||||
case `uname -s` in
|
||||
Linux | CYGWIN* | Windows* )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithHeapBasedOops'
|
||||
|
||||
# NOTE: Can't use 32g heap with UseCompressedOops. Hopefully the 31g heap will
|
||||
# force HeapBased compressed oops to be enalbed by hoping that there isn't
|
||||
# enough space in the lowest 1 GB of the virtual address space.
|
||||
OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -Xmx31g -XX:+UseCompressedOops'
|
||||
|
||||
if [ -z "${TESTCLASSPATH}" ]; then
|
||||
echo "Using TESTCLASSES"
|
||||
MY_CLASSPATH=${TESTCLASSES}
|
||||
else
|
||||
echo "Using TESTCLASSPATH"
|
||||
MY_CLASSPATH=${TESTCLASSPATH}
|
||||
fi
|
||||
|
||||
if uses_windows_or_linux && uses_64_bit_testjava; then
|
||||
printenv
|
||||
echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}"
|
||||
${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}
|
||||
fi
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, 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
|
||||
@ -28,6 +28,17 @@ package jdk.jfr.event.gc.configuration;
|
||||
import jdk.jfr.consumer.RecordedEvent;
|
||||
import jdk.test.lib.jfr.EventVerifier;
|
||||
|
||||
/*
|
||||
* @test TestGCHeapConfigurationEventWithZeroBasedOops
|
||||
* @key jfr
|
||||
* @requires vm.hasJFR
|
||||
* @requires vm.gc == "Parallel" | vm.gc == null
|
||||
* @requires os.family == "linux" | os.family == "windows"
|
||||
* @requires sun.arch.data.model == "64"
|
||||
* @library /test/lib /test/jdk
|
||||
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx4g jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithZeroBasedOops
|
||||
*/
|
||||
|
||||
/* See the shell script wrapper for the flags used when invoking the JVM */
|
||||
public class TestGCHeapConfigurationEventWithZeroBasedOops extends GCHeapConfigurationEventTester {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -1,60 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2013, 2018, 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 TestGCHeapConfigurationEventWithZeroBasedOops
|
||||
# @key jfr
|
||||
# @requires vm.hasJFR
|
||||
# @requires vm.gc == "Parallel" | vm.gc == null
|
||||
# @library /test/lib /test/jdk
|
||||
# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithZeroBasedOops
|
||||
# @run shell TestGCHeapConfigurationEventWithZeroBasedOops.sh
|
||||
|
||||
uses_64_bit_testjava() {
|
||||
${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null
|
||||
}
|
||||
|
||||
uses_windows_or_linux() {
|
||||
case `uname -s` in
|
||||
Linux | CYGWIN* | Windows* )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithZeroBasedOops'
|
||||
|
||||
OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx4g'
|
||||
|
||||
if [ -z "${TESTCLASSPATH}" ]; then
|
||||
echo "Using TESTCLASSES"
|
||||
MY_CLASSPATH=${TESTCLASSES}
|
||||
else
|
||||
echo "Using TESTCLASSPATH"
|
||||
MY_CLASSPATH=${TESTCLASSPATH}
|
||||
fi
|
||||
|
||||
if uses_windows_or_linux && uses_64_bit_testjava; then
|
||||
printenv
|
||||
echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}"
|
||||
${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}
|
||||
fi
|
@ -53,7 +53,8 @@ import jdk.test.lib.Utils;
|
||||
* @modules java.instrument
|
||||
*
|
||||
* @build jdk.jfr.event.io.EvilInstrument
|
||||
* @run shell MakeJAR.sh EvilInstrument 'Can-Redefine-Classes: true'
|
||||
* @run driver jdk.test.lib.util.JavaAgentBuilder
|
||||
* jdk.jfr.event.io.EvilInstrument EvilInstrument.jar
|
||||
* @run main/othervm -javaagent:EvilInstrument.jar jdk.jfr.event.io.EvilInstrument
|
||||
*/
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
AGENT="$1"
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTJAVA=${TESTJAVA}"
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${COMPILEJAVA}" ]
|
||||
then
|
||||
COMPILEJAVA=${TESTJAVA}
|
||||
fi
|
||||
|
||||
JAVAC="${COMPILEJAVA}/bin/javac -g"
|
||||
JAR="${COMPILEJAVA}/bin/jar"
|
||||
|
||||
cp ${TESTSRC}/${AGENT}.java .
|
||||
${JAVAC} -cp ${TESTCLASSPATH} ${AGENT}.java
|
||||
|
||||
echo "Manifest-Version: 1.0" > ${AGENT}.mf
|
||||
echo Premain-Class: jdk.jfr.event.io.${AGENT} >> ${AGENT}.mf
|
||||
shift
|
||||
while [ $# != 0 ] ; do
|
||||
echo $1 >> ${AGENT}.mf
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
${JAR} cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}*.class
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, 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
|
||||
@ -36,30 +36,51 @@ import jdk.jfr.Recording;
|
||||
import jdk.jfr.consumer.RecordedEvent;
|
||||
import jdk.test.lib.jfr.EventNames;
|
||||
import jdk.test.lib.jfr.Events;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key jfr
|
||||
* @requires vm.hasJFR
|
||||
* @library /test/lib
|
||||
* @run main jdk.jfr.event.os.TestInitialEnvironmentVariable
|
||||
*/
|
||||
public class TestInitialEnvironmentVariable {
|
||||
private final static String EVENT_NAME = EventNames.InitialEnvironmentVariable;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Map<String, String> env = new HashMap<>();
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(Test.class.getName());
|
||||
setEnv(pb.environment());
|
||||
(new OutputAnalyzer(pb.start())).shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
static void setEnv(Map<String, String> env) {
|
||||
env.put("keytest1", "value1");
|
||||
env.put("keytest2", "value 2");
|
||||
}
|
||||
|
||||
Recording recording = new Recording();
|
||||
recording.enable(EVENT_NAME);
|
||||
recording.start();
|
||||
recording.stop();
|
||||
List<RecordedEvent> events = Events.fromRecording(recording);
|
||||
Events.hasEvents(events);
|
||||
for (RecordedEvent event : events) {
|
||||
System.out.println("Event: " + event);
|
||||
String key = Events.assertField(event, "key").notNull().getValue();
|
||||
String value = Events.assertField(event, "value").notNull().getValue();
|
||||
if (env.containsKey(key)) {
|
||||
assertEquals(value, env.get(key), "Wrong value for key: " + key);
|
||||
env.remove(key);
|
||||
static class Test {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Map<String, String> env = new HashMap<>();
|
||||
setEnv(env);
|
||||
|
||||
Recording recording = new Recording();
|
||||
recording.enable(EVENT_NAME);
|
||||
recording.start();
|
||||
recording.stop();
|
||||
List<RecordedEvent> events = Events.fromRecording(recording);
|
||||
Events.hasEvents(events);
|
||||
for (RecordedEvent event : events) {
|
||||
System.out.println("Event: " + event);
|
||||
String key = Events.assertField(event, "key").notNull().getValue();
|
||||
String value = Events.assertField(event, "value").notNull().getValue();
|
||||
if (env.containsKey(key)) {
|
||||
assertEquals(value, env.get(key), "Wrong value for key: " + key);
|
||||
env.remove(key);
|
||||
}
|
||||
}
|
||||
assertTrue(env.isEmpty(), "Missing env keys " + env.keySet());
|
||||
}
|
||||
assertTrue(env.isEmpty(), "Missing env keys " + env.keySet());
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2013, 2018, 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
|
||||
# @key jfr
|
||||
# @requires vm.hasJFR
|
||||
# @library /test/lib
|
||||
# @build jdk.jfr.event.os.TestInitialEnvironmentVariable
|
||||
# @run shell TestInitialEnvironmentVariable.sh
|
||||
|
||||
echo -------------------------------------------------------------
|
||||
echo "TESTCLASSES='$TESTCLASSES'"
|
||||
echo "TESTSRC='$TESTSRC'"
|
||||
echo Launching test for `basename $0 .sh`
|
||||
echo -------------------------------------------------------------
|
||||
keytest1="value1";export keytest1
|
||||
keytest2="value 2";export keytest2
|
||||
${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} jdk.jfr.event.os.TestInitialEnvironmentVariable
|
||||
exit $?
|
@ -1 +0,0 @@
|
||||
+FlightRecorder
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, 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,10 +25,10 @@
|
||||
|
||||
package jdk.jfr.event.runtime;
|
||||
|
||||
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -39,13 +39,21 @@ import jdk.test.lib.jfr.EventNames;
|
||||
import jdk.test.lib.jfr.Events;
|
||||
|
||||
/**
|
||||
* The test will verify that JVM Information event values are delivered
|
||||
* and compare them with the RuntimeMXBean's values.
|
||||
* @test
|
||||
* @key jfr
|
||||
* @requires vm.hasJFR
|
||||
* @library /test/lib
|
||||
* @run driver jdk.jfr.event.runtime.TestVMInfoEvent generateFlagsFile
|
||||
* @run main/othervm -XX:Flags=TestVMInfoEvent.flags -Xmx500m jdk.jfr.event.runtime.TestVMInfoEvent arg1 arg2
|
||||
*/
|
||||
public class TestVMInfoEvent {
|
||||
private final static String EVENT_NAME = EventNames.JVMInformation;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if( (args.length > 0) && ("generateFlagsFile".equals(args[0])) ) {
|
||||
generateFlagsFile();
|
||||
return;
|
||||
}
|
||||
RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean();
|
||||
Recording recording = new Recording();
|
||||
recording.enable(EVENT_NAME);
|
||||
@ -76,4 +84,7 @@ public class TestVMInfoEvent {
|
||||
}
|
||||
}
|
||||
|
||||
public static void generateFlagsFile() throws Exception {
|
||||
Files.writeString(Paths.get("", "TestVMInfoEvent.flags"), "+UseSerialGC");
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2013, 2018, 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
|
||||
# @key jfr
|
||||
# @requires vm.hasJFR
|
||||
# @library /test/lib /test/jdk
|
||||
# @build jdk.jfr.event.runtime.TestVMInfoEvent
|
||||
# @run shell TestVMInfoEvent.sh
|
||||
|
||||
echo -------------------------------------------------------------
|
||||
echo Launching test for `basename $0 .sh`
|
||||
echo -------------------------------------------------------------
|
||||
|
||||
${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -XX:Flags=${TESTSRC}/TestVMInfoEvent.flags jdk.jfr.event.runtime.TestVMInfoEvent arg1 arg2
|
||||
exit $?
|
Loading…
Reference in New Issue
Block a user