test/jtreg-ext/requires/VMProps.java
author jwilhelm
Thu, 01 Feb 2018 02:05:35 +0100
changeset 48829 93de07994202
parent 48155 551de50b4ff7
child 48880 ee49ac008730
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
     1
/*
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
     4
 *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
     8
 *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    13
 * accompanied this code).
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    14
 *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    18
 *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    21
 * questions.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    22
 */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    23
package requires;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    24
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    25
import java.io.IOException;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    26
import java.nio.file.Files;
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
    27
import java.nio.file.Path;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    28
import java.nio.file.Paths;
42511
8009d4cba2ea 8170228: register closed @requires property setter
iignatyev
parents: 42006
diff changeset
    29
import java.nio.file.StandardOpenOption;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    30
import java.util.ArrayList;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    31
import java.util.HashMap;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    32
import java.util.List;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    33
import java.util.Map;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    34
import java.util.concurrent.Callable;
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
    35
import java.util.concurrent.TimeUnit;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    36
import java.util.regex.Matcher;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    37
import java.util.regex.Pattern;
43389
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
    38
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
    39
import sun.hotspot.cpuinfo.CPUInfo;
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
    40
import sun.hotspot.gc.GC;
39941
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
    41
import sun.hotspot.WhiteBox;
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
    42
import jdk.test.lib.Platform;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    43
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    44
/**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    45
 * The Class to be invoked by jtreg prior Test Suite execution to
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    46
 * collect information about VM.
39941
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
    47
 * Do not use any API's that may not be available in all target VMs.
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    48
 * Properties set by this Class will be available in the @requires expressions.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    49
 */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    50
public class VMProps implements Callable<Map<String, String>> {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    51
39941
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
    52
    private static final WhiteBox WB = WhiteBox.getWhiteBox();
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
    53
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    54
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    55
     * Collects information about VM properties.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    56
     * This method will be invoked by jtreg.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    57
     *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    58
     * @return Map of property-value pairs.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    59
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    60
    @Override
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    61
    public Map<String, String> call() {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    62
        Map<String, String> map = new HashMap<>();
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    63
        map.put("vm.flavor", vmFlavor());
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    64
        map.put("vm.compMode", vmCompMode());
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    65
        map.put("vm.bits", vmBits());
39199
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
    66
        map.put("vm.flightRecorder", vmFlightRecorder());
39198
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
    67
        map.put("vm.simpleArch", vmArch());
42006
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
    68
        map.put("vm.debug", vmDebug());
42512
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
    69
        map.put("vm.jvmci", vmJvmci());
43394
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
    70
        map.put("vm.emulatedClient", vmEmulatedClient());
43389
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
    71
        map.put("vm.cpu.features", cpuFeatures());
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
    72
        map.put("vm.rtm.cpu", vmRTMCPU());
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
    73
        map.put("vm.rtm.os", vmRTMOS());
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
    74
        map.put("vm.aot", vmAOT());
46242
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
    75
        // vm.cds is true if the VM is compiled with cds support.
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
    76
        map.put("vm.cds", vmCDS());
48155
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
    77
        map.put("vm.cds.custom.loaders", vmCDSForCustomLoaders());
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
    78
        // vm.graal.enabled is true if Graal is used as JIT
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
    79
        map.put("vm.graal.enabled", isGraalEnabled());
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
    80
        map.put("docker.support", dockerSupport());
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
    81
        vmGC(map); // vm.gc.X = true/false
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
    82
42511
8009d4cba2ea 8170228: register closed @requires property setter
iignatyev
parents: 42006
diff changeset
    83
        VMProps.dump(map);
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    84
        return map;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    85
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    86
39198
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
    87
    /**
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    88
     * Prints a stack trace before returning null.
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    89
     * Used by the various helper functions which parse information from
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    90
     * VM properties in the case where they don't find an expected property
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    91
     * or a propoerty doesn't conform to an expected format.
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    92
     *
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    93
     * @return null
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    94
     */
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    95
    private String nullWithException(String message) {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    96
        new Exception(message).printStackTrace();
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    97
        return null;
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    98
    }
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
    99
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   100
    /**
39198
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   101
     * @return vm.simpleArch value of "os.simpleArch" property of tested JDK.
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   102
     */
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   103
    protected String vmArch() {
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   104
        String arch = System.getProperty("os.arch");
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   105
        if (arch.equals("x86_64") || arch.equals("amd64")) {
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   106
            return "x64";
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   107
        }
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   108
        else if (arch.contains("86")) {
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   109
            return "x86";
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   110
        } else {
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   111
            return arch;
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   112
        }
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   113
    }
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   114
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   115
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   116
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   117
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   118
     * @return VM type value extracted from the "java.vm.name" property.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   119
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   120
    protected String vmFlavor() {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   121
        // E.g. "Java HotSpot(TM) 64-Bit Server VM"
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   122
        String vmName = System.getProperty("java.vm.name");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   123
        if (vmName == null) {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   124
            return nullWithException("Can't get 'java.vm.name' property");
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   125
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   126
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   127
        Pattern startP = Pattern.compile(".* (\\S+) VM");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   128
        Matcher m = startP.matcher(vmName);
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   129
        if (m.matches()) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   130
            return m.group(1).toLowerCase();
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   131
        }
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   132
        return nullWithException("Can't get VM flavor from 'java.vm.name'");
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   133
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   134
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   135
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   136
     * @return VM compilation mode extracted from the "java.vm.info" property.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   137
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   138
    protected String vmCompMode() {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   139
        // E.g. "mixed mode"
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   140
        String vmInfo = System.getProperty("java.vm.info");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   141
        if (vmInfo == null) {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   142
            return nullWithException("Can't get 'java.vm.info' property");
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   143
        }
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   144
        if (vmInfo.toLowerCase().indexOf("mixed mode") != -1) {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   145
            return "Xmixed";
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   146
        } else if (vmInfo.toLowerCase().indexOf("compiled mode") != -1) {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   147
            return "Xcomp";
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   148
        } else if (vmInfo.toLowerCase().indexOf("interpreted mode") != -1) {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   149
            return "Xint";
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   150
        } else {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   151
            return nullWithException("Can't get compilation mode from 'java.vm.info'");
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   152
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   153
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   154
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   155
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   156
     * @return VM bitness, the value of the "sun.arch.data.model" property.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   157
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   158
    protected String vmBits() {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   159
        String dataModel = System.getProperty("sun.arch.data.model");
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   160
        if (dataModel != null) {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   161
            return dataModel;
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   162
        } else {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   163
            return nullWithException("Can't get 'sun.arch.data.model' property");
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   164
        }
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   165
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   166
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   167
    /**
39199
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   168
     * @return "true" if Flight Recorder is enabled, "false" if is disabled.
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   169
     */
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   170
    protected String vmFlightRecorder() {
39941
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
   171
        Boolean isUnlockedCommercialFatures = WB.getBooleanVMFlag("UnlockCommercialFeatures");
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
   172
        Boolean isFlightRecorder = WB.getBooleanVMFlag("FlightRecorder");
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
   173
        String startFROptions = WB.getStringVMFlag("StartFlightRecording");
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
   174
        if (isUnlockedCommercialFatures != null && isUnlockedCommercialFatures) {
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
   175
            if (isFlightRecorder != null && isFlightRecorder) {
39199
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   176
                return "true";
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   177
            }
39941
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
   178
            if (startFROptions != null && !startFROptions.isEmpty()) {
39199
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   179
                return "true";
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   180
            }
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   181
        }
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   182
        return "false";
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   183
    }
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   184
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   185
    /**
42006
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   186
     * @return debug level value extracted from the "jdk.debug" property.
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   187
     */
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   188
    protected String vmDebug() {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   189
        String debug = System.getProperty("jdk.debug");
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   190
        if (debug != null) {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   191
            return "" + debug.contains("debug");
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   192
        } else {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   193
            return nullWithException("Can't get 'jdk.debug' property");
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   194
        }
42006
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   195
    }
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   196
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   197
    /**
42512
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   198
     * @return true if VM supports JVMCI and false otherwise
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   199
     */
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   200
    protected String vmJvmci() {
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   201
        // builds with jvmci have this flag
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   202
        return "" + (WB.getBooleanVMFlag("EnableJVMCI") != null);
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   203
    }
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   204
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   205
    /**
43394
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   206
     * @return true if VM runs in emulated-client mode and false otherwise.
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   207
     */
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   208
    protected String vmEmulatedClient() {
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   209
        String vmInfo = System.getProperty("java.vm.info");
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   210
        if (vmInfo == null) {
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   211
            return "false";
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   212
        }
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   213
        return "" + vmInfo.contains(" emulated-client");
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   214
    }
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   215
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   216
    /**
43389
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   217
     * @return supported CPU features
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   218
     */
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   219
    protected String cpuFeatures() {
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   220
        return CPUInfo.getFeatures().toString();
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   221
    }
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   222
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   223
    /**
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   224
     * For all existing GC sets vm.gc.X property.
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   225
     * Example vm.gc.G1=true means:
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   226
     *    VM supports G1
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   227
     *    User either set G1 explicitely (-XX:+UseG1GC) or did not set any GC
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   228
     * @param map - property-value pairs
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   229
     */
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   230
    protected void vmGC(Map<String, String> map){
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   231
        GC currentGC = GC.current();
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   232
        boolean isByErgo = GC.currentSetByErgo();
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   233
        List<GC> supportedGC = GC.allSupported();
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   234
        for (GC gc: GC.values()) {
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   235
            boolean isSupported = supportedGC.contains(gc);
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   236
            boolean isAcceptable = isSupported && (gc == currentGC || isByErgo);
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   237
            map.put("vm.gc." + gc.name(), "" + isAcceptable);
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   238
        }
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   239
    }
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   240
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   241
    /**
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   242
     * @return true if VM runs RTM supported OS and false otherwise.
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   243
     */
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   244
    protected String vmRTMOS() {
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   245
        boolean isRTMOS = true;
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   246
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   247
        if (Platform.isAix()) {
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   248
            // Actually, this works since AIX 7.1.3.30, but os.version property
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   249
            // is set to 7.1.
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   250
            isRTMOS = (Platform.getOsVersionMajor()  > 7) ||
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   251
                      (Platform.getOsVersionMajor() == 7 && Platform.getOsVersionMinor() > 1);
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   252
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   253
        } else if (Platform.isLinux()) {
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   254
            if (Platform.isPPC()) {
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   255
                isRTMOS = (Platform.getOsVersionMajor()  > 4) ||
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   256
                          (Platform.getOsVersionMajor() == 4 && Platform.getOsVersionMinor() > 1);
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   257
            }
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   258
        }
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   259
        return "" + isRTMOS;
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   260
    }
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   261
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   262
    /**
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   263
     * @return true if VM runs RTM supported CPU and false otherwise.
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   264
     */
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   265
    protected String vmRTMCPU() {
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   266
        boolean vmRTMCPU = (Platform.isPPC() ? CPUInfo.hasFeature("tcheck") : CPUInfo.hasFeature("rtm"));
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   267
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   268
        return "" + vmRTMCPU;
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   269
    }
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   270
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   271
    /**
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   272
     * @return true if VM supports AOT and false otherwise
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   273
     */
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   274
    protected String vmAOT() {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   275
        // builds with aot have jaotc in <JDK>/bin
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   276
        Path bin = Paths.get(System.getProperty("java.home"))
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   277
                        .resolve("bin");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   278
        Path jaotc;
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   279
        if (Platform.isWindows()) {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   280
            jaotc = bin.resolve("jaotc.exe");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   281
        } else {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   282
            jaotc = bin.resolve("jaotc");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   283
        }
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   284
        return "" + Files.exists(jaotc);
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   285
    }
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   286
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   287
    /**
46242
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   288
     * Check for CDS support.
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   289
     *
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   290
     * @return true if CDS is supported by the VM to be tested.
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   291
     */
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   292
    protected String vmCDS() {
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   293
        if (WB.isCDSIncludedInVmBuild()) {
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   294
            return "true";
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   295
        } else {
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   296
            return "false";
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   297
        }
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   298
    }
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   299
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   300
    /**
48155
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   301
     * Check for CDS support for custom loaders.
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   302
     *
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   303
     * @return true if CDS is supported for customer loader by the VM to be tested.
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   304
     */
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   305
    protected String vmCDSForCustomLoaders() {
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   306
        if (vmCDS().equals("true") && Platform.areCustomLoadersSupportedForCDS()) {
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   307
            return "true";
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   308
        } else {
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   309
            return "false";
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   310
        }
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   311
    }
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   312
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   313
    /**
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   314
     * Check if Graal is used as JIT compiler.
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   315
     *
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   316
     * @return true if Graal is used as JIT compiler.
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   317
     */
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   318
    protected String isGraalEnabled() {
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   319
        // Graal is enabled if following conditions are true:
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   320
        // - we are not in Interpreter mode
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   321
        // - UseJVMCICompiler flag is true
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   322
        // - jvmci.Compiler variable is equal to 'graal'
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   323
        // - TieredCompilation is not used or TieredStopAtLevel is greater than 3
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   324
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   325
        Boolean useCompiler = WB.getBooleanVMFlag("UseCompiler");
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   326
        if (useCompiler == null || !useCompiler)
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   327
            return "false";
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   328
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   329
        Boolean useJvmciComp = WB.getBooleanVMFlag("UseJVMCICompiler");
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   330
        if (useJvmciComp == null || !useJvmciComp)
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   331
            return "false";
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   332
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   333
        // This check might be redundant but let's keep it for now.
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   334
        String jvmciCompiler = System.getProperty("jvmci.Compiler");
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   335
        if (jvmciCompiler == null || !jvmciCompiler.equals("graal")) {
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   336
            return "false";
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   337
        }
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   338
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   339
        Boolean tieredCompilation = WB.getBooleanVMFlag("TieredCompilation");
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   340
        Long compLevel = WB.getIntxVMFlag("TieredStopAtLevel");
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   341
        // if TieredCompilation is enabled and compilation level is <= 3 then no Graal is used
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   342
        if (tieredCompilation != null && tieredCompilation && compLevel != null && compLevel <= 3)
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   343
            return "false";
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   344
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   345
        return "true";
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   346
    }
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   347
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   348
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   349
   /**
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   350
     * A simple check for docker support
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   351
     *
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   352
     * @return true if docker is supported in a given environment
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   353
     */
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   354
    protected String dockerSupport() {
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   355
        // currently docker testing is only supported for Linux-x64
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   356
        if (! ( Platform.isLinux() && Platform.isX64() ) )
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   357
            return "false";
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   358
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   359
        boolean isSupported;
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   360
        try {
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   361
            isSupported = checkDockerSupport();
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   362
        } catch (Exception e) {
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   363
            isSupported = false;
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   364
        }
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   365
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   366
        return (isSupported) ? "true" : "false";
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   367
    }
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   368
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   369
    private boolean checkDockerSupport() throws IOException, InterruptedException {
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   370
        ProcessBuilder pb = new ProcessBuilder("docker", "ps");
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   371
        Process p = pb.start();
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   372
        p.waitFor(10, TimeUnit.SECONDS);
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   373
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   374
        return (p.exitValue() == 0);
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   375
    }
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   376
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   377
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   378
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   379
    /**
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   380
     * Dumps the map to the file if the file name is given as the property.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   381
     * This functionality could be helpful to know context in the real
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   382
     * execution.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   383
     *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   384
     * @param map
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   385
     */
42511
8009d4cba2ea 8170228: register closed @requires property setter
iignatyev
parents: 42006
diff changeset
   386
    protected static void dump(Map<String, String> map) {
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   387
        String dumpFileName = System.getProperty("vmprops.dump");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   388
        if (dumpFileName == null) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   389
            return;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   390
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   391
        List<String> lines = new ArrayList<>();
39199
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   392
        map.forEach((k, v) -> lines.add(k + ":" + v));
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   393
        try {
42511
8009d4cba2ea 8170228: register closed @requires property setter
iignatyev
parents: 42006
diff changeset
   394
            Files.write(Paths.get(dumpFileName), lines, StandardOpenOption.APPEND);
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   395
        } catch (IOException e) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   396
            throw new RuntimeException("Failed to dump properties into '"
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   397
                    + dumpFileName + "'", e);
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   398
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   399
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   401
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   402
     * This method is for the testing purpose only.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   403
     * @param args
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   404
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   405
    public static void main(String args[]) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   406
        Map<String, String> map = new VMProps().call();
39199
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   407
        map.forEach((k, v) -> System.out.println(k + ": '" + v + "'"));
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   408
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   409
}