[PATCH] Fix for EXE_SUFFIX being set for WSL having no effect

Andrew Luo andrewluotechnologies at outlook.com
Fri Jan 18 21:34:13 UTC 2019


Sounds good.  My plan is to first try to address most of the failures in tier 1 rather than doing all tests at once.  There aren't that many shell tests in tier 1 so it won't be a lot of work wasted if other teams prefer a different approach.  Anyways, I want to have something that I know works before I propose it...

Regarding the previous topic of whether or not we need the -wsl flag - I noticed in some places we are actually checking the type of JVM, in particular in test/hotspot/jtreg/test_env.sh:

${TESTJAVA}${FS}bin${FS}java${EXE_SUFFIX} ${TESTOPTS} -Xinternalversion | sed -e 's/[(][^)]*[)]//g' -e 's/ by "[^"]*"//g' > vm_version.out 2>&1
echo "INT_VERSION=`cat vm_version.out 2>&1`"

...

VM_OS="unknown"
grep "aix" vm_version.out > ${NULL}
if [ $? = 0 ]
then
  VM_OS="aix"
fi
grep "bsd" vm_version.out > ${NULL}
if [ $? = 0 ]
then
  VM_OS="bsd"
fi
grep "linux" vm_version.out > ${NULL}
if [ $? = 0 ]
then
  VM_OS="linux"
fi
grep "solaris" vm_version.out > ${NULL}
if [ $? = 0 ]
then
  VM_OS="solaris"
fi
grep "windows" vm_version.out > ${NULL}
if [ $? = 0 ]
then
  VM_OS="windows"
fi

This is potentially a way shell scripts can determine themselves whether or not they are in WSL, or perhaps if we want to remove the need for the -wsl flag to jtreg, we could implement some similar logic.  Just a thought though.  (I do also wonder why someone implemented this - for cross-compilation? As far as I'm aware, the OS running == JDK target OS in all cases except WSL)

On a (somewhat related note), another thing I noticed is that some scripts have logic such as:

OS=`uname -s`;
# Set classpath separator
case "$OS" in
        Windows* | CYGWIN* )
	SEP=";"
        ;;

	* )
	SEP=":"
esac

However, the classpath separator would depend on the platform of the JVM under test (; for a Windows JVM under test, : for a Linux JVM under test).  I could copy the above logic to detect the JVM under test in the script, but this seems like overkill just to check whether your target JVM is Windows or Linux.  So perhaps we could add another environment variable, say WSL_TARGET, which would either be set to "windows" for a Windows WSL target, or empty for Linux WSL target/non-WSL.  That way the above logic could be rewritten:

OS=`uname -s`;
# Set classpath separator
case "$OS" in
        Windows* | CYGWIN* )
	SEP=";"
        ;;

	* )
	if [ "x${WSL_TARGET}" = "xwindows" ]; then
		SEP=";"
	else
		SEP=":"
	fi
esac

Of course, this could be implemented using VM_OS using the code above, but it seems to me to be pretty clumsy to have to invoke the JVM in every test just to determine whether you're target JVM is Windows or Linux, given that jtreg knows this information anyways and could just tell the scripts, via an environment variable.  Let me know your thoughts/what you prefer.

Thanks,

-Andrew



More information about the code-tools-dev mailing list