< prev index next >

test/gc/arguments/TestObjectTenuringFlags.java

Print this page
rev 8851 : [mq]: webrev.00


 140         new ExpectedTenuringFlags());
 141 
 142     runTenuringFlagsConsistencyTest(
 143         new String[]{"-XX:InitialTenuringThreshold=16"},
 144         true /* shouldFail */,
 145         new ExpectedTenuringFlags());
 146 
 147     runTenuringFlagsConsistencyTest(
 148         new String[]{"-XX:InitialTenuringThreshold=17"},
 149         true /* shouldFail */,
 150         new ExpectedTenuringFlags());
 151   }
 152 
 153   private static void runTenuringFlagsConsistencyTest(String[] tenuringFlags,
 154           boolean shouldFail,
 155           ExpectedTenuringFlags expectedFlags) throws Exception {
 156     List<String> vmOpts = new ArrayList<>();
 157     if (tenuringFlags.length > 0) {
 158       Collections.addAll(vmOpts, tenuringFlags);
 159     }
 160     Collections.addAll(vmOpts, "-XX:+PrintFlagsFinal", "-version");
 161 
 162     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
 163     OutputAnalyzer output = new OutputAnalyzer(pb.start());
 164 
 165     if (shouldFail) {
 166       output.shouldHaveExitValue(1);
 167     } else {
 168       output.shouldHaveExitValue(0);
 169       String stdout = output.getStdout();
 170       checkTenuringFlagsConsistency(stdout, expectedFlags);
 171     }
 172   }
 173 
 174   private static void checkTenuringFlagsConsistency(String output, ExpectedTenuringFlags expectedFlags) {
 175     if (expectedFlags.alwaysTenure != FlagsValue.getFlagBoolValue("AlwaysTenure", output)) {
 176       throw new RuntimeException(
 177             "Actual flag AlwaysTenure " + FlagsValue.getFlagBoolValue("AlwaysTenure", output) +
 178             " is not equal to expected flag AlwaysTenure " + expectedFlags.alwaysTenure);
 179     }
 180 




 140         new ExpectedTenuringFlags());
 141 
 142     runTenuringFlagsConsistencyTest(
 143         new String[]{"-XX:InitialTenuringThreshold=16"},
 144         true /* shouldFail */,
 145         new ExpectedTenuringFlags());
 146 
 147     runTenuringFlagsConsistencyTest(
 148         new String[]{"-XX:InitialTenuringThreshold=17"},
 149         true /* shouldFail */,
 150         new ExpectedTenuringFlags());
 151   }
 152 
 153   private static void runTenuringFlagsConsistencyTest(String[] tenuringFlags,
 154           boolean shouldFail,
 155           ExpectedTenuringFlags expectedFlags) throws Exception {
 156     List<String> vmOpts = new ArrayList<>();
 157     if (tenuringFlags.length > 0) {
 158       Collections.addAll(vmOpts, tenuringFlags);
 159     }
 160     Collections.addAll(vmOpts, "-XX:+UseParallelGC", "-XX:+PrintFlagsFinal", "-version");
 161 
 162     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
 163     OutputAnalyzer output = new OutputAnalyzer(pb.start());
 164 
 165     if (shouldFail) {
 166       output.shouldHaveExitValue(1);
 167     } else {
 168       output.shouldHaveExitValue(0);
 169       String stdout = output.getStdout();
 170       checkTenuringFlagsConsistency(stdout, expectedFlags);
 171     }
 172   }
 173 
 174   private static void checkTenuringFlagsConsistency(String output, ExpectedTenuringFlags expectedFlags) {
 175     if (expectedFlags.alwaysTenure != FlagsValue.getFlagBoolValue("AlwaysTenure", output)) {
 176       throw new RuntimeException(
 177             "Actual flag AlwaysTenure " + FlagsValue.getFlagBoolValue("AlwaysTenure", output) +
 178             " is not equal to expected flag AlwaysTenure " + expectedFlags.alwaysTenure);
 179     }
 180 


< prev index next >