How to specity the -agentlib option in a jtreg test?
Staffan Larsen
staffan.larsen at oracle.com
Tue Apr 19 12:42:57 UTC 2016
> On 19 apr. 2016, at 14:34, Alexander Kulyakhtin <alexander.kulyakhtin at oracle.com> wrote:
>
> Jon, Staffan,
>
> Based on the discussion below can I file a bug or an enhancement against the jtreg, requiring it to support the -agentlib option?
I think that is a good idea, yes.
>
> Without the direct support for the -agentlib option, testing JVMTI with the jtreg, though possible, would require a somewhat tedious and platform-dependent workaround.
>
> Best regards,
> Alexander
>
>
>
> ----- Original Message -----
> From: staffan.larsen at oracle.com
> To: jonathan.gibbons at oracle.com
> Cc: alexander.kulyakhtin at oracle.com, jtreg-use at openjdk.java.net
> Sent: Tuesday, April 19, 2016 10:48:32 AM GMT +03:00 Iraq
> Subject: Re: How to specity the -agentlib option in a jtreg test?
>
>
> On 18 apr. 2016, at 21:59, Jonathan Gibbons <jonathan.gibbons at oracle.com <mailto:jonathan.gibbons at oracle.com>> wrote:
>
> HI Staffan,
>
> The text specifically describes Windows and Solaris. Should we assume that Mac and Linux also use LD_LIBRARY_PATH.
>
> As David said, Mac uses DYLD_LIBRARY_PATH.
>
> And, my question still stands: which is the better one to fix: jtreg, or jvmti?
>
> I think the fix needs to be in jtreg.
>
> /Staffan
>
>
> -- Jon
>
> On 04/18/2016 11:07 AM, Staffan Larsen wrote:
> The JVMTI spec is kind of vague on this point, but does not mention system properties.
>
> -agentlib:<agent-lib-name>=<options>
> The name following -agentlib: is the name of the library to load. Lookup of the library, both its full name and location, proceeds in a platform-specific manner. Typically, the <agent-lib-name> is expanded to an operating system specific file name. The <options> will be passed to the agent on start-up. For example, if the option -agentlib:foo=opt1,opt2 is specified, the VM will attempt to load the shared library foo.dllfrom the system PATH under WindowsTM or libfoo.so from the LD_LIBRARY_PATH under the SolarisTM operating environment. If the agent library is statically linked into the executable then no actual loading takes place.
>
> http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html <http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html>
>
>
>
> On 18 apr. 2016, at 19:51, Jonathan Gibbons <jonathan.gibbons at oracle.com <mailto:jonathan.gibbons at oracle.com>> wrote:
>
> OK, thanks for clarifying.
>
> The question is, should -agentlib use the system property (that is already being set) or should jtreg set LD_LIBRARY_PATH (which is platform specific.)
>
> -- Jon
>
> On 04/18/2016 04:53 AM, Alexander Kulyakhtin wrote:
> Jon,
>
> In the 'rerun' section I have:
>
> images/jdk/bin/java \\
> ...
> -Dtest.nativepath=<...>images/test/hotspot/jtreg/native
> -Djava.library.path=<...>images/test/hotspot/jtreg/native
> -agentlib:TestGetModules
> ...
>
> While TestGetModules.so does reside in the images/test/hotspot/jtreg/native, jtreg does not set LD_LIBRARY_PATH to that directory before invoking java.
> Therefore -agentlib does not know where to look for the library.
> The System.loadLibrary, on the contrary, does succeed because of the -Djava.library.path passed to java.
>
> Best regards,
> Alexander
>
> ----- Original Message -----
> From: jonathan.gibbons at oracle.com <mailto:jonathan.gibbons at oracle.com>
> To: jtreg-use at openjdk.java.net <mailto:jtreg-use at openjdk.java.net>
> Sent: Friday, April 15, 2016 7:05:18 PM GMT +03:00 Iraq
> Subject: Re: How to specity the -agentlib option in a jtreg test?
>
> jtreg should report the command it is trying to execute in the "rerun"
> section.
>
> If you execute that command directly, does it work? In other words,
> can you isolate the problem to jtreg or to the execution of the command
> that jtreg execs?
>
> -- Jon
>
> On 04/15/2016 07:53 AM, Staffan Larsen wrote:
> I don’t know why it does not work for -agentlib, but as a workaround you can create an @driver class that launches your test program with the -agentpath parameter and get the location of the native libraries through the system property test.nativepath.
>
> Staffan
>
> On 15 apr. 2016, at 16:29, Alexander Kulyakhtin <alexander.kulyakhtin at oracle.com <mailto:alexander.kulyakhtin at oracle.com>> wrote:
>
> Hi,
>
> I'm trying to create a jtreg test which compiles and then executes a java class with the -agentlib option (to test some JVMTI functionality)
>
> In my test I have
>
> @compile MyTest.java
> @run main/othervm -agentlib:mylib MyTest
>
> I run the test with:
>
> jtreg -nativepath:<path to libmylib.so> MyTest
>
> However, it fails with:
>
> "Could not find agent library mylib on the library path, libmylib.so: cannot open shared object file: No such file or directory"
>
> The -nativepath does provide for the successful loading of the library when I use System.loadLibrary("mylib").
> However, for the -agentlib option, it does not help.
>
> Does someone know if it is possible to specify the library path for the -agentlib option, from within a jtreg test or using the jtreg options?
>
> Thank you very much for your help.
>
> Best regards,
> Alexander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/jtreg-use/attachments/20160419/90ac57f3/attachment.html>
More information about the jtreg-use
mailing list