8217332: JTREG: Clean up, use generics instead of raw types
26 * @key gc
27 * @summary Test to check correct handling of non-existent directory passed to AllocateOldGenAt option
28 * @requires vm.gc=="null" & os.family != "aix"
29 * @library /test/lib
30 * @modules java.base/jdk.internal.misc
31 * @run main gc.nvdimm.TestAllocateOldGenAtError
32 */
33
34 import java.io.File;
35 import jdk.test.lib.JDKToolFinder;
36 import jdk.test.lib.process.ProcessTools;
37 import jdk.test.lib.process.OutputAnalyzer;
38 import java.util.ArrayList;
39 import java.util.Collections;
40 import java.util.UUID;
41
42 public class TestAllocateOldGenAtError {
43 private static ArrayList<String> commonOpts;
44
45 public static void main(String args[]) throws Exception {
46 commonOpts = new ArrayList();
47
48 String testVmOptsStr = System.getProperty("test.java.opts");
49 if (!testVmOptsStr.isEmpty()) {
50 String[] testVmOpts = testVmOptsStr.split(" ");
51 Collections.addAll(commonOpts, testVmOpts);
52 }
53 String test_dir = System.getProperty("test.dir", ".");
54
55 File f = null;
56 do {
57 f = new File(test_dir, UUID.randomUUID().toString());
58 } while(f.exists());
59
60 Collections.addAll(commonOpts, new String[] {"-XX:+UnlockExperimentalVMOptions",
61 "-XX:AllocateOldGenAt=" + f.getName(),
62 "-Xlog:gc+heap=info",
63 "-Xmx32m",
64 "-Xms32m",
65 "-version"});
|
26 * @key gc
27 * @summary Test to check correct handling of non-existent directory passed to AllocateOldGenAt option
28 * @requires vm.gc=="null" & os.family != "aix"
29 * @library /test/lib
30 * @modules java.base/jdk.internal.misc
31 * @run main gc.nvdimm.TestAllocateOldGenAtError
32 */
33
34 import java.io.File;
35 import jdk.test.lib.JDKToolFinder;
36 import jdk.test.lib.process.ProcessTools;
37 import jdk.test.lib.process.OutputAnalyzer;
38 import java.util.ArrayList;
39 import java.util.Collections;
40 import java.util.UUID;
41
42 public class TestAllocateOldGenAtError {
43 private static ArrayList<String> commonOpts;
44
45 public static void main(String args[]) throws Exception {
46 commonOpts = new ArrayList<>();
47
48 String testVmOptsStr = System.getProperty("test.java.opts");
49 if (!testVmOptsStr.isEmpty()) {
50 String[] testVmOpts = testVmOptsStr.split(" ");
51 Collections.addAll(commonOpts, testVmOpts);
52 }
53 String test_dir = System.getProperty("test.dir", ".");
54
55 File f = null;
56 do {
57 f = new File(test_dir, UUID.randomUUID().toString());
58 } while(f.exists());
59
60 Collections.addAll(commonOpts, new String[] {"-XX:+UnlockExperimentalVMOptions",
61 "-XX:AllocateOldGenAt=" + f.getName(),
62 "-Xlog:gc+heap=info",
63 "-Xmx32m",
64 "-Xms32m",
65 "-version"});
|
75
76 output.shouldContain("Could not initialize G1 heap");
77 output.shouldContain("Error occurred during initialization of VM");
78 output.shouldNotHaveExitValue(0);
79
80 }
81
82 private static void testParallelOld() throws Exception {
83 System.out.println("Testing ParallelOld GC with UseAdaptiveGCBoundary disabled");
84 OutputAnalyzer output = runTest("-XX:+UseParallelOldGC -XX:-UseAdaptiveGCBoundary");
85 output.shouldContain("Error occurred during initialization of VM");
86 output.shouldNotHaveExitValue(0);
87
88 System.out.println("Testing ParallelOld GC with UseAdaptiveGCBoundary enabled");
89 output = runTest("-XX:+UseParallelOldGC -XX:+UseAdaptiveGCBoundary");
90 output.shouldContain("Error occurred during initialization of VM");
91 output.shouldNotHaveExitValue(0);
92 }
93
94 private static OutputAnalyzer runTest(String... extraFlags) throws Exception {
95 ArrayList<String> testOpts = new ArrayList();
96 Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()]));
97 Collections.addAll(testOpts, extraFlags);
98
99 System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
100 for (int i = 0; i < testOpts.size(); i += 1) {
101 System.out.print(" " + testOpts.get(i));
102 }
103 System.out.println();
104
105 ProcessBuilder pb =
106 ProcessTools.createJavaProcessBuilder(testOpts.toArray(new String[testOpts.size()]));
107 OutputAnalyzer output = new OutputAnalyzer(pb.start());
108 return output;
109 }
110 }
|
75
76 output.shouldContain("Could not initialize G1 heap");
77 output.shouldContain("Error occurred during initialization of VM");
78 output.shouldNotHaveExitValue(0);
79
80 }
81
82 private static void testParallelOld() throws Exception {
83 System.out.println("Testing ParallelOld GC with UseAdaptiveGCBoundary disabled");
84 OutputAnalyzer output = runTest("-XX:+UseParallelOldGC -XX:-UseAdaptiveGCBoundary");
85 output.shouldContain("Error occurred during initialization of VM");
86 output.shouldNotHaveExitValue(0);
87
88 System.out.println("Testing ParallelOld GC with UseAdaptiveGCBoundary enabled");
89 output = runTest("-XX:+UseParallelOldGC -XX:+UseAdaptiveGCBoundary");
90 output.shouldContain("Error occurred during initialization of VM");
91 output.shouldNotHaveExitValue(0);
92 }
93
94 private static OutputAnalyzer runTest(String... extraFlags) throws Exception {
95 ArrayList<String> testOpts = new ArrayList<>();
96 Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()]));
97 Collections.addAll(testOpts, extraFlags);
98
99 System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
100 for (int i = 0; i < testOpts.size(); i += 1) {
101 System.out.print(" " + testOpts.get(i));
102 }
103 System.out.println();
104
105 ProcessBuilder pb =
106 ProcessTools.createJavaProcessBuilder(testOpts.toArray(new String[testOpts.size()]));
107 OutputAnalyzer output = new OutputAnalyzer(pb.start());
108 return output;
109 }
110 }
|