< prev index next >

test/gc/arguments/TestMaxHeapSizeTools.java

Print this page




  95   }
  96 
  97   private static void getNewOldSize(String gcflag, long[] values) throws Exception {
  98     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(gcflag,
  99       "-XX:+PrintFlagsFinal", "-version");
 100     OutputAnalyzer output = new OutputAnalyzer(pb.start());
 101     output.shouldHaveExitValue(0);
 102 
 103     String stdout = output.getStdout();
 104     values[0] = getFlagValue(" NewSize", stdout);
 105     values[1] = getFlagValue(" OldSize", stdout);
 106   }
 107 
 108   public static void checkGenMaxHeapErgo(String gcflag) throws Exception {
 109     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 3);
 110     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 4);
 111     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 5);
 112   }
 113 
 114   private static void checkInvalidMinInitialHeapCombinations(String gcflag) throws Exception {

 115     expectError(new String[] { gcflag, "-Xms64M", "-XX:InitialHeapSize=32M", "-version" });
 116   }
 117 
 118   private static void checkValidMinInitialHeapCombinations(String gcflag) throws Exception {

 119     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=8M", "-Xms4M", "-version" });
 120     expectValid(new String[] { gcflag, "-Xms4M", "-XX:InitialHeapSize=8M", "-version" });
 121     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=8M", "-Xms8M", "-version" });
 122     // the following is not an error as -Xms sets both minimal and initial heap size
 123     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=4M", "-Xms8M", "-version" });
 124   }
 125 
 126   private static void checkInvalidInitialMaxHeapCombinations(String gcflag) throws Exception {

 127     expectError(new String[] { gcflag, "-XX:MaxHeapSize=4M", "-XX:InitialHeapSize=8M", "-version" });
 128     expectError(new String[] { gcflag, "-XX:InitialHeapSize=8M", "-XX:MaxHeapSize=4M", "-version" });
 129   }
 130 
 131   private static void checkValidInitialMaxHeapCombinations(String gcflag) throws Exception {

 132     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=4M", "-XX:MaxHeapSize=8M", "-version" });
 133     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=8M", "-XX:InitialHeapSize=4M", "-version" });
 134     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=4M", "-XX:InitialHeapSize=4M", "-version" });
 135     // a value of "0" for initial heap size means auto-detect
 136     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=4M", "-XX:InitialHeapSize=0M", "-version" });
 137   }
 138 
 139   private static long valueAfter(String source, String match) {
 140     int start = source.indexOf(match) + match.length();
 141     String tail = source.substring(start).split(" ")[0];
 142     return Long.parseLong(tail);
 143   }
 144 
 145   /**
 146    * Executes a new VM process with the given class and parameters.
 147    * @param vmargs Arguments to the VM to run
 148    * @param classname Name of the class to run
 149    * @param arguments Arguments to the class
 150    * @param useTestDotJavaDotOpts Use test.java.opts as part of the VM argument string
 151    * @return The OutputAnalyzer with the results for the invocation.




  95   }
  96 
  97   private static void getNewOldSize(String gcflag, long[] values) throws Exception {
  98     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(gcflag,
  99       "-XX:+PrintFlagsFinal", "-version");
 100     OutputAnalyzer output = new OutputAnalyzer(pb.start());
 101     output.shouldHaveExitValue(0);
 102 
 103     String stdout = output.getStdout();
 104     values[0] = getFlagValue(" NewSize", stdout);
 105     values[1] = getFlagValue(" OldSize", stdout);
 106   }
 107 
 108   public static void checkGenMaxHeapErgo(String gcflag) throws Exception {
 109     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 3);
 110     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 4);
 111     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 5);
 112   }
 113 
 114   private static void checkInvalidMinInitialHeapCombinations(String gcflag) throws Exception {
 115     expectError(new String[] { gcflag, "-XX:InitialHeapSize=1023K", "-version" });
 116     expectError(new String[] { gcflag, "-Xms64M", "-XX:InitialHeapSize=32M", "-version" });
 117   }
 118 
 119   private static void checkValidMinInitialHeapCombinations(String gcflag) throws Exception {
 120     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=1024K", "-version" });
 121     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=8M", "-Xms4M", "-version" });
 122     expectValid(new String[] { gcflag, "-Xms4M", "-XX:InitialHeapSize=8M", "-version" });
 123     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=8M", "-Xms8M", "-version" });
 124     // the following is not an error as -Xms sets both minimal and initial heap size
 125     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=4M", "-Xms8M", "-version" });
 126   }
 127 
 128   private static void checkInvalidInitialMaxHeapCombinations(String gcflag) throws Exception {
 129     expectError(new String[] { gcflag, "-XX:MaxHeapSize=2047K", "-version" });
 130     expectError(new String[] { gcflag, "-XX:MaxHeapSize=4M", "-XX:InitialHeapSize=8M", "-version" });
 131     expectError(new String[] { gcflag, "-XX:InitialHeapSize=8M", "-XX:MaxHeapSize=4M", "-version" });
 132   }
 133 
 134   private static void checkValidInitialMaxHeapCombinations(String gcflag) throws Exception {
 135     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=2048K", "-version" });
 136     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=4M", "-XX:MaxHeapSize=8M", "-version" });
 137     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=8M", "-XX:InitialHeapSize=4M", "-version" });
 138     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=4M", "-XX:InitialHeapSize=4M", "-version" });
 139     // a value of "0" for initial heap size means auto-detect
 140     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=4M", "-XX:InitialHeapSize=0M", "-version" });
 141   }
 142 
 143   private static long valueAfter(String source, String match) {
 144     int start = source.indexOf(match) + match.length();
 145     String tail = source.substring(start).split(" ")[0];
 146     return Long.parseLong(tail);
 147   }
 148 
 149   /**
 150    * Executes a new VM process with the given class and parameters.
 151    * @param vmargs Arguments to the VM to run
 152    * @param classname Name of the class to run
 153    * @param arguments Arguments to the class
 154    * @param useTestDotJavaDotOpts Use test.java.opts as part of the VM argument string
 155    * @return The OutputAnalyzer with the results for the invocation.


< prev index next >