Skip to content

Commit

Permalink
Merge pull request #11556 from OscarQQ/testRASAPI
Browse files Browse the repository at this point in the history
Port testRASAPI into openj9
  • Loading branch information
llxia committed Jan 22, 2021
2 parents 3cd0af8 + 6bed3f4 commit 8c1868d
Show file tree
Hide file tree
Showing 106 changed files with 15,445 additions and 0 deletions.
123 changes: 123 additions & 0 deletions test/functional/RasapiTest/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0"?>

<!--
Copyright (c) 2016, 2021 IBM Corp. and others
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
distribution and is available at https://www.eclipse.org/legal/epl-2.0/
or the Apache License, Version 2.0 which accompanies this distribution and
is available at https://www.apache.org/licenses/LICENSE-2.0.
This Source Code may also be made available under the following
Secondary Licenses when the conditions for such availability set
forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
General Public License, version 2 with the GNU Classpath
Exception [1] and GNU General Public License, version 2 with the
OpenJDK Assembly Exception [2].
[1] https://www.gnu.org/software/classpath/license.html
[2] http://openjdk.java.net/legal/assembly-exception.html
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
-->
<project name="Build script for com.ibm.jvm.ras.tests" default="check" basedir=".">

<property name="build.jar.tests" value="com.ibm.jvm.ras.tests.jar" />
<property name="DEST" value="${BUILD_ROOT}/functional/RasapiTest" />
<property name="src.level" value="1.7"/>
<property name="target.level" value="1.7"/>
<property name="source.dir" location="./src" />
<property name="dummy.source.dir" location="./dummy_src" />
<property name="build.dir" location="./build" />
<property name="dist.dir" location="./dist" />
<property name="src" location="." />
<property name="LIB" value="junit4"/>
<import file="${TEST_ROOT}/TKG/scripts/getDependencies.xml"/>
<!-- <property name="build.cp" value="${BUILD_ROOT}/build/j9jcl/source/ive/lib/jclSC18/classes-vm.zip"/> -->

<path id="build.cp">
<fileset dir="${LIB_DIR}/" includes="junit4.jar" />
</path>

<target name="help">
<echo>Ant build script to generate com.ibm.jvm.ras.tests.jar
</echo>
</target>

<target name="clean">
<echo>Cleaning build directory ${build.dir}</echo>
<mkdir dir="${dist.dir}"/>
<delete failonerror="false" verbose="true">
<fileset dir="${dist.dir}" includes="${build.jar.tests}" />
</delete>
<mkdir dir="${build.dir}/bin"/>
<delete failonerror="false" verbose="false">
<fileset dir="${build.dir}" includes="bin/**/*" />
</delete>
</target>

<target name="compile" depends="clean">

<echo>Ant version is ${ant.version}</echo>
<echo>Compiling code to ${build.dir} and packaging ${build.jar.tests} to ${dist.dir}</echo>

<echo>============COMPILER SETTINGS============</echo>
<echo>===fork: yes</echo>
<echo>===executable: ${compiler.javac}</echo>
<echo>===source: ${src.level}</echo>
<echo>===target: ${target.level}</echo>
<echo>===debug: on</echo>
<echo>===destdir: ${build.dir}</echo>

<mkdir dir="${build.dir}/bin"/>
<mkdir dir="${dist.dir}"/>
<javac destdir="${build.dir}/bin" source="${src.level}" target="${target.level}"
debug="true" fork="true" executable="${compiler.javac}" encoding="UTF-8" classpathref="build.cp">
<!-- Locally there can be a problem with old versions of the DTFJ API which don't support Image.close().
I could remove that call but it causes us to leak files and blocks checking if files are system
dumps so this points to a recent version of dtfj-interface.jar to compile against instead. -->
<!-- <compilerarg value="-Xbootclasspath/p:${build.cp}"/> -->
<src path="${source.dir}"/>
<!-- The boot compiler, unless it's IBM 1.8, won't have the right API to build all these tests.
We have a hollowed out version in dummy_src for the tests to compile against -->
<src path="${dummy.source.dir}"/>
</javac>

<!-- jar the .class files except the dummy source -->
<jar destfile="${dist.dir}/${build.jar.tests}">
<fileset dir="${build.dir}/bin">
<exclude name="com/ibm/jvm/*.class" />
</fileset>
</jar>

<copy todir="${dist.dir}">
<fileset dir="${LIB_DIR}/" includes="junit4.jar" />
</copy>

<copy todir="${dist.dir}">
<fileset dir="." includes="test.xml"/>
</copy>
</target>

<target name="check" >
<if>
<or>
<equals arg1="${JDK_IMPL}" arg2="ibm" />
<equals arg1="${JDK_IMPL}" arg2="openj9" />
</or>
<then>
<antcall target="build" inheritall="true" />
</then>
</if>
</target>

<target name="build" depends="compile">
<mkdir dir="${DEST}"/>
<copy todir="${DEST}">
<fileset dir="${dist.dir}" includes="*.xml,**/*.jar,**/*.xml"/>
<fileset dir="${src}" includes="*.mk"/>
</copy>
</target>

</project>
163 changes: 163 additions & 0 deletions test/functional/RasapiTest/dummy_src/com/ibm/jvm/Dump.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*******************************************************************************
* Copyright (c) 2006, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package com.ibm.jvm;

import java.security.AccessController;
import java.security.PrivilegedAction;

/**
* This class is used to trigger and configure the options used to produce different
* types of diagnostic dumps available from the IBM JVM.
* <p>
* -Xdump must be enabled on the command line or the functions that attempt to cause
* dumps to be created or set options will fail with a java.lang.RuntimeException.
* <p>
* The methods on this class can be used to trigger dumps, configure dump options and
* query those options.
* <p>
* The {@link #JavaDump()}, {@link #SystemDump()}, {@link #HeapDump()} and {@link #SnapDump()}
* methods trigger dumps of the given type with no options and no return value.
* Although they are not configurable they do provide an easy API to use via reflection
* if your code is likely to run on both IBM and non-IBM JVMs and you only need the most
* basic ability to create a dump.
* <p>
* The {@link #javaDumpToFile()}, {@link #systemDumpToFile()}, {@link #heapDumpToFile()} and
* {@link #snapDumpToFile()} methods allow a destination file to be optionally specified and
* will return the full path of the file that is created.
* <br>
* The recommended usage of the {@link #javaDumpToFile()}, {@link #systemDumpToFile()},
* {@link #heapDumpToFile()} and {@link #snapDumpToFile()}
* methods is to call the no argument versions of these calls rather than specifying a file
* name as this will trigger a dump to the default location. Your dump file will go to the
* default location specified by any -Xdump options given to the JVM at startup time following
* the user or administrators preferences.
* The location the dump file was written to will be returned as a String so the generated
* file can be located.
* <p>
* The {@link #triggerDump(String)} method offers similar functionality as the DumpToFile() methods
* but with the ability to specify any dump options that are meaningful for a dump that occurs
* immediately. The options are passed as a String that follows the same format as the option
* strings passed to -Xdump on the command line.<br>
* For example:
* <ul>
* <li>triggerDump("java") is equivalent to javaDumpToFile() or javaDumpToFile(null) all three
* will cause a javadump to be generated to the default location.</li>
* <li>triggerDump("heap:file=heapdump.phd") is equivalent to heapDumpToFile("heapdump.phd")</li>
* <li>triggerDump("heap:file=heapdump.txt,opts=CLASSIC") allows you to specify the CLASSIC
* option to triggerDump and produce a text format heap dump which is not possible through
* the *DumpToFile(String filename) or *Dump() methods.</li>
* <li>triggerDump("java:request=exclusive") will trigger a java dump with the request option set
* to "exclusive" and any other options, including the file name, taken from the default options
* for java dumps</li>
* </ul>
* <p>
* The {@link #setDumpOptions(String)} method allows dump options that will cause or change how
* a dump occurs for an event in the future to be specified. The options are specified in the
* format expected by the -Xdump command line. Not all options can be configured at runtime and
* this method will throw an InvalidDumpOption exception if it is passed an option that cannot be set.<p>
* For example:
* <ul>
* <li>setDumpOptions("java") - enable java dumps with the default settings.</li>
* <li>setDumpOptions("java:events=vmstop") - enable java dumps on the vmstop event (this will
* occur once when the JVM exits).</li>
* <li>setDumpOptions("none") - disable all dump agents on all events.</li>
* <li>setDumpOptions("heap:none") - disable all heap dump agents on all events.</li>
* <li>setDumpOptions("system:none:events=systhrow,filter=java/lang/OutOfMemoryError") - disable
* system dumps on systhrow events for OutOfMemory errors only.</li>
* </ul>
* For full details of dump options see the section on dump agents in the documentation for the IBM JVM.
* <p>
* The {@link #queryDumpOptions()} method returns a String array containing a snapshot of the currently
* configured dump options. Each String is in the format expected by the -Xdump command line
* option and setDumpOptions. The Strings can be passed back to setDumpOptions to recreate
* the current dump agent configuration at a later time.
* <p>
* The {@link #resetDumpOptions()} method resets the dump options to the settings specified when the
* JVM was started removing any additional configuration done since then.<br>
* If you wish to change the dump configuration at runtime and then reset it to an earlier
* state that included additional runtime configuration done through this API or JVMTI you should
* consider saving the result of queryDumpOptions and then later use {@link #setDumpOptions(String)}
* to restore that configuration after a call to setDumpOptions("none") to clear all dump agent
* configuration.
*/
public class Dump {

public static void JavaDump() {
}

public static void HeapDump() {
}

public static void SystemDump() {
}

private Dump() {
}

public static void SnapDump() {
}

public static String javaDumpToFile(String fileNamePattern ) throws InvalidDumpOptionException {
return null;
}

public static String javaDumpToFile() {
return null;
}

public static String heapDumpToFile(String fileNamePattern ) throws InvalidDumpOptionException {
return null;
}

public static String heapDumpToFile() {
return null;
}


public static String systemDumpToFile(String fileNamePattern) throws InvalidDumpOptionException {
return null; }

public static String systemDumpToFile() {
return null;
}
public static String snapDumpToFile(String fileNamePattern) throws InvalidDumpOptionException {
return null;
}
public static String snapDumpToFile() {
return null;
}

public static String triggerDump(String dumpOptions) throws InvalidDumpOptionException {
return null;
}

public static void setDumpOptions(String dumpOptions) throws InvalidDumpOptionException, DumpConfigurationUnavailableException {
}

public static String[] queryDumpOptions() {
return null;
}

public static void resetDumpOptions() throws DumpConfigurationUnavailableException {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2006, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package com.ibm.jvm;

public class DumpConfigurationUnavailableException extends Exception {

public DumpConfigurationUnavailableException(String message) {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2006, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package com.ibm.jvm;

import java.security.BasicPermission;

public class DumpPermission extends BasicPermission {

public DumpPermission() {
super(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2006, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package com.ibm.jvm;

public class InvalidDumpOptionException extends Exception {

public InvalidDumpOptionException(String message) {
}

}

0 comments on commit 8c1868d

Please sign in to comment.