[PATCH] Enable jtreg tests to run on WSL (Windows Subsystem for Linux)

Jonathan Gibbons jonathan.gibbons at oracle.com
Thu Jan 10 00:58:47 UTC 2019


Andrew,

You are right that there are typically 2 JDKs involved, but jtreg is a 
standalone app, and does not need to be run from the Makefiles, and so 
is not tied to the Boot JDK. But it is true to say that there is the JDK 
used to run jtreg, and the JDK under test.

Until your recent work with WSL, Cygwin was the only supported 
environment for running shell tests. (MKS was the official solution for 
Sun, back before JDK was open source; MSYS never quite took hold.)

If we get to the point of widely adopting/supporting WSL, then we could 
have jtreg default to using WSL if WSL is found to be installed and on 
the path, or we could figure a way to determine that Cygwin is available 
and should be used. Either way, I would retain the ability to specify 
which to use with an option, in case people want to override the default 
choice made by jtreg. And, Erik suggested that when running jtreg from 
the Makefiles, it would make sense to always specify which compatibility 
layer to use.

But, for now, we can defer these design decisions, and rely on requiring 
the option to be specified.

-- Jon



On 01/09/2019 04:42 PM, Andrew Luo wrote:
>
> I see what you mean.
>
> From my understanding, there are 2 JDKs here:
>
> 1.Boot JDK – which is used to build the new OpenJDK, and run jtreg (is 
> that right, or does the JDK under test itself run jtreg?)
>
> 2.JDK under test – the JDK that was just built from the OpenJDK source 
> tree, what jtreg is actually testing
>
> Currently the boot JDK can only be Windows when running a WSL Windows 
> build.  But I think this could change in the future.  So if we do 
> potentially allow either a Windows or Linux boot JDK, we wouldn’t be 
> able to test in-process by just checking os.name/os.version 
> properties.  However, we could execute the JDK under test and check 
> os.name/os.version out-of-process.  If os.name is Windows, then we 
> need either Cygwin, or WSL (or some other compatibility layer – MSYS 
> or MKS, but my understanding is these are no longer supported).  Or 
> potentially, we could just check to see if the java executable is 
> named exactly “java” or “java.exe”.
>
> Once we determine our JDK under test is a Windows JDK, we have to 
> figure out whether we’re in Cygwin or WSL.  I haven’t used Cygwin in a 
> long time, but if I remember right, Cygwin uses the same Path 
> environment variables as Windows (Cygwin bash is a Win32 process).  So 
> when invoking the JDK, all the Cygwin executables will live on the 
> Path, so one can just call uname to check if one is in Cygwin.  In 
> WSL, this call to uname will either fail (Windows Boot JDK) or return 
> Linux (Linux Boot JDK), but assuming we support no other compatibility 
> layers, if we’re not in Cygwin, we can assume we’re in WSL.
>
> Checking for wsl.exe being on the Path, in my opinion, would not be 
> ideal, since if both Cygwin and WSL are installed on a system, wsl.exe 
> would be on the Path, even if you are in Cygwin (or some other 
> compatibility layer, assuming it shares the Windows Path).
>
> Thanks,
>
> -Andrew
>
> *From:*Jonathan Gibbons <jonathan.gibbons at oracle.com>
> *Sent:* Tuesday, January 8, 2019 3:28 PM
> *To:* Andrew Luo <andrewluotechnologies at outlook.com>; 
> code-tools-dev at openjdk.java.net
> *Subject:* Re: [PATCH] Enable jtreg tests to run on WSL (Windows 
> Subsystem for Linux)
>
> `targetting` is a strange word to use in this context, since (to me) 
> `targetting` implies `action at a distance`.
>
> Any Java program can query its environment to determine the OS on 
> which it it running. There are various system properties, all 
> beginning "os.":  os.name, os.arch and os.version. Listed here: 
> https://docs.oracle.com/javase/9/docs/api/java/lang/System.html#getProperties--
>
> So part of the question is, what are the values of these properties 
> when using WSL, or (more accurately) when running a JRE that was built 
> by using "/./configure in OpenJDK to build a Linux JDK on WSL or a 
> Windows JDK on WSL./"
>
> Then, the question becomes, can jtreg detect if a compatibility layer 
> is required, and if so can it infer whether to use WSL or Cygwin?   
> I'm not sure if this question makes sense, but maybe jtreg could infer 
> which to use by seeing whether wsl.exe or sh.exe is on $PATH. And, 
> maybe that's "too magic" ... I'm just asking.
>
> -- Jon
>
> On 01/08/2019 02:26 PM, Andrew Luo wrote:
>
>     Oh, now that I look at your 3rd revision, I think I understand what you meant.  jtreg can detect whether or not it is targeting Windows or Linux based on the current OS of the JRE being used to run jtreg - is that what you mean?
>
>     If so, that might work, but on the build-dev discussion while adding WSL we did think about it being possible (later on; seehttps://mail.openjdk.java.net/pipermail/build-dev/2018-December/024542.html) to use either a Windows or Linux boot JDK to build on WSL.
>
>     Thanks,
>
>     -Andrew
>
>     -----Original Message-----
>
>     From: code-tools-dev<code-tools-dev-bounces at openjdk.java.net>
>     <mailto:code-tools-dev-bounces at openjdk.java.net>  On Behalf Of Andrew Luo
>
>     Sent: Tuesday, January 8, 2019 2:23 PM
>
>     To: Jonathan Gibbons<jonathan.gibbons at oracle.com> <mailto:jonathan.gibbons at oracle.com>;code-tools-dev at openjdk.java.net
>     <mailto:code-tools-dev at openjdk.java.net>
>
>     Subject: RE: [PATCH] Enable jtreg tests to run on WSL (Windows Subsystem for Linux)
>
>     Jon,
>
>     I’m not sure what exactly you mean that the “test effectively require either Cygwin or WSL”?  I believe it would be possible (ideal actually) to write the tests such that they can run on all platforms (Linux, Cygwin, WSL Windows target) – most tests today run on multiple platforms already, right?
>
>     The option needs to be provided only when you use WSL to target Windows.  If you use WSL to target Linux then the option should not be set; the behavior will be the same as Linux.  I don’t think it’s possible for jtreg or the test itself to infer this information, because it depends on whether you called ./configure in OpenJDK to build a Linux JDK on WSL or a Windows JDK on WSL.
>
>     Perhaps I’m misunderstanding what you’re saying though…
>
>     Thanks,
>
>     -Andrew
>
>     From: Jonathan Gibbons<jonathan.gibbons at oracle.com> <mailto:jonathan.gibbons at oracle.com>
>
>     Sent: Tuesday, January 8, 2019 11:25 AM
>
>     To: Andrew Luo<andrewluotechnologies at outlook.com>
>     <mailto:andrewluotechnologies at outlook.com>;code-tools-dev at openjdk.java.net
>     <mailto:code-tools-dev at openjdk.java.net>
>
>     Subject: Re: [PATCH] Enable jtreg tests to run on WSL (Windows Subsystem for Linux)
>
>     Andrew,
>
>     One final question ...
>
>     You introduce a new jtreg option to sepcify the use of WSL. Given that the test effectively require either Cygwin or WSL, would it be reasonable to try and infer which subsystem is required, perhaps leaving the new option to be used only in the case of uncertainty/ambiguity?
>
>     Not everyone runs jtreg tests through the Makefiles, and for those that don't, requiring the new option will mean that they need to specify the new option to use WSL. It would be nice if they didn't have to.
>
>     -- Jon
>



More information about the code-tools-dev mailing list