hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java
author eistepan
Tue, 16 Dec 2014 14:52:57 +0300
changeset 28200 38d3bf236c31
parent 24007 40c951a7d36c
child 30604 b8d532cb6420
permissions -rw-r--r--
8054892: Improve compiler's CLI tests error reporting Reviewed-by: roland, twisti
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
/*
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
 */
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    24
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    25
import com.oracle.java.testlibrary.*;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    26
import com.oracle.java.testlibrary.cli.*;
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    27
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    28
import java.util.function.BooleanSupplier;
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
public abstract class TestPrintPreciseRTMLockingStatisticsBase
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    31
        extends RTMGenericCommandLineOptionTest {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    32
    protected static final String DEFAULT_VALUE = "false";
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    33
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    34
    protected TestPrintPreciseRTMLockingStatisticsBase(
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    35
            BooleanSupplier predicate) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    36
        super(predicate, "PrintPreciseRTMLockingStatistics", true, false,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    37
                TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE);
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    38
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    39
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    40
    @Override
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    41
    protected void runNonX86TestCases() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    42
        verifyJVMStartup();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    43
        verifyOptionValues();
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    44
    }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    45
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    46
    @Override
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    47
    protected void verifyJVMStartup() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    48
        if (Platform.isServer()) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    49
            if (!Platform.isDebugBuild()) {
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    50
                String shouldFailMessage = String.format("VM option '%s' is "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    51
                        + "diagnostic%nJVM startup should fail without "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    52
                        + "-XX:\\+UnlockDiagnosticVMOptions flag", optionName);
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    53
                String shouldPassMessage = String.format("VM option '%s' is "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    54
                        + "diagnostic%nJVM startup should pass with "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    55
                        + "-XX:\\+UnlockDiagnosticVMOptions in debug build",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    56
                        optionName);
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    57
                String errorMessage = CommandLineOptionTest.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    58
                        getDiagnosticOptionErrorMessage(optionName);
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    59
                // verify that option is actually diagnostic
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    60
                CommandLineOptionTest.verifySameJVMStartup(
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    61
                        new String[] { errorMessage }, null, shouldFailMessage,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    62
                        shouldFailMessage, ExitCode.FAIL,
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    63
                        prepareOptionValue("true"));
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    64
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    65
                CommandLineOptionTest.verifySameJVMStartup(null,
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    66
                        new String[] { errorMessage }, shouldPassMessage,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    67
                        shouldPassMessage + "without any warnings", ExitCode.OK,
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    68
                        CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    69
                        prepareOptionValue("true"));
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    70
            } else {
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    71
                String shouldPassMessage = String.format("JVM startup should "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    72
                                + "pass with '%s' option in debug build",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    73
                                optionName);
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    74
                CommandLineOptionTest.verifySameJVMStartup(null, null,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    75
                        shouldPassMessage, shouldPassMessage,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    76
                        ExitCode.OK, prepareOptionValue("true"));
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    77
            }
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    78
        } else {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    79
            String errorMessage = CommandLineOptionTest.
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    80
                    getUnrecognizedOptionErrorMessage(optionName);
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    81
            String shouldFailMessage =  String.format("JVM startup should fail"
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    82
                    + " with '%s' option in not debug build", optionName);
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    83
            CommandLineOptionTest.verifySameJVMStartup(
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    84
                    new String[]{errorMessage}, null, shouldFailMessage,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    85
                    shouldFailMessage, ExitCode.FAIL,
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    86
                    CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    87
                    prepareOptionValue("true"));
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    88
        }
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
    protected void verifyOptionValues() throws Throwable {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    93
        if (Platform.isServer()) {
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    94
            // Verify default value
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    95
            CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
    96
                    TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE,
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    97
                    String.format("Option '%s' should have '%s' default value",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    98
                            optionName,
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 24007
diff changeset
    99
                       TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE),
24007
40c951a7d36c 8039496: Add sanity tests on RTM-related command line options
iignatyev
parents:
diff changeset
   100
                    CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
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
}