8213214: Set -Djava.io.tmpdir= when running tests

Reviewed-by: alanb, mikael
This commit is contained in:
Erik Joelsson 2020-06-23 06:51:35 -07:00
parent 2765410a28
commit d8219d0a78
2 changed files with 23 additions and 4 deletions

View File

@ -849,10 +849,14 @@ define SetupRunJtregTestBody
$1_JTREG_LAUNCHER_OPTIONS += -Xmx$$($1_JTREG_MAX_MEM)
endif
# Make sure the tmp dir is normalized as some tests will react badly otherwise
$1_TEST_TMP_DIR := $$(abspath $$($1_TEST_SUPPORT_DIR)/tmp)
$1_JTREG_BASIC_OPTIONS += -$$($1_JTREG_TEST_MODE) \
-verbose:$$(JTREG_VERBOSE) -retain:$$(JTREG_RETAIN) \
-concurrency:$$($1_JTREG_JOBS) -timeoutFactor:$$(JTREG_TIMEOUT_FACTOR) \
-vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE)
-vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) \
-vmoption:-Djava.io.tmpdir="$$($1_TEST_TMP_DIR)"
$1_JTREG_BASIC_OPTIONS += -automatic -ignore:quiet
@ -968,7 +972,8 @@ define SetupRunJtregTestBody
run-test-$1: pre-run-test clean-workdir-$1 $$($1_AOT_TARGETS)
$$(call LogWarn)
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR) \
$$($1_TEST_TMP_DIR))
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, ( \
$$(COV_ENVIRONMENT) $$($1_COMMAND_LINE) \
))

View File

@ -120,8 +120,22 @@ public class Misc {
* Test: toRealPath() should resolve links
*/
if (supportsLinks) {
Files.createSymbolicLink(link, file.toAbsolutePath());
assertTrue(link.toRealPath().equals(file.toRealPath()));
Path resolvedFile = file;
if (isWindows) {
// Path::toRealPath does not work with environments using the
// legacy subst mechanism. This is a workaround to keep the
// test working if 'dir' points to a location on a subst drive.
// See JDK-8213216.
//
Path tempLink = dir.resolve("tempLink");
Files.createSymbolicLink(tempLink, dir.toAbsolutePath());
Path resolvedDir = tempLink.toRealPath();
Files.delete(tempLink);
resolvedFile = resolvedDir.resolve(file.getFileName());
}
Files.createSymbolicLink(link, resolvedFile.toAbsolutePath());
assertTrue(link.toRealPath().equals(resolvedFile.toRealPath()));
Files.delete(link);
}