hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java
author stsmirno
Mon, 17 Oct 2016 18:54:12 -0400
changeset 41705 332239c052cc
parent 40631 ed82623d7831
child 46515 dbb676a40899
permissions -rw-r--r--
8165687: Fix license and copyright headers in jd9 under hotspot/test Summary: Legal notices and Oracle copyrights were updated (white and blank space, commas) in tests files for uniformity to meet Oracle requirements. Reviewed-by: dholmes, iris Contributed-by: Stanislav Smirnov <stanislav.smirnov@oracle.com>, Vassili Igouchkine <vassili.igouchkine@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     1
/*
40015
524230a0f4ca 8140723: Remove source code conditionalized on JAVASE_EMBEDDED
dholmes
parents: 30607
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     4
 *
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     8
 *
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    14
 *
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    18
 *
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    21
 * questions.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    22
 */
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    23
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 30607
diff changeset
    24
package compiler.rtm.cli;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 30607
diff changeset
    25
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40093
diff changeset
    26
import jdk.test.lib.process.ExitCode;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 30607
diff changeset
    27
import jdk.test.lib.Platform;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 30607
diff changeset
    28
import jdk.test.lib.cli.CommandLineOptionTest;
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    29
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    30
import java.util.function.BooleanSupplier;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    31
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    32
/**
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    33
 * Base for all RTM-related CLI tests.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    34
 */
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    35
public abstract class RTMGenericCommandLineOptionTest
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    36
        extends CommandLineOptionTest {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    37
    protected static final String RTM_INSTR_ERROR
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    38
            = "RTM instructions are not available on this CPU";
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    39
    protected static final String RTM_UNSUPPORTED_VM_ERROR
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    40
            = "RTM locking optimization is not supported in this VM";
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    41
    protected static final String RTM_ABORT_RATIO_WARNING
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    42
            = "RTMAbortRatio must be in the range 0 to 100, resetting it to 50";
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    43
    protected static final String RTM_FOR_STACK_LOCKS_WARNING
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    44
            = "UseRTMForStackLocks flag should be off when UseRTMLocking "
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    45
            + "flag is off";
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    46
    protected static final String RTM_COUNT_INCR_WARNING
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    47
            = "RTMTotalCountIncrRate must be a power of 2, resetting it to 64";
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    48
    protected static final String RTM_BIASED_LOCKING_WARNING
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    49
            = "Biased locking is not supported with RTM locking; "
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    50
            + "ignoring UseBiasedLocking flag";
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    51
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    52
    protected final String optionName;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    53
    protected final String errorMessage;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    54
    protected final String experimentalOptionError;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    55
    protected final boolean isExperimental;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    56
    protected final boolean isBoolean;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    57
    protected final String defaultValue;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    58
    protected final String[] optionValues;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    59
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    60
    /**
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    61
     * Constructs new genetic RTM CLI test, for option {@code optionName} which
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    62
     * has default value {@code defaultValue}. Test cases will use option's
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    63
     * values passed via {@code optionValues} for verification of correct
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    64
     * option processing.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    65
     *
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    66
     * Test constructed using this ctor will be started on any cpu regardless
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    67
     * it's architecture and supported/unsupported features.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    68
     *
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    69
     * @param predicate predicate responsible for test's preconditions check
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    70
     * @param optionName name of option to be tested
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    71
     * @param isBoolean {@code true} if option is binary
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    72
     * @param isExperimental {@code true} if option is experimental
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    73
     * @param defaultValue default value of tested option
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    74
     * @param optionValues different option values
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    75
     */
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    76
    public RTMGenericCommandLineOptionTest(BooleanSupplier predicate,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    77
            String optionName, boolean isBoolean, boolean isExperimental,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    78
            String defaultValue, String... optionValues) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    79
        super(predicate);
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    80
        this.optionName = optionName;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    81
        this.isExperimental = isExperimental;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    82
        this.isBoolean = isBoolean;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    83
        this.defaultValue = defaultValue;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    84
        this.optionValues = optionValues;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    85
        this.errorMessage = CommandLineOptionTest.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    86
                getUnrecognizedOptionErrorMessage(optionName);
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    87
        this.experimentalOptionError = CommandLineOptionTest.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    88
                getExperimentalOptionErrorMessage(optionName);
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    89
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    90
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    91
    @Override
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    92
    public void runTestCases() throws Throwable {
30589
4722e25bfd6d 8078593: [TESTBUG] ppc: Enable jtreg tests for new features
goetz
parents: 28200
diff changeset
    93
        if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) {
40015
524230a0f4ca 8140723: Remove source code conditionalized on JAVASE_EMBEDDED
dholmes
parents: 30607
diff changeset
    94
            if (Platform.isServer()) {
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    95
                runX86SupportedVMTestCases();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    96
            } else {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    97
                runX86UnsupportedVMTestCases();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    98
            }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    99
        } else {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   100
            runNonX86TestCases();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   101
        }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   102
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   103
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   104
    /**
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   105
     * Runs test cases on X86 CPU if VM supports RTM locking.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   106
     * @throws Throwable
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   107
     */
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   108
    protected void runX86SupportedVMTestCases() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   109
        runGenericX86TestCases();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   110
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   111
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   112
    /**
30589
4722e25bfd6d 8078593: [TESTBUG] ppc: Enable jtreg tests for new features
goetz
parents: 28200
diff changeset
   113
     * Runs test cases on X86 CPU if VM does not support RTM locking.
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   114
     * @throws Throwable
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   115
     */
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   116
    protected void runX86UnsupportedVMTestCases() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   117
        runGenericX86TestCases();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   118
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   119
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   120
    /**
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   121
     * Runs test cases on non-X86 CPU.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   122
     * @throws Throwable
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   123
     */
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   124
    protected void runNonX86TestCases() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   125
        CommandLineOptionTest.verifySameJVMStartup(
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   126
                new String[] { errorMessage }, null,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   127
                String.format("Option '%s' should be unknown on non-X86CPUs.%n"
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   128
                + "JVM startup should fail", optionName), "", ExitCode.FAIL,
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   129
                prepareOptionValue(defaultValue));
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   130
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   131
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   132
    /**
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   133
     * Runs generic X86 test cases.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   134
     * @throws Throwable
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   135
     */
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   136
    protected void runGenericX86TestCases() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   137
        verifyJVMStartup();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   138
        verifyOptionValues();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   139
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   140
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   141
    protected void verifyJVMStartup() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   142
        String optionValue = prepareOptionValue(defaultValue);
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   143
        String shouldFailMessage = String.format("VM option '%s' is "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   144
                + "experimental.%nVM startup expected to fail without "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   145
                + "-XX:+UnlockExperimentalVMOptions option", optionName);
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   146
        String shouldPassMessage = String.format("VM option '%s' is "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   147
                + "experimental%nVM startup should pass with "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   148
                + "-XX:+UnlockExperimentalVMOptions option", optionName);
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   149
        if (isExperimental) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   150
            // verify that option is experimental
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   151
            CommandLineOptionTest.verifySameJVMStartup(
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   152
                    new String[] { experimentalOptionError },
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   153
                    new String[] { errorMessage }, shouldFailMessage,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   154
                    shouldFailMessage, ExitCode.FAIL, optionValue);
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   155
            // verify that it could be passed if experimental options
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   156
            // are unlocked
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   157
            CommandLineOptionTest.verifySameJVMStartup(null,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   158
                    new String[] {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   159
                            experimentalOptionError,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   160
                            errorMessage
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   161
                    },
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   162
                    shouldPassMessage,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   163
                    "JVM should start without any warnings or errors",
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   164
                    ExitCode.OK,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   165
                    CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   166
                    optionValue);
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   167
        } else {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   168
            // verify that option could be passed
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   169
            CommandLineOptionTest.verifySameJVMStartup(null,
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   170
                    new String[]{errorMessage},
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   171
                    String.format("VM startup shuld pass with '%s' option",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   172
                            optionName),
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   173
                    "JVM should start without any warnings or errors",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   174
                    ExitCode.OK, optionValue);
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   175
        }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   176
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   177
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   178
    protected void verifyOptionValues() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   179
        // verify default value
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   180
        if (isExperimental) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   181
            CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   182
                    defaultValue,
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   183
                    String.format("Option '%s' is expected to have '%s' "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   184
                            + "default value", optionName, defaultValue),
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   185
                    CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   186
        } else {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   187
            CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   188
                    defaultValue,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   189
                    String.format("Option '%s' is expected to have '%s' "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   190
                            + "default value", optionName, defaultValue));
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   191
        }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   192
        // verify other specified option values
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   193
        if (optionValues == null) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   194
            return;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   195
        }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   196
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   197
        for (String value : optionValues) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   198
            if (isExperimental) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   199
                CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   200
                        value,
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   201
                        String.format("Option '%s' is set to have '%s' value",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   202
                                optionName, value),
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   203
                        CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   204
                        prepareOptionValue(value));
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   205
            } else {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   206
                CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   207
                        value,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   208
                        String.format("Option '%s' is set to have '%s' value",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
   209
                                optionName, value), prepareOptionValue(value));
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   210
            }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   211
        }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   212
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   213
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   214
    protected String prepareOptionValue(String value) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   215
        if (isBoolean) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   216
            return CommandLineOptionTest.prepareBooleanFlag(optionName,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   217
                    Boolean.valueOf(value));
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   218
        } else {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   219
            return String.format("-XX:%s=%s", optionName, value);
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   220
        }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   221
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   222
}