8209813: [TESTBUG] rewrite JFR shell tests in Java
Summary: Converted shell tests to Java
Reviewed-by: lmesnik, egahlin
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java Thu Nov 07 13:53:38 2019 -0800
+++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java Thu Nov 07 16:00:53 2019 -0800
@@ -30,6 +30,20 @@
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 {
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.sh Thu Nov 07 13:53:38 2019 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java Thu Nov 07 13:53:38 2019 -0800
+++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java Thu Nov 07 16:00:53 2019 -0800
@@ -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 @@
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 {
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.sh Thu Nov 07 13:53:38 2019 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java Thu Nov 07 13:53:38 2019 -0800
+++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java Thu Nov 07 16:00:53 2019 -0800
@@ -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 @@
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 {
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.sh Thu Nov 07 13:53:38 2019 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/test/jdk/jdk/jfr/event/io/EvilInstrument.java Thu Nov 07 13:53:38 2019 -0800
+++ b/test/jdk/jdk/jfr/event/io/EvilInstrument.java Thu Nov 07 16:00:53 2019 -0800
@@ -53,7 +53,8 @@
* @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
*/
--- a/test/jdk/jdk/jfr/event/io/MakeJAR.sh Thu Nov 07 13:53:38 2019 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java Thu Nov 07 13:53:38 2019 -0800
+++ b/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java Thu Nov 07 16:00:53 2019 -0800
@@ -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.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());
}
}
--- a/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.sh Thu Nov 07 13:53:38 2019 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 $?
--- a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.flags Thu Nov 07 13:53:38 2019 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-+FlightRecorder
\ No newline at end of file
--- a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java Thu Nov 07 13:53:38 2019 -0800
+++ b/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java Thu Nov 07 16:00:53 2019 -0800
@@ -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.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 static void generateFlagsFile() throws Exception {
+ Files.writeString(Paths.get("", "TestVMInfoEvent.flags"), "+UseSerialGC");
+ }
}
--- a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.sh Thu Nov 07 13:53:38 2019 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 $?
--- a/test/jdk/jdk/jfr/javaagent/JavaAgentBuilder.java Thu Nov 07 13:53:38 2019 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 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
- * 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.
- */
-
-package jdk.test.lib.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import jdk.test.lib.Utils;
-import jdk.test.lib.util.JarUtils;
-
-/**
- * A builder for a common Java agent.
- * Can be used directly from the jtreg test header to
- * build a java agent before the test is executed.
- *
- * E.g.:
- * @run driver jdk.test.lib.util.JavaAgentBuilder
- * jdk.jfr.javaagent.EventEmitterAgent EventEmitterAgent.jar
- *
- */
-public class JavaAgentBuilder {
-
- /**
- * Build a java agent jar file with a given agent class.
- *
- * @param args[0] fully qualified name of an agent class
- * @param args[1] file name of the agent jar to be created
- * @throws IOException
- */
- public static void main(String... args) throws IOException {
- String agentClass = args[0];
- String agentJar = args[1];
- System.out.println("Building " + agentJar + " with agent class " + agentClass);
- build(agentClass, agentJar);
- }
-
- /**
- * Build a java agent jar file with a given agent class.
- * The agent class will be added as both premain class and agent class.
- *
- * @param agentClass fully qualified name of an agent class
- * @param agentJar file name of the agent jar to be created
- * the file will be placed in a current work directory
- * @throws IOException
- */
- public static void build(String agentClass, String agentJar) throws IOException {
- Manifest mf = new Manifest();
- Attributes attrs = mf.getMainAttributes();
- attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
- attrs.putValue("Premain-Class", agentClass);
- attrs.putValue("Agent-Class", agentClass);
-
- Path jarFile = Paths.get(".", agentJar);
- String testClasses = Utils.TEST_CLASSES;
- String agentPath = agentClass.replace(".", File.separator) + ".class";
- Path agentFile = Paths.get(testClasses, agentPath);
- Path dir = Paths.get(testClasses);
- JarUtils.createJarFile(jarFile, mf, dir, agentFile);
- System.out.println("Agent built:" + jarFile.toAbsolutePath());
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/util/JavaAgentBuilder.java Thu Nov 07 16:00:53 2019 -0800
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 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
+ * 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.
+ */
+
+package jdk.test.lib.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import jdk.test.lib.Utils;
+import jdk.test.lib.util.JarUtils;
+
+/**
+ * A builder for a common Java agent.
+ * Can be used directly from the jtreg test header to
+ * build a java agent before the test is executed.
+ *
+ * E.g.:
+ * @run driver jdk.test.lib.util.JavaAgentBuilder
+ * jdk.jfr.javaagent.EventEmitterAgent EventEmitterAgent.jar
+ *
+ */
+public class JavaAgentBuilder {
+
+ /**
+ * Build a java agent jar file with a given agent class.
+ *
+ * @param args[0] fully qualified name of an agent class
+ * @param args[1] file name of the agent jar to be created
+ * @throws IOException
+ */
+ public static void main(String... args) throws IOException {
+ String agentClass = args[0];
+ String agentJar = args[1];
+ System.out.println("Building " + agentJar + " with agent class " + agentClass);
+ build(agentClass, agentJar);
+ }
+
+ /**
+ * Build a java agent jar file with a given agent class.
+ * The agent class will be added as both premain class and agent class.
+ *
+ * @param agentClass fully qualified name of an agent class
+ * @param agentJar file name of the agent jar to be created
+ * the file will be placed in a current work directory
+ * @throws IOException
+ */
+ public static void build(String agentClass, String agentJar) throws IOException {
+ Manifest mf = new Manifest();
+ Attributes attrs = mf.getMainAttributes();
+ attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+ attrs.putValue("Premain-Class", agentClass);
+ attrs.putValue("Agent-Class", agentClass);
+
+ Path jarFile = Paths.get(".", agentJar);
+ String testClasses = Utils.TEST_CLASSES;
+ String agentPath = agentClass.replace(".", File.separator) + ".class";
+ Path agentFile = Paths.get(testClasses, agentPath);
+ Path dir = Paths.get(testClasses);
+ JarUtils.createJarFile(jarFile, mf, dir, agentFile);
+ System.out.println("Agent built:" + jarFile.toAbsolutePath());
+ }
+}