8215369: Jcstress pollute /var/tmp with temporary files.
authorlmesnik
Thu, 13 Dec 2018 14:16:21 -0800
changeset 53025 5c65191e56b9
parent 53021 cc4098b3bc10
child 53026 7d4397b43fa3
8215369: Jcstress pollute /var/tmp with temporary files. Reviewed-by: iignatyev, mseledtsov
test/hotspot/jtreg/applications/jcstress/JcstressRunner.java
--- a/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java	Thu Dec 13 16:45:26 2018 +0100
+++ b/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java	Thu Dec 13 14:16:21 2018 -0800
@@ -89,6 +89,11 @@
     private static String[] getCmd(String[] args) {
         List<String> extraFlags = new ArrayList<>();
 
+        // java.io.tmpdir is set for both harness and forked VM so temporary files
+        // created like this File.createTempFile("jcstress", "stdout");
+        // don't pollute temporary directories
+        extraFlags.add("-Djava.io.tmpdir=" + System.getProperty("user.dir"));
+
         // add jar with jcstress tests and harness to CP
         extraFlags.add("-cp");
         extraFlags.add(System.getProperty("java.class.path")
@@ -97,16 +102,11 @@
 
         extraFlags.add(MAIN_CLASS);
 
-        String[] javaOpts = Utils.getTestJavaOpts();
-        // disable flags auto-detection
-        if (0 == javaOpts.length) {
+        extraFlags.add("--jvmArgs");
+        extraFlags.add("-Djava.io.tmpdir=" + System.getProperty("user.dir"));
+        for (String jvmArg : Utils.getTestJavaOpts()) {
             extraFlags.add("--jvmArgs");
-            extraFlags.add("");
-        } else {
-            for (String jvmArg : Utils.getTestJavaOpts()) {
-                extraFlags.add("--jvmArgs");
-                extraFlags.add(jvmArg);
-            }
+            extraFlags.add(jvmArg);
         }
 
         String[] result = new String[extraFlags.size() + args.length];