< prev index next >

test/gc/arguments/TestSurvivorAlignmentInBytesOption.java

Print this page
rev 7469 : 8066143: [TESTBUG] New tests in gc/survivorAlignment/ fails
Reviewed-by:


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import com.oracle.java.testlibrary.ExitCode;
  25 import com.oracle.java.testlibrary.Utils;
  26 import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
  27 
  28 import java.util.Collections;
  29 import java.util.LinkedList;
  30 import java.util.List;
  31 
  32 /**
  33  * @test
  34  * @bug 8031323
  35  * @summary Verify SurvivorAlignmentInBytes option processing.
  36  * @library /testlibrary





  37  * @run main TestSurvivorAlignmentInBytesOption
  38  */
  39 public class TestSurvivorAlignmentInBytesOption {
  40     private static final String[] FILTERED_VM_OPTIONS
  41             = Utils.getFilteredTestJavaOpts(
  42             "UnlockExperimentalVMOptions",
  43             "SurvivorAlignmentInBytes",
  44             "ObjectAlignmentInBytes");
  45 
  46     public static void main(String args[]) throws Throwable {
  47         String optionName = "SurvivorAlignmentInBytes";

  48         String optionIsExperimental
  49                 = CommandLineOptionTest.getExperimentalOptionErrorMessage(
  50                 optionName);
  51         String valueIsTooSmall= ".*SurvivorAlignmentInBytes=.*must be greater"
  52                 + " than ObjectAlignmentInBytes.*";
  53         String mustBePowerOf2 = ".*SurvivorAlignmentInBytes=.*must be "
  54                 + "power of 2.*";
  55 
  56         // Verify that without -XX:+UnlockExperimentalVMOptions usage of
  57         // SurvivorAlignmentInBytes option will cause JVM startup failure
  58         // with the warning message saying that that option is experimental.
  59         CommandLineOptionTest.verifyJVMStartup(
  60                 new String[]{optionIsExperimental}, null, ExitCode.FAIL, false,
  61                 TestSurvivorAlignmentInBytesOption.prepareOptions(
  62                         "-XX:-UnlockExperimentalVMOptions",
  63                         CommandLineOptionTest.prepareNumericFlag(
  64                                 optionName, 64)));

  65 
  66         // Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM
  67         // usage of SurvivorAlignmentInBytes option won't cause JVM startup
  68         // failure.
  69         CommandLineOptionTest.verifyJVMStartup(
  70                 null, new String[]{optionIsExperimental}, ExitCode.OK, false,
  71                 TestSurvivorAlignmentInBytesOption.prepareOptions(
  72                         CommandLineOptionTest.prepareNumericFlag(
  73                                 optionName, 64)));
  74 
  75         // Verify that if specified SurvivorAlignmentInBytes is lower then
  76         // ObjectAlignmentInBytes, then the JVM startup will fail with
  77         // appropriate error message.
  78         CommandLineOptionTest.verifyJVMStartup(
  79                 new String[]{valueIsTooSmall}, null, ExitCode.FAIL, false,
  80                 TestSurvivorAlignmentInBytesOption.prepareOptions(
  81                         CommandLineOptionTest.prepareNumericFlag(
  82                                 optionName, 2)));
  83 
  84         // Verify that if specified SurvivorAlignmentInBytes value is not
  85         // a power of 2 then the JVM startup will fail with appropriate error
  86         // message.
  87         CommandLineOptionTest.verifyJVMStartup(
  88                 new String[]{mustBePowerOf2}, null, ExitCode.FAIL, false,
  89                 TestSurvivorAlignmentInBytesOption.prepareOptions(
  90                         CommandLineOptionTest.prepareNumericFlag(
  91                                 optionName, 127)));
  92 
  93         // Verify that if SurvivorAlignmentInBytes has correct value, then
  94         // the JVM will be started without errors.
  95         CommandLineOptionTest.verifyJVMStartup(
  96                 null, new String[]{".*SurvivorAlignmentInBytes.*"},
  97                 ExitCode.OK, false,
  98                 TestSurvivorAlignmentInBytesOption.prepareOptions(
  99                         CommandLineOptionTest.prepareNumericFlag(
 100                                 optionName, 128)));
 101 
 102         // Verify that we can setup different SurvivorAlignmentInBytes values.
 103         for (int alignment = 32; alignment <= 128; alignment *= 2) {
 104             CommandLineOptionTest.verifyOptionValue(optionName,
 105                     Integer.toString(alignment), false,
 106                     TestSurvivorAlignmentInBytesOption.prepareOptions(

 107                             CommandLineOptionTest.prepareNumericFlag(
 108                                     optionName, alignment)));
 109         }
 110     }
 111 
 112     private static String[] prepareOptions(String... options) {
 113         List<String> finalOptions = new LinkedList<>();
 114         Collections.addAll(finalOptions,
 115                 TestSurvivorAlignmentInBytesOption.FILTERED_VM_OPTIONS);
 116         finalOptions.add(CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
 117         Collections.addAll(finalOptions, options);
 118         return finalOptions.toArray(new String[finalOptions.size()]);
 119     }
 120 }


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import com.oracle.java.testlibrary.ExitCode;

  25 import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
  26 




  27 /**
  28  * @test
  29  * @bug 8031323
  30  * @summary Verify SurvivorAlignmentInBytes option processing.
  31  * @library /testlibrary
  32  * @requires vm.opt.SurvivorAlignmentInBytes == null
  33  *           & vm.opt.ObjectAlignmentInBytes == null
  34  *           & vm.opt.UnlockExperimentalVMOptions == null
  35  *           & (vm.opt.IgnoreUnrecognizedVMOptions == null
  36  *              | vm.opt.IgnoreUnrecognizedVMOptions == "false")
  37  * @run main TestSurvivorAlignmentInBytesOption
  38  */
  39 public class TestSurvivorAlignmentInBytesOption {






  40     public static void main(String args[]) throws Throwable {
  41         String optionName = "SurvivorAlignmentInBytes";
  42         String unlockExperimentalVMOpts = "UnlockExperimentalVMOptions";
  43         String optionIsExperimental
  44                 = CommandLineOptionTest.getExperimentalOptionErrorMessage(
  45                 optionName);
  46         String valueIsTooSmall= ".*SurvivorAlignmentInBytes=.*must be greater"
  47                 + " than ObjectAlignmentInBytes.*";
  48         String mustBePowerOf2 = ".*SurvivorAlignmentInBytes=.*must be "
  49                 + "power of 2.*";
  50 
  51         // Verify that without -XX:+UnlockExperimentalVMOptions usage of
  52         // SurvivorAlignmentInBytes option will cause JVM startup failure
  53         // with the warning message saying that that option is experimental.
  54         CommandLineOptionTest.verifyJVMStartup(
  55                 new String[]{optionIsExperimental}, null, ExitCode.FAIL, false,

  56                 "-XX:-UnlockExperimentalVMOptions",
  57                 CommandLineOptionTest.prepareBooleanFlag(
  58                         unlockExperimentalVMOpts, false),
  59                 CommandLineOptionTest.prepareNumericFlag(optionName, 64));
  60 
  61         // Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM
  62         // usage of SurvivorAlignmentInBytes option won't cause JVM startup
  63         // failure.
  64         CommandLineOptionTest.verifyJVMStartup(
  65                 null, new String[]{optionIsExperimental}, ExitCode.OK, false,
  66                 CommandLineOptionTest.prepareBooleanFlag(
  67                         unlockExperimentalVMOpts, true),
  68                 CommandLineOptionTest.prepareNumericFlag(optionName, 64));
  69 
  70         // Verify that if specified SurvivorAlignmentInBytes is lower then
  71         // ObjectAlignmentInBytes, then the JVM startup will fail with
  72         // appropriate error message.
  73         CommandLineOptionTest.verifyJVMStartup(
  74                 new String[]{valueIsTooSmall}, null, ExitCode.FAIL, false,
  75                 CommandLineOptionTest.prepareBooleanFlag(
  76                         unlockExperimentalVMOpts, true),
  77                 CommandLineOptionTest.prepareNumericFlag(optionName, 2));
  78 
  79         // Verify that if specified SurvivorAlignmentInBytes value is not
  80         // a power of 2 then the JVM startup will fail with appropriate error
  81         // message.
  82         CommandLineOptionTest.verifyJVMStartup(
  83                 new String[]{mustBePowerOf2}, null, ExitCode.FAIL, false,
  84                 CommandLineOptionTest.prepareBooleanFlag(
  85                         unlockExperimentalVMOpts, true),
  86                 CommandLineOptionTest.prepareNumericFlag(optionName, 127));
  87 
  88         // Verify that if SurvivorAlignmentInBytes has correct value, then
  89         // the JVM will be started without errors.
  90         CommandLineOptionTest.verifyJVMStartup(
  91                 null, new String[]{".*SurvivorAlignmentInBytes.*"},
  92                 ExitCode.OK, false,
  93                 CommandLineOptionTest.prepareBooleanFlag(
  94                         unlockExperimentalVMOpts, true),
  95                 CommandLineOptionTest.prepareNumericFlag(optionName, 128));
  96 
  97         // Verify that we can setup different SurvivorAlignmentInBytes values.
  98         for (int alignment = 32; alignment <= 128; alignment *= 2) {
  99             CommandLineOptionTest.verifyOptionValue(optionName,
 100                     Integer.toString(alignment),
 101                     CommandLineOptionTest.prepareBooleanFlag(
 102                             unlockExperimentalVMOpts, true),
 103                     CommandLineOptionTest.prepareNumericFlag(
 104                             optionName, alignment));
 105         }









 106     }
 107 }
< prev index next >