Mon, 06 Nov 2017 16:51:47 +0800
[Code Reorganization] remove trailing whitespace to pass jcheck test
fzhinkin@7431 | 1 | /* |
fzhinkin@7431 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
fzhinkin@7431 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
fzhinkin@7431 | 4 | * |
fzhinkin@7431 | 5 | * This code is free software; you can redistribute it and/or modify it |
fzhinkin@7431 | 6 | * under the terms of the GNU General Public License version 2 only, as |
fzhinkin@7431 | 7 | * published by the Free Software Foundation. |
fzhinkin@7431 | 8 | * |
fzhinkin@7431 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
fzhinkin@7431 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
fzhinkin@7431 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
fzhinkin@7431 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
fzhinkin@7431 | 13 | * accompanied this code). |
fzhinkin@7431 | 14 | * |
fzhinkin@7431 | 15 | * You should have received a copy of the GNU General Public License version |
fzhinkin@7431 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
fzhinkin@7431 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
fzhinkin@7431 | 18 | * |
fzhinkin@7431 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
fzhinkin@7431 | 20 | * or visit www.oracle.com if you need additional information or have any |
fzhinkin@7431 | 21 | * questions. |
fzhinkin@7431 | 22 | */ |
fzhinkin@7431 | 23 | |
fzhinkin@7431 | 24 | import com.oracle.java.testlibrary.ExitCode; |
fzhinkin@7431 | 25 | import com.oracle.java.testlibrary.cli.CommandLineOptionTest; |
fzhinkin@7431 | 26 | |
fzhinkin@7431 | 27 | /** |
fzhinkin@7431 | 28 | * @test |
fzhinkin@7431 | 29 | * @bug 8031323 |
fzhinkin@7431 | 30 | * @summary Verify SurvivorAlignmentInBytes option processing. |
fzhinkin@7431 | 31 | * @library /testlibrary |
fzhinkin@7432 | 32 | * @requires vm.opt.SurvivorAlignmentInBytes == null |
fzhinkin@7432 | 33 | * & vm.opt.ObjectAlignmentInBytes == null |
fzhinkin@7432 | 34 | * & vm.opt.UnlockExperimentalVMOptions == null |
fzhinkin@7432 | 35 | * & (vm.opt.IgnoreUnrecognizedVMOptions == null |
fzhinkin@7432 | 36 | * | vm.opt.IgnoreUnrecognizedVMOptions == "false") |
fzhinkin@7431 | 37 | * @run main TestSurvivorAlignmentInBytesOption |
fzhinkin@7431 | 38 | */ |
fzhinkin@7431 | 39 | public class TestSurvivorAlignmentInBytesOption { |
fzhinkin@7431 | 40 | public static void main(String args[]) throws Throwable { |
fzhinkin@7431 | 41 | String optionName = "SurvivorAlignmentInBytes"; |
fzhinkin@7432 | 42 | String unlockExperimentalVMOpts = "UnlockExperimentalVMOptions"; |
fzhinkin@7431 | 43 | String optionIsExperimental |
fzhinkin@7431 | 44 | = CommandLineOptionTest.getExperimentalOptionErrorMessage( |
fzhinkin@7431 | 45 | optionName); |
fzhinkin@7431 | 46 | String valueIsTooSmall= ".*SurvivorAlignmentInBytes=.*must be greater" |
fzhinkin@7431 | 47 | + " than ObjectAlignmentInBytes.*"; |
fzhinkin@7431 | 48 | String mustBePowerOf2 = ".*SurvivorAlignmentInBytes=.*must be " |
fzhinkin@7431 | 49 | + "power of 2.*"; |
fzhinkin@7431 | 50 | |
fzhinkin@7431 | 51 | // Verify that without -XX:+UnlockExperimentalVMOptions usage of |
fzhinkin@7431 | 52 | // SurvivorAlignmentInBytes option will cause JVM startup failure |
fzhinkin@7431 | 53 | // with the warning message saying that that option is experimental. |
fzhinkin@7431 | 54 | CommandLineOptionTest.verifyJVMStartup( |
fzhinkin@7431 | 55 | new String[]{optionIsExperimental}, null, ExitCode.FAIL, false, |
fzhinkin@7432 | 56 | "-XX:-UnlockExperimentalVMOptions", |
fzhinkin@7432 | 57 | CommandLineOptionTest.prepareBooleanFlag( |
fzhinkin@7432 | 58 | unlockExperimentalVMOpts, false), |
fzhinkin@7432 | 59 | CommandLineOptionTest.prepareNumericFlag(optionName, 64)); |
fzhinkin@7431 | 60 | |
fzhinkin@7431 | 61 | // Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM |
fzhinkin@7431 | 62 | // usage of SurvivorAlignmentInBytes option won't cause JVM startup |
fzhinkin@7431 | 63 | // failure. |
fzhinkin@7431 | 64 | CommandLineOptionTest.verifyJVMStartup( |
fzhinkin@7431 | 65 | null, new String[]{optionIsExperimental}, ExitCode.OK, false, |
fzhinkin@7432 | 66 | CommandLineOptionTest.prepareBooleanFlag( |
fzhinkin@7432 | 67 | unlockExperimentalVMOpts, true), |
fzhinkin@7432 | 68 | CommandLineOptionTest.prepareNumericFlag(optionName, 64)); |
fzhinkin@7431 | 69 | |
fzhinkin@7431 | 70 | // Verify that if specified SurvivorAlignmentInBytes is lower then |
fzhinkin@7431 | 71 | // ObjectAlignmentInBytes, then the JVM startup will fail with |
fzhinkin@7431 | 72 | // appropriate error message. |
fzhinkin@7431 | 73 | CommandLineOptionTest.verifyJVMStartup( |
fzhinkin@7431 | 74 | new String[]{valueIsTooSmall}, null, ExitCode.FAIL, false, |
fzhinkin@7432 | 75 | CommandLineOptionTest.prepareBooleanFlag( |
fzhinkin@7432 | 76 | unlockExperimentalVMOpts, true), |
fzhinkin@7432 | 77 | CommandLineOptionTest.prepareNumericFlag(optionName, 2)); |
fzhinkin@7431 | 78 | |
fzhinkin@7431 | 79 | // Verify that if specified SurvivorAlignmentInBytes value is not |
fzhinkin@7431 | 80 | // a power of 2 then the JVM startup will fail with appropriate error |
fzhinkin@7431 | 81 | // message. |
fzhinkin@7431 | 82 | CommandLineOptionTest.verifyJVMStartup( |
fzhinkin@7431 | 83 | new String[]{mustBePowerOf2}, null, ExitCode.FAIL, false, |
fzhinkin@7432 | 84 | CommandLineOptionTest.prepareBooleanFlag( |
fzhinkin@7432 | 85 | unlockExperimentalVMOpts, true), |
fzhinkin@7432 | 86 | CommandLineOptionTest.prepareNumericFlag(optionName, 127)); |
fzhinkin@7431 | 87 | |
fzhinkin@7431 | 88 | // Verify that if SurvivorAlignmentInBytes has correct value, then |
fzhinkin@7431 | 89 | // the JVM will be started without errors. |
fzhinkin@7431 | 90 | CommandLineOptionTest.verifyJVMStartup( |
fzhinkin@7431 | 91 | null, new String[]{".*SurvivorAlignmentInBytes.*"}, |
fzhinkin@7431 | 92 | ExitCode.OK, false, |
fzhinkin@7432 | 93 | CommandLineOptionTest.prepareBooleanFlag( |
fzhinkin@7432 | 94 | unlockExperimentalVMOpts, true), |
fzhinkin@7432 | 95 | CommandLineOptionTest.prepareNumericFlag(optionName, 128)); |
fzhinkin@7431 | 96 | |
fzhinkin@7431 | 97 | // Verify that we can setup different SurvivorAlignmentInBytes values. |
fzhinkin@7431 | 98 | for (int alignment = 32; alignment <= 128; alignment *= 2) { |
fzhinkin@7431 | 99 | CommandLineOptionTest.verifyOptionValue(optionName, |
fzhinkin@7432 | 100 | Integer.toString(alignment), |
fzhinkin@7432 | 101 | CommandLineOptionTest.prepareBooleanFlag( |
fzhinkin@7432 | 102 | unlockExperimentalVMOpts, true), |
fzhinkin@7432 | 103 | CommandLineOptionTest.prepareNumericFlag( |
fzhinkin@7432 | 104 | optionName, alignment)); |
fzhinkin@7431 | 105 | } |
fzhinkin@7431 | 106 | } |
fzhinkin@7431 | 107 | } |