23 * |
23 * |
24 */ |
24 */ |
25 |
25 |
26 package gc.metaspace; |
26 package gc.metaspace; |
27 |
27 |
|
28 import jdk.test.lib.Platform; |
28 import jdk.test.lib.process.ProcessTools; |
29 import jdk.test.lib.process.ProcessTools; |
29 import jdk.test.lib.process.OutputAnalyzer; |
30 import jdk.test.lib.process.OutputAnalyzer; |
|
31 import java.util.ArrayList; |
|
32 import java.util.List; |
30 |
33 |
31 /* @test TestSizeTransitionsSerial |
34 /* @test TestSizeTransitionsSerial |
32 * @key gc |
35 * @key gc |
33 * @requires vm.gc.Serial |
36 * @requires vm.gc.Serial |
34 * @summary Tests that the metaspace size transition logging is done correctly. |
37 * @summary Tests that the metaspace size transition logging is done correctly. |
102 // args: <use-coops> <gc-arg> |
105 // args: <use-coops> <gc-arg> |
103 if (args.length != 2) { |
106 if (args.length != 2) { |
104 throw new RuntimeException("wrong number of args: " + args.length); |
107 throw new RuntimeException("wrong number of args: " + args.length); |
105 } |
108 } |
106 |
109 |
|
110 final boolean hasCoops = Platform.is64bit(); |
107 final boolean useCoops = Boolean.parseBoolean(args[0]); |
111 final boolean useCoops = Boolean.parseBoolean(args[0]); |
108 final String gcArg = args[1]; |
112 final String gcArg = args[1]; |
109 final String[] jvmArgs = { |
113 |
110 useCoops ? "-XX:+UseCompressedOops" : "-XX:-UseCompressedOops", |
114 if (!hasCoops && useCoops) { |
111 gcArg, |
115 // No need to run this configuration. |
112 "-Xmx256m", |
116 System.out.println("Skipping test."); |
113 "-Xlog:gc,gc+metaspace=info", |
117 return; |
114 TestSizeTransitions.Run.class.getName() |
118 } |
115 }; |
119 |
|
120 List<String> jvmArgs = new ArrayList<>(); |
|
121 if (hasCoops) { |
|
122 jvmArgs.add(useCoops ? "-XX:+UseCompressedOops" : "-XX:-UseCompressedOops"); |
|
123 } |
|
124 jvmArgs.add(gcArg); |
|
125 jvmArgs.add("-Xmx256m"); |
|
126 jvmArgs.add("-Xlog:gc,gc+metaspace=info"); |
|
127 jvmArgs.add(TestSizeTransitions.Run.class.getName()); |
116 |
128 |
117 System.out.println("JVM args:"); |
129 System.out.println("JVM args:"); |
118 for (String a : jvmArgs) { |
130 for (String a : jvmArgs) { |
119 System.out.println(" " + a); |
131 System.out.println(" " + a); |
120 } |
132 } |
121 |
133 |
122 final ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvmArgs); |
134 final ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvmArgs.toArray(new String[0])); |
123 final OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
135 final OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
124 System.out.println(output.getStdout()); |
136 System.out.println(output.getStdout()); |
125 output.shouldHaveExitValue(0); |
137 output.shouldHaveExitValue(0); |
126 |
138 |
127 if (useCoops) { |
139 if (useCoops) { |