Supporting WSL in shell tests; was Re: [PATCH] Fix for EXE_SUFFIX being set for WSL having no effect

Jonathan Gibbons jonathan.gibbons at
Wed Jan 23 23:25:16 UTC 2019

On 1/23/19 1:56 PM, Jonathan Gibbons wrote:
> On 1/23/19 1:49 PM, Jonathan Gibbons wrote:
>> On 1/23/19 1:12 PM, Alexandre (Shura) Iline wrote:
>>> I think it is only natural to expect folks to debug shell tests 
>>> directly. If we accept this assumption, then, is there any 
>>> reasonable alternative to “uname"? There is a “systeminfo” tool on 
>>> windows, not sure if it helps. We really need to know what “uname 
>>> -s” outputs, though, as it might still work.
>> It would help if we could crowd-source a table showing the value on 
>> different systems.
>> -- jon
> ... but that being said, `uname` will test the system being used to 
> run the shell script; it seems we need to distinguish the different 
> kinds of JDK we might be wanting to test ... i.e is the JDK a "Linux 
> JDK" or a "WIndows JDK". You won't get that from `uname`, since (as I 
> understand it) the WSL world can invoke either sort of JDK.
> This seems to be the thinking behind Andrew's suggestion of providing 
> WSL_TARGET, but it just seems weird, in his proposed text, to be 
> testing WSL_TARGET when we might not be running on WSL.
> -- Jon

Here's a variant of Andrew's earlier suggestion that does not require 
jtreg setting either EXE_SUFFIX or WSL_TARGET, which is nice because 
that supports standalone invocation of the shell script for development 
and debugging.

OS=`uname -s`;
case "$OS" in
     Windows* | CYGWIN* )

     Linux )
         if [ -r $JAVA_HOME/bin/java.exe ]; then

     * )

Note: that code is not tested on any platforms, and may need to be 
adapted as needed in some tests .. e.g. some tests want SEP instead of 
PS, some tests may also want NULL (set to NUL or /dev/null), etc

Yes, the code fragment is growing, but Shura points out that if enough 
tests would make use of it, we could put a script in a shared test 
library somewhere, to reduce the impact in any individual test.

-- Jon

More information about the quality-discuss mailing list