hotspot/test/compiler/codecache/cli/printcodecache/PrintCodeCacheRunner.java
author thartmann
Wed, 28 Jan 2015 07:55:27 +0100
changeset 28730 106944a21769
parent 28390 263a69157012
child 30604 b8d532cb6420
permissions -rw-r--r--
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34 Summary: Aligning code heap sizes to large page size if supported. Reviewed-by: kvn, anoll
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28390
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     1
/*
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     4
 *
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     8
 *
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    13
 * accompanied this code).
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    14
 *
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    18
 *
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    21
 * questions.
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    22
 */
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    23
package printcodecache;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    24
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    25
import com.oracle.java.testlibrary.ExitCode;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    26
import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    27
import common.CodeCacheCLITestCase;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    28
import common.CodeCacheInfoFormatter;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    29
import common.CodeCacheOptions;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    30
import sun.hotspot.code.BlobType;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    31
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    32
import java.util.EnumSet;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    33
import java.util.stream.Collectors;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    34
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    35
/**
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    36
 * Runner implementation aimed to verify PrintCodeCache output.
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    37
 */
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    38
public class PrintCodeCacheRunner implements CodeCacheCLITestCase.Runner {
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    39
    private final boolean printCodeCache;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    40
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    41
    public PrintCodeCacheRunner(boolean printCodeCache) {
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    42
        this.printCodeCache = printCodeCache;
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    43
    }
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    44
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    45
    public PrintCodeCacheRunner() {
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    46
        this(true);
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    47
    }
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    48
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    49
    @Override
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    50
    public void run(CodeCacheCLITestCase.Description testCaseDescription,
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    51
            CodeCacheOptions options) throws Throwable {
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    52
        CodeCacheOptions expectedValues
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    53
                = testCaseDescription.expectedValues(options);
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    54
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    55
        String[] expectedMessages
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    56
                = testCaseDescription.involvedCodeHeaps.stream()
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    57
                        .map(heap -> CodeCacheInfoFormatter.forHeap(heap)
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    58
                                .withSize(expectedValues.sizeForHeap(heap)))
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    59
                        .map(CodeCacheInfoFormatter::getInfoString)
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    60
                        .toArray(String[]::new);
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    61
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    62
        EnumSet<BlobType> unexpectedHeapsSet
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    63
                = EnumSet.complementOf(testCaseDescription.involvedCodeHeaps);
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    64
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    65
        String[] unexpectedMessages = CodeCacheInfoFormatter.forHeaps(
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    66
                unexpectedHeapsSet.toArray(
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    67
                        new BlobType[unexpectedHeapsSet.size()]));
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    68
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    69
        String description = String.format("JVM output should contain entries "
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    70
                + "for following code heaps: [%s] and should not contain "
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    71
                + "entries for following code heaps: [%s].",
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    72
                testCaseDescription.involvedCodeHeaps.stream()
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    73
                        .map(BlobType::name)
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    74
                        .collect(Collectors.joining(", ")),
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    75
                unexpectedHeapsSet.stream()
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    76
                        .map(BlobType::name)
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    77
                        .collect(Collectors.joining(", ")));
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    78
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    79
        CommandLineOptionTest.verifySameJVMStartup(expectedMessages,
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    80
                unexpectedMessages, "JVM startup failure is not expected, "
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    81
                + "since all options have allowed values", description,
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    82
                ExitCode.OK,
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    83
                testCaseDescription.getTestOptions(options,
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    84
                        CommandLineOptionTest.prepareBooleanFlag(
28730
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28390
diff changeset
    85
                                "PrintCodeCache", printCodeCache),
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28390
diff changeset
    86
                        // Do not use large pages to avoid large page
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28390
diff changeset
    87
                        // alignment of code heaps affecting their size.
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28390
diff changeset
    88
                        "-XX:-UseLargePages"));
28390
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    89
    }
263a69157012 8059623: JEP-JDK-8043304: Test task: command line options tests
fzhinkin
parents:
diff changeset
    90
}