8222500: runtime/8176717/TestInheritFD.java failed with java.nio.file.NoSuchFileException: /tmp/communication7071713601211876892.txt

Create the test's temporary files inside of jtreg scratch directories instead of /tmp

Reviewed-by: coleenp, lfoltan, dholmes
This commit is contained in:
Harold Seigel 2019-05-03 07:54:09 -04:00
parent e08506e683
commit 84c38b8f7f

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,7 +21,6 @@
* questions.
*/
import static java.io.File.createTempFile;
import static java.lang.Long.parseLong;
import static java.lang.System.getProperty;
import static java.nio.file.Files.readAllBytes;
@ -30,6 +29,7 @@ import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder;
import static jdk.test.lib.Platform.isWindows;
import jdk.test.lib.Utils;
import java.io.BufferedReader;
import java.io.File;
@ -43,7 +43,7 @@ import java.util.stream.Stream;
/*
* @test TestInheritFD
* @bug 8176717 8176809
* @bug 8176717 8176809 8222500
* @summary a new process should not inherit open file descriptors
* @comment On Aix lsof requires root privileges.
* @requires os.family != "aix"
@ -79,8 +79,8 @@ public class TestInheritFD {
// first VM
public static void main(String[] args) throws Exception {
String logPath = createTempFile("logging", LOG_SUFFIX).getName();
File commFile = createTempFile("communication", ".txt");
String logPath = Utils.createTempFile("logging", LOG_SUFFIX).toFile().getName();
File commFile = Utils.createTempFile("communication", ".txt").toFile();
if (!isWindows() && !lsofCommand().isPresent()) {
System.out.println("Could not find lsof like command");