jtreg - building java and cpp test

Pete Brunet peter.brunet at oracle.com
Thu Nov 19 21:45:27 UTC 2015

Yes, I saw that.  But I don't see how to write my test to use it.  Where
do I put my cpp file so it ends up in whatever $(shell $(GETMIXEDPATH)
"$(TESTNATIVE_DIR)/jdk/jtreg/native") is.  I searched for a jtreg/native
under my entire tree including the build output and didn't find it. 
That's why it seems noone is using this feature.  But maybe I am missing
something.  I'm hoping someone has already done this so I can use that
as a prototype.

BTW, I found https://bugs.openjdk.java.net/browse/JDK-8072842 which
added the infrastructure last February but didn't find any helpful
information there.


On 11/19/15 3:36 PM, Jonathan Gibbons wrote:
> Pete,
> I see a few uses in the hotspot/ and jdk/ repos.
> $ grep --recursive nativepath make */make test */test
> hotspot/test/Makefile:# jtreg -nativepath <dir>
> hotspot/test/Makefile:  JTREG_NATIVE_PATH = -nativepath:$(shell
> $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/hotspot/jtreg/native")
> jdk/test/native_sanity/simplenativelauncher/ProgramTest.java: String
> lib = System.getProperty("test.nativepath");
> jdk/test/Makefile:# jtreg -nativepath <dir>
> jdk/test/Makefile:  JTREG_NATIVE_PATH = -nativepath:$(shell
> $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/jdk/jtreg/native")
> -- Jon
> On 11/19/2015 01:08 PM, Pete Brunet wrote:
>> On 11/19/15 3:07 PM, Pete Brunet wrote:
>>> Thanks Jonathan, Is -native in use?  I see some infrastructure for it
>>> but can't find (yet) that it's actually in use.  -Pete
>> s/native/nativepath/
>>> On 11/19/15 12:44 PM, Jonathan Gibbons wrote:
>>>> On 11/19/2015 07:46 AM, Pete Brunet wrote:
>>>>> Hi, I need to build a regression test that has both Java and C++
>>>>> code.
>>>>> I see some similar cases in the test tree and they include the exe of
>>>>> the cpp file.  I also see a Makefile.  If I run the test without
>>>>> the exe
>>>>> it is not built so what is the Makefile for?  Documentation?
>>>>> The Makefile I used as a prototype has
>>>>> cl -o name.exe name.cpp name.lib name.lib
>>>>> but when I ran make at the command line cl was not found but at
>>>>> least at
>>>>> this point I don't see the need to look into the cl failure if the
>>>>> Makefile is just for documentation.
>>>>> Pete
>>>> jtreg has no direct, complete solution for mixed code like this, and
>>>> is unlikely to support
>>>> it any time soon.
>>>> You can use Makefiles from a shell script, but that is unlikely to be
>>>> successful in a
>>>> broad multi-platform world, like OpenJDK.  Not only is it problematic
>>>> to know what
>>>> compiler to use and where to find it, but at least in our internal
>>>> test infrastructure,
>>>> the test machines may not even have the native code compilers
>>>> installed.
>>>> (i.e. it is common practice to build and test on different host
>>>> systems.)
>>>> The compromise solution we adopted in conjunction with the Hotspot SQE
>>>> team
>>>> is to use the OpenJDK build process to compile the C/C++ code needed
>>>> for the tests.
>>>> The build has the info needed on how to do platform-specific
>>>> compilation of native
>>>> code.   The build can then generate a bundle that can be passed to
>>>> jtreg with the
>>>> -nativepath option.
>>>> I cannot speak to the existence of Makefiles appearing in the
>>>> regression test suite.
>>>> Sometimes they are used manually to create native files that are
>>>> checked in to the
>>>> repo (uugh) and sometimes the tests are restricted to run on a limited
>>>> set of platforms
>>>> (e.g. Windows only, or Unix only.)
>>>> -- Jon

More information about the jtreg-use mailing list