INSTRUMENT TEST
This page describe the detail of non-unit-test of instrument.
How to build a test
A.Create a test class, e.g, "test.java". Do something in method main().
B.Create a class with a method "Premain":
public static void premain(String agentArgs, Instrumentation inst);
"inst" is one instance of the implement of Instrument in Harmony. You can test any function of the Instrumentation here.
C.Create a jar file, e.g, "test.jar", with Premain-class attribute which denotes the class "PreMain" in the manifest. It is convenience to pack "PreMain.class" in it.
An example:
(1)create a manifest called Manifest with such content:
Manifest-Version: 1.0
Created-By: 1.5.0_06 (Sun Microsystems Inc.)
Premain-Class: PreMain
Boot-Class-Path: .
(2)create the jar: jar cvfm Test.jar Manifest Premain.class
D.lauch Java VM with the following options:
java -agentlib:Path InstrumentDLLName=test.jar Main
Here VMPath is the path of InstrumentDLLName; InstrumentDLLName is the name(without suffix) of a instrument dll file
If Launcher with parameter "-javaagent" is ready, then we can lauch:
java -javaagent:test.jar Main