You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2006/11/15 22:33:36 UTC
svn commit: r475438 - in /incubator/harmony/enhanced/drlvm/trunk:
build/make/ build/make/targets/ vm/tests/jvmti/ vm/tests/jvmti/VMInit1/
Author: gshimansky
Date: Wed Nov 15 13:33:36 2006
New Revision: 475438
URL: http://svn.apache.org/viewvc?view=rev&rev=475438
Log:
Applied HARMONY-2151 [drlvm][jvmti] JVMTI acceptance tests support for drlvm and one simple test
Tests run on ubuntu and win32. I had to exclude all architectures except for ia32 because test on x86_64 fails on assertions. In fact JVMTI is not yet implemented on x86_64
Added:
incubator/harmony/enhanced/drlvm/trunk/build/make/targets/jvmti.test.xml
incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/
incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/
incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.java
Modified:
incubator/harmony/enhanced/drlvm/trunk/build/make/build.xml
incubator/harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml
incubator/harmony/enhanced/drlvm/trunk/build/make/targets/test.xml
Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/build.xml?view=diff&rev=475438&r1=475437&r2=475438
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/build.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/build.xml Wed Nov 15 13:33:36 2006
@@ -35,6 +35,7 @@
designated components
smoke.test - builds and runs smoke tests for the
designated components
+ jvmti.test - builds and runs JVMTI tests
test - builds and runs unit & smoke tests for the
designated components
@@ -393,14 +394,31 @@
</target>
<!-- Main target to run smoke tests -->
- <target name="smoke.test" depends="init, set.target.to.smoke.test, process.components" />
- <target name="set.target.to.smoke.test">
+ <target name="smoke.test" depends="setup, init">
<property name="target" value="smoke.test" />
+ <subant buildpath="." antfile="build_component.xml" target="build" inheritall="true" failonerror="true">
+ <property name="_component" value="vm" />
+ <property name="_target" value="${target}" />
+ </subant>
</target>
<!-- Main target to run kernel tests -->
<target name="kernel.test" depends="extern_dep,init" >
<ant antfile="targets/kernel.test.xml" target="kernel.test"/>
+ </target>
+
+ <!-- Main target to run jvmti tests /-->
+ <target name="jvmti.test" depends="setup, init">
+ <if>
+ <equals arg1="${build.arch}" arg2="ia32" />
+ <then>
+ <property name="target" value="jvmti.test" />
+ <subant buildpath="." antfile="build_component.xml" target="build" inheritall="true" failonerror="true">
+ <property name="_component" value="vm" />
+ <property name="_target" value="${target}" />
+ </subant>
+ </then>
+ </if>
</target>
<!-- process (build/create javadoc/etc...) all the specified components -->
Added: incubator/harmony/enhanced/drlvm/trunk/build/make/targets/jvmti.test.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/targets/jvmti.test.xml?view=auto&rev=475438
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/targets/jvmti.test.xml (added)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/targets/jvmti.test.xml Wed Nov 15 13:33:36 2006
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project name="JVMTI TESTS">
+ <property name="jvmti.test.src" location="${build.VM.home}/tests/jvmti" />
+ <property name="jvmti.test.dir" location="${build.semi.dir}/jvmti.tests"/>
+ <property name="jvmti.test.class.path" location="${jvmti.test.dir}/classes"/>
+ <property name="jvmti.test.native.path" location="${jvmti.test.dir}/native"/>
+
+ <patternset id="jvmti.test.src.pattern">
+ <include name="*" />
+ <!-- This test fails -->
+ <!--exclude name="FailingTest" /-->
+ </patternset>
+
+ <property name="jvmti.test.timeout" value="180000" />
+
+ <target name="compile-jvmti-tests-prepare" depends="">
+ <dirset id="jvmti.test.src.dirs.set"
+ dir="${jvmti.test.src}">
+ <patternset refid="jvmti.test.src.pattern" />
+ </dirset>
+
+ <pathconvert pathsep=","
+ property="jvmti.test.src.dirs.list"
+ refid="jvmti.test.src.dirs.set" />
+ </target>
+
+ <target name="compile-jvmti-tests-java"
+ depends="compile-jvmti-tests-prepare, init_component">
+ <mkdir dir="${jvmti.test.class.path}" />
+ <for list="${jvmti.test.src.dirs.list}" param="directory"
+ delimiter=",">
+ <sequential>
+ <var name="testdir" unset="true" />
+ <basename property="testdir" file="@{directory}" />
+ <javac destdir="${jvmti.test.class.path}"
+ source="1.5" target="1.5" listfiles="true"
+ debug="true">
+ <src path="${jvmti.test.src}" />
+ <include name="${testdir}/**/*.java" />
+ </javac>
+ </sequential>
+ </for>
+ </target>
+
+ <target name="compile-jvmti-tests-native"
+ depends="compile-jvmti-tests-prepare, init_component">
+ <mkdir dir="${jvmti.test.native.path}" />
+
+ <for list="${jvmti.test.src.dirs.list}" param="directory"
+ delimiter=",">
+ <sequential>
+ <var name="outputdir" unset="true" />
+ <basename property="outputdir" file="@{directory}" />
+ <echo message="## Compiling JVMTI natives in: @{directory}" />
+ <mkdir dir="${jvmti.test.native.path}/${outputdir}" />
+ <cc name="${build.cxx}"
+ debug="true"
+ runtime="dynamic"
+ multithreaded="true"
+ link="shared"
+ outfile="${jvmti.test.native.path}/${outputdir}/${outputdir}">
+ <includepath path="${build.deploy.dir}/include" />
+ <select os="lnx">
+ <linkerarg value="-lstdc++" />
+ </select>
+ <fileset dir="@{directory}">
+ <include name="**/*.cpp" />
+ </fileset>
+ </cc>
+ </sequential>
+ </for>
+ </target>
+
+ <target name="pre-jvmti-test" depends="compile-jvmti-tests-java,
+ compile-jvmti-tests-native">
+ <condition property="junit.jar" value="${junit.home}/junit.jar">
+ <isset property="junit.home" />
+ </condition>
+ <property name="junit.jar"
+ location="${external.dep.CLASSLIB}/depends/jars/junit_3.8.2/junit.jar" />
+ <if>
+ <not>
+ <available file="${junit.jar}"/>
+ </not>
+ <then>
+ <echo>
+ ==============================================
+ Please set the classpath of junit as follows:
+ build.bat -Djunit.jar=%JUNIT_HOME% test
+ ==============================================
+ </echo>
+ <fail message="JVMTI tests misconfigured" />
+ </then>
+ </if>
+
+ <delete quiet="true" dir="${jvmti.test.dir}/reports" />
+ <delete quiet="true" dir="${jvmti.test.dir}/ref-reports" />
+ <mkdir dir="${jvmti.test.dir}/reports" />
+ <mkdir dir="${jvmti.test.dir}/ref-reports" />
+ </target>
+
+ <target name="run-jvmti-tests">
+ <echo>
+ ==================================
+ Run JVMTI tests using ${jvmti.tests.mode}
+ ==================================
+ </echo>
+
+ <property name="report.dir"
+ location="${jvmti.test.dir}/reports/${jvmti.tests.mode}"/>
+ <mkdir dir="${report.dir}" />
+
+ <for list="${jvmti.test.src.dirs.list}" param="directory"
+ delimiter=",">
+ <sequential>
+ <var name="testname" unset="true" />
+ <basename property="testname" file="@{directory}" />
+ <echo message="Running ${testname}" />
+ <junit fork="yes"
+ failureproperty="${testname}.failed"
+ timeout="${jvmti.test.timeout}"
+ jvm="${build.deploy.dir}/bin/java">
+ <jvmarg value="-Dvm.assert_dialog=0" />
+ <select os="win">
+ <jvmarg
+ value="-agentpath:${jvmti.test.native.path}/${testname}/${testname}.dll"
+ />
+ </select>
+ <select os="lnx">
+ <jvmarg
+ value="-agentpath:${jvmti.test.native.path}/${testname}/lib${testname}.so"
+ />
+ </select>
+ <jvmarg line="${jvmti.tests.mode.switch}" />
+ <formatter type="brief"/>
+ <formatter type="xml" />
+ <classpath path="${jvmti.test.class.path}" />
+ <test name="${testname}.${testname}" todir="${report.dir}" />
+ </junit>
+ <fail if="${testname}.failed" />
+ </sequential>
+ </for>
+ </target>
+
+ <target name="jvmti.test" depends="pre-jvmti-test">
+ <if>
+ <equals arg1="${build.arch}" arg2="ia32" />
+ <then>
+ <antcall target="run-jvmti-tests">
+ <param name="jvmti.tests.mode" value="jit" />
+ <param name="jvmti.tests.mode.switch" value ="" />
+ </antcall>
+
+ <antcall target="run-jvmti-tests">
+ <param name="jvmti.tests.mode" value="interpreter" />
+ <param name="jvmti.tests.mode.switch" value="-Xint" />
+ </antcall>
+ </then>
+ </if>
+ </target>
+</project>
Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml?view=diff&rev=475438&r1=475437&r2=475438
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/targets/kernel.test.xml Wed Nov 15 13:33:36 2006
@@ -124,7 +124,7 @@
<echo>
==============================================
Please set the classpath of junit as follows:
- build.bat -Djunit.jar=%JUNIT_HOME% test"
+ build.bat -Djunit.jar=%JUNIT_HOME% test
==============================================
</echo>
<fail message="Kernel tests misconfigured" />
Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/targets/test.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/targets/test.xml?view=diff&rev=475438&r1=475437&r2=475438
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/targets/test.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/targets/test.xml Wed Nov 15 13:33:36 2006
@@ -18,6 +18,6 @@
Version: $Revision: 1.3.2.2 $
-->
<project name="ALL TESTS">
- <target name="test" depends="cunit.test, smoke.test, kernel.test" />
+ <target name="test" depends="jvmti.test, cunit.test, smoke.test, kernel.test" />
</project>
Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.cpp?view=auto&rev=475438
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.cpp (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.cpp Wed Nov 15 13:33:36 2006
@@ -0,0 +1,49 @@
+#include <string.h>
+#include <jvmti.h>
+
+static void JNICALL vm_init_callback(jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread)
+{
+ jclass cl = jni_env->FindClass("VMInit1/Status");
+ if (NULL == cl)
+ return;
+
+ jfieldID fid = jni_env->GetStaticFieldID(cl, "status", "Z");
+ if (NULL == fid)
+ return;
+
+ jni_env->SetStaticBooleanField(cl, fid, JNI_TRUE);
+}
+
+JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
+{
+ jvmtiEnv *jvmti_env;
+ if(vm->GetEnv((void**)&jvmti_env, JVMTI_VERSION_1_0) != JNI_OK)
+ return JNI_ERR;
+
+ // Get all supported capabilities
+ jvmtiCapabilities capabilities;
+ jvmtiError result = jvmti_env->GetPotentialCapabilities(&capabilities);
+ if (JVMTI_ERROR_NONE != result)
+ return JNI_ERR;
+
+ // Enabled all supported capabilities
+ result = jvmti_env->AddCapabilities(&capabilities);
+ if (JVMTI_ERROR_NONE != result)
+ return JNI_ERR;
+
+ jvmtiEventCallbacks callbacks;
+ memset(&callbacks, 0, sizeof(jvmtiEventCallbacks));
+ callbacks.VMInit = vm_init_callback;
+
+ // Set callback for VMInit
+ result = jvmti_env->SetEventCallbacks(&callbacks, (jint)sizeof(callbacks));
+ if (JVMTI_ERROR_NONE != result)
+ return JNI_ERR;
+
+ // Set event mode to true
+ result = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL);
+ if (JVMTI_ERROR_NONE != result)
+ return JNI_ERR;
+
+ return JNI_OK;
+}
Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.java?view=auto&rev=475438
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/jvmti/VMInit1/VMInit1.java Wed Nov 15 13:33:36 2006
@@ -0,0 +1,23 @@
+package VMInit1;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for VMInit event. Should be executed with all JVMTI capabilies
+ * enabled.
+ */
+public class VMInit1 extends TestCase {
+ public static void main(String args[]) {
+ (new VMInit1()).test();
+ }
+
+ public void test() {
+ System.out.println("test done");
+ assertTrue(Status.status);
+ }
+}
+
+class Status {
+ public static boolean status = false;
+}
+