test/jtreg-ext/requires/VMProps.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 58511 eb68d459ba6a
child 58679 9c3209ff7550
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
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
/*
53494
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
     2
 * Copyright (c) 2016, 2019, 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
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
    25
import java.io.BufferedInputStream;
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
    26
import java.io.FileInputStream;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    27
import java.io.IOException;
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
    28
import java.io.InputStream;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    29
import java.nio.file.Files;
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
    30
import java.nio.file.Path;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    31
import java.nio.file.Paths;
42511
8009d4cba2ea 8170228: register closed @requires property setter
iignatyev
parents: 42006
diff changeset
    32
import java.nio.file.StandardOpenOption;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    33
import java.util.ArrayList;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    34
import java.util.HashMap;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    35
import java.util.List;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    36
import java.util.Map;
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
    37
import java.util.Properties;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    38
import java.util.concurrent.Callable;
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
    39
import java.util.concurrent.TimeUnit;
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    40
import java.util.function.Supplier;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    41
import java.util.regex.Matcher;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    42
import java.util.regex.Pattern;
43389
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
    43
50455
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 50339
diff changeset
    44
import sun.hotspot.code.Compiler;
43389
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
    45
import sun.hotspot.cpuinfo.CPUInfo;
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
    46
import sun.hotspot.gc.GC;
39941
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
    47
import sun.hotspot.WhiteBox;
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
    48
import jdk.test.lib.Platform;
55757
07e998f8f816 8228434: jdk/net/Sockets/Test.java fails after JDK-8227642
sgehwolf
parents: 55746
diff changeset
    49
import jdk.test.lib.Container;
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    50
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    51
/**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    52
 * 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
    53
 * collect information about VM.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    54
 * Do not use any APIs 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
    55
 * 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
    56
 */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    57
public class VMProps implements Callable<Map<String, String>> {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    58
    // value known to jtreg as an indicator of error state
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    59
    private static final String ERROR_STATE = "__ERROR__";
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    60
39941
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
    61
    private static final WhiteBox WB = WhiteBox.getWhiteBox();
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
    62
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    63
    private static class SafeMap {
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    64
        private final Map<String, String> map = new HashMap<>();
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    65
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    66
        public void put(String key, Supplier<String> s) {
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    67
            String value;
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    68
            try {
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    69
                value = s.get();
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    70
            } catch (Throwable t) {
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    71
                System.err.println("failed to get value for " + key);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    72
                t.printStackTrace(System.err);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    73
                value = ERROR_STATE + t;
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    74
            }
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    75
            map.put(key, value);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    76
        }
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    77
    }
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    78
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    79
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    80
     * Collects information about VM properties.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    81
     * This method will be invoked by jtreg.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    82
     *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    83
     * @return Map of property-value pairs.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    84
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    85
    @Override
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
    86
    public Map<String, String> call() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    87
        SafeMap map = new SafeMap();
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    88
        map.put("vm.flavor", this::vmFlavor);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    89
        map.put("vm.compMode", this::vmCompMode);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    90
        map.put("vm.bits", this::vmBits);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    91
        map.put("vm.flightRecorder", this::vmFlightRecorder);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    92
        map.put("vm.simpleArch", this::vmArch);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    93
        map.put("vm.debug", this::vmDebug);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    94
        map.put("vm.jvmci", this::vmJvmci);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    95
        map.put("vm.emulatedClient", this::vmEmulatedClient);
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
    96
        // vm.hasSA is "true" if the VM contains the serviceability agent
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
    97
        // and jhsdb.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
    98
        map.put("vm.hasSA", this::vmHasSA);
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
    99
        // vm.hasSAandCanAttach is "true" if the VM contains the serviceability agent
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   100
        // and jhsdb and it can attach to the VM.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   101
        map.put("vm.hasSAandCanAttach", this::vmHasSAandCanAttach);
51214
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   102
        // vm.hasJFR is "true" if JFR is included in the build of the VM and
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   103
        // so tests can be executed.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   104
        map.put("vm.hasJFR", this::vmHasJFR);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   105
        map.put("vm.cpu.features", this::cpuFeatures);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   106
        map.put("vm.rtm.cpu", this::vmRTMCPU);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   107
        map.put("vm.rtm.compiler", this::vmRTMCompiler);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   108
        map.put("vm.aot", this::vmAOT);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   109
        map.put("vm.aot.enabled", this::vmAotEnabled);
46242
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   110
        // vm.cds is true if the VM is compiled with cds support.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   111
        map.put("vm.cds", this::vmCDS);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   112
        map.put("vm.cds.custom.loaders", this::vmCDSForCustomLoaders);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   113
        map.put("vm.cds.archived.java.heap", this::vmCDSForArchivedJavaHeap);
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   114
        // vm.graal.enabled is true if Graal is used as JIT
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   115
        map.put("vm.graal.enabled", this::isGraalEnabled);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   116
        map.put("vm.compiler1.enabled", this::isCompiler1Enabled);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   117
        map.put("vm.compiler2.enabled", this::isCompiler2Enabled);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   118
        map.put("docker.support", this::dockerSupport);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   119
        map.put("release.implementor", this::implementor);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   120
        map.put("test.vm.gc.nvdimm", this::isNvdimmTestEnabled);
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   121
        vmGC(map); // vm.gc.X = true/false
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   122
        vmOptFinalFlags(map);
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   123
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   124
        dump(map.map);
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   125
        return map.map;
37400
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
39198
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   128
    /**
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   129
     * Print a stack trace before returning error state;
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   130
     * 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
   131
     * VM properties in the case where they don't find an expected property
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   132
     * or a property doesn't conform to an expected format.
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   133
     *
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   134
     * @return {@link #ERROR_STATE}
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   135
     */
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   136
    private String errorWithMessage(String message) {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   137
        new Exception(message).printStackTrace();
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   138
        return ERROR_STATE + message;
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   139
    }
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   140
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   141
    /**
39198
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   142
     * @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
   143
     */
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   144
    protected String vmArch() {
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   145
        String arch = System.getProperty("os.arch");
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   146
        if (arch.equals("x86_64") || arch.equals("amd64")) {
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   147
            return "x64";
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   148
        } else if (arch.contains("86")) {
39198
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   149
            return "x86";
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   150
        } else {
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   151
            return arch;
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   152
        }
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   153
    }
050eff9d3bcf 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 37400
diff changeset
   154
37400
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 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
   157
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   158
    protected String vmFlavor() {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   159
        // 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
   160
        String vmName = System.getProperty("java.vm.name");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   161
        if (vmName == null) {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   162
            return errorWithMessage("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
   163
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   164
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   165
        Pattern startP = Pattern.compile(".* (\\S+) VM");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   166
        Matcher m = startP.matcher(vmName);
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   167
        if (m.matches()) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   168
            return m.group(1).toLowerCase();
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   169
        }
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   170
        return errorWithMessage("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
   171
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   172
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   173
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   174
     * @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
   175
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   176
    protected String vmCompMode() {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   177
        // E.g. "mixed mode"
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   178
        String vmInfo = System.getProperty("java.vm.info");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   179
        if (vmInfo == null) {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   180
            return errorWithMessage("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
   181
        }
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   182
        vmInfo = vmInfo.toLowerCase();
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   183
        if (vmInfo.contains("mixed mode")) {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   184
            return "Xmixed";
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   185
        } else if (vmInfo.contains("compiled mode")) {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   186
            return "Xcomp";
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   187
        } else if (vmInfo.contains("interpreted mode")) {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   188
            return "Xint";
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   189
        } else {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   190
            return errorWithMessage("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
   191
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   192
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   193
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   194
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   195
     * @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
   196
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   197
    protected String vmBits() {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   198
        String dataModel = System.getProperty("sun.arch.data.model");
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   199
        if (dataModel != null) {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   200
            return dataModel;
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   201
        } else {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   202
            return errorWithMessage("Can't get 'sun.arch.data.model' property");
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   203
        }
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   204
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   205
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   206
    /**
39199
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   207
     * @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
   208
     */
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   209
    protected String vmFlightRecorder() {
39941
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
   210
        Boolean isFlightRecorder = WB.getBooleanVMFlag("FlightRecorder");
fdbe314f004f 8161208: Unable to run jtreg tests with MinimalVM
mchernov
parents: 39377
diff changeset
   211
        String startFROptions = WB.getStringVMFlag("StartFlightRecording");
50708
bd3a8f48597e 8202331: Obsolete support for commercial features
mikael
parents: 50590
diff changeset
   212
        if (isFlightRecorder != null && isFlightRecorder) {
bd3a8f48597e 8202331: Obsolete support for commercial features
mikael
parents: 50590
diff changeset
   213
            return "true";
bd3a8f48597e 8202331: Obsolete support for commercial features
mikael
parents: 50590
diff changeset
   214
        }
bd3a8f48597e 8202331: Obsolete support for commercial features
mikael
parents: 50590
diff changeset
   215
        if (startFROptions != null && !startFROptions.isEmpty()) {
bd3a8f48597e 8202331: Obsolete support for commercial features
mikael
parents: 50590
diff changeset
   216
            return "true";
39199
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   217
        }
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   218
        return "false";
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   219
    }
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   220
ec6fd961811c 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled
mchernov
parents: 39198
diff changeset
   221
    /**
42006
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   222
     * @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
   223
     */
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   224
    protected String vmDebug() {
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   225
        String debug = System.getProperty("jdk.debug");
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   226
        if (debug != null) {
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   227
            return "" + debug.contains("debug");
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   228
        } else {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   229
            return errorWithMessage("Can't get 'jdk.debug' property");
45823
f3cf2ee05985 8183534: [TEST] Make detection of compilation mode more robust
simonis
parents: 43394
diff changeset
   230
        }
42006
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   231
    }
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   232
98146f279bba 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents: 39941
diff changeset
   233
    /**
42512
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   234
     * @return true if VM supports JVMCI and false otherwise
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   235
     */
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   236
    protected String vmJvmci() {
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   237
        // builds with jvmci have this flag
58428
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   238
        if (WB.getBooleanVMFlag("EnableJVMCI") == null) {
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   239
            return "false";
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   240
        }
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   241
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   242
        switch (GC.selected()) {
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   243
            case Serial:
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   244
            case Parallel:
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   245
            case G1:
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   246
                // These GCs are supported with JVMCI
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   247
                return "true";
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   248
            default:
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   249
                break;
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   250
        }
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   251
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   252
        // Every other GC is not supported
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   253
        return "false";
42512
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   254
    }
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   255
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   256
    /**
43394
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   257
     * @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
   258
     */
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   259
    protected String vmEmulatedClient() {
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   260
        String vmInfo = System.getProperty("java.vm.info");
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   261
        if (vmInfo == null) {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   262
            return errorWithMessage("Can't get 'java.vm.info' property");
43394
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   263
        }
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   264
        return "" + vmInfo.contains(" emulated-client");
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   265
    }
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   266
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   267
    /**
43389
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   268
     * @return supported CPU features
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   269
     */
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   270
    protected String cpuFeatures() {
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   271
        return CPUInfo.getFeatures().toString();
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   272
    }
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   273
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   274
    /**
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   275
     * For all existing GC sets vm.gc.X property.
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   276
     * Example vm.gc.G1=true means:
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   277
     *    VM supports G1
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   278
     *    User either set G1 explicitely (-XX:+UseG1GC) or did not set any GC
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   279
     *
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   280
     * @param map - property-value pairs
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   281
     */
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   282
    protected void vmGC(SafeMap map) {
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   283
        for (GC gc: GC.values()) {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   284
            map.put("vm.gc." + gc.name(),
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   285
                    () -> "" + (gc.isSupported()
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   286
                            && (gc.isSelected() || GC.isSelectedErgonomically())));
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   287
        }
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   288
    }
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   289
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   290
    /**
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   291
     * Selected final flag.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   292
     *
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   293
     * @param map - property-value pairs
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   294
     * @param flagName - flag name
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   295
     */
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   296
    private void vmOptFinalFlag(SafeMap map, String flagName) {
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   297
        map.put("vm.opt.final." + flagName,
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   298
                () -> String.valueOf(WB.getBooleanVMFlag(flagName)));
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   299
    }
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   300
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   301
    /**
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   302
     * Selected sets of final flags.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   303
     *
50908
7c51db95ccb6 8205207: Port Graal unit tests under jtreg
epavlova
parents: 50791
diff changeset
   304
     * @param map - property-value pairs
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   305
     */
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   306
    protected void vmOptFinalFlags(SafeMap map) {
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   307
        vmOptFinalFlag(map, "ClassUnloading");
58511
eb68d459ba6a 8231489: GC watermark_0_1 failed due to "metaspace.gc.Fault: GC has happened too rare"
pliden
parents: 58428
diff changeset
   308
        vmOptFinalFlag(map, "ClassUnloadingWithConcurrentMark");
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   309
        vmOptFinalFlag(map, "UseCompressedOops");
50908
7c51db95ccb6 8205207: Port Graal unit tests under jtreg
epavlova
parents: 50791
diff changeset
   310
        vmOptFinalFlag(map, "EnableJVMCI");
53497
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 53494
diff changeset
   311
        vmOptFinalFlag(map, "EliminateAllocations");
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   312
    }
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   313
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   314
    /**
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   315
     * @return "true" if VM has a serviceability agent.
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   316
     */
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   317
    protected String vmHasSA() {
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   318
        return "" + Platform.hasSA();
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   319
    }
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   320
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   321
    /**
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   322
     * @return "true" if VM has a serviceability agent and it can
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   323
     * attach to the VM.
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   324
     */
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   325
    protected String vmHasSAandCanAttach() {
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   326
        try {
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   327
            return "" + Platform.shouldSAAttach();
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   328
        } catch (IOException e) {
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   329
            e.printStackTrace();
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   330
            return errorWithMessage("Checking whether SA can attach to the VM failed.:" + e);
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   331
        }
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   332
    }
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   333
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   334
    /**
51214
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   335
     * @return "true" if the VM is compiled with Java Flight Recorder (JFR)
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   336
     * support.
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   337
     */
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   338
    protected String vmHasJFR() {
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   339
        return "" + WB.isJFRIncludedInVmBuild();
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   340
    }
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   341
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   342
    /**
51753
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   343
     * @return true if compiler in use supports RTM and false otherwise.
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   344
     */
51753
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   345
    protected String vmRTMCompiler() {
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   346
        boolean isRTMCompiler = false;
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   347
51753
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   348
        if (Compiler.isC2Enabled() &&
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   349
            (Platform.isX86() || Platform.isX64() || Platform.isPPC())) {
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   350
            isRTMCompiler = true;
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   351
        }
51753
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   352
        return "" + isRTMCompiler;
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   353
    }
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   354
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   355
    /**
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   356
     * @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
   357
     */
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   358
    protected String vmRTMCPU() {
50339
ede65c4fb6da 8203669: PPC64: Fix jtreg RTM tests after "8203305: Improve TM detection for enabling RTM on Linux / POWER9"
gromero
parents: 50320
diff changeset
   359
        return "" + CPUInfo.hasFeature("rtm");
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   360
    }
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   361
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   362
    /**
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   363
     * @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
   364
     */
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   365
    protected String vmAOT() {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   366
        // builds with aot have jaotc in <JDK>/bin
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   367
        Path bin = Paths.get(System.getProperty("java.home"))
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   368
                        .resolve("bin");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   369
        Path jaotc;
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   370
        if (Platform.isWindows()) {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   371
            jaotc = bin.resolve("jaotc.exe");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   372
        } else {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   373
            jaotc = bin.resolve("jaotc");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   374
        }
58428
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   375
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   376
        if (!Files.exists(jaotc)) {
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   377
            // No jaotc => no AOT
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   378
            return "false";
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   379
        }
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   380
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   381
        switch (GC.selected()) {
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   382
            case Serial:
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   383
            case Parallel:
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   384
            case G1:
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   385
                // These GCs are supported with AOT
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   386
                return "true";
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   387
            default:
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   388
                break;
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   389
        }
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   390
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   391
        // Every other GC is not supported
9b644c06226f 8231503: [TESTBUG] compiler/{jvmci,aot} tests should not run with GCs that do not support JVMCI/AOT
shade
parents: 55757
diff changeset
   392
        return "false";
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   393
    }
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   394
53494
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   395
    /*
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   396
     * @return true if there is at least one loaded AOT'ed library.
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   397
     */
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   398
    protected String vmAotEnabled() {
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   399
        return "" + (WB.aotLibrariesCount() > 0);
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   400
    }
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   401
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   402
    /**
46242
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   403
     * Check for CDS support.
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   404
     *
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   405
     * @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
   406
     */
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   407
    protected String vmCDS() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   408
        return "" + WB.isCDSIncludedInVmBuild();
46242
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   409
    }
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   410
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   411
    /**
48155
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   412
     * 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
   413
     *
49008
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   414
     * @return true if CDS provides support for customer loader in the VM to be tested.
48155
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   415
     */
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   416
    protected String vmCDSForCustomLoaders() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   417
        return "" + ("true".equals(vmCDS()) && Platform.areCustomLoadersSupportedForCDS());
48155
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   418
    }
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   419
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   420
    /**
49008
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   421
     * Check for CDS support for archived Java heap regions.
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   422
     *
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   423
     * @return true if CDS provides support for archive Java heap regions in the VM to be tested.
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   424
     */
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   425
    protected String vmCDSForArchivedJavaHeap() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   426
        return "" + ("true".equals(vmCDS()) && WB.isJavaHeapArchiveSupported());
49008
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   427
    }
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   428
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   429
    /**
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   430
     * 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
   431
     *
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   432
     * @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
   433
     */
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   434
    protected String isGraalEnabled() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   435
        return "" + Compiler.isGraalEnabled();
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   436
    }
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   437
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   438
    /**
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   439
     * Check if Compiler1 is present.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   440
     *
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   441
     * @return true if Compiler1 is used as JIT compiler, either alone or as part of the tiered system.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   442
     */
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   443
    protected String isCompiler1Enabled() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   444
        return "" + Compiler.isC1Enabled();
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   445
    }
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   446
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   447
    /**
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   448
     * Check if Compiler2 is present.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   449
     *
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   450
     * @return true if Compiler2 is used as JIT compiler, either alone or as part of the tiered system.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   451
     */
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   452
    protected String isCompiler2Enabled() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   453
        return "" + Compiler.isC2Enabled();
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   454
    }
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   455
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   456
   /**
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   457
     * A simple check for docker support
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   458
     *
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   459
     * @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
   460
     */
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   461
    protected String dockerSupport() {
54538
ef331769d4ab 8222501: [TESTBUG] Docker support is always set to true in jtreg-ext/requires/VMProps.java
mseledtsov
parents: 54537
diff changeset
   462
        boolean isSupported = false;
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   463
        if (Platform.isLinux()) {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   464
           // currently docker testing is only supported for Linux,
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   465
           // on certain platforms
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   466
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   467
           String arch = System.getProperty("os.arch");
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   468
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   469
           if (Platform.isX64()) {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   470
              isSupported = true;
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   471
           } else if (Platform.isAArch64()) {
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   472
              isSupported = true;
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   473
           } else if (Platform.isS390x()) {
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   474
              isSupported = true;
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   475
           } else if (arch.equals("ppc64le")) {
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   476
              isSupported = true;
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   477
           }
48880
ee49ac008730 8196062: Enable docker container related tests for linux ppc64le
mbaesken
parents: 48155
diff changeset
   478
        }
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   479
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   480
        if (isSupported) {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   481
           try {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   482
              isSupported = checkDockerSupport();
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   483
           } catch (Exception e) {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   484
              isSupported = false;
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   485
           }
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   486
         }
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   487
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   488
        return "" + isSupported;
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   489
    }
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   490
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   491
    private boolean checkDockerSupport() throws IOException, InterruptedException {
55757
07e998f8f816 8228434: jdk/net/Sockets/Test.java fails after JDK-8227642
sgehwolf
parents: 55746
diff changeset
   492
        ProcessBuilder pb = new ProcessBuilder(Container.ENGINE_COMMAND, "ps");
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   493
        Process p = pb.start();
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   494
        p.waitFor(10, TimeUnit.SECONDS);
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   495
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   496
        return (p.exitValue() == 0);
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   497
    }
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   498
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   499
    private String implementor() {
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   500
        try (InputStream in = new BufferedInputStream(new FileInputStream(
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   501
                System.getProperty("java.home") + "/release"))) {
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   502
            Properties properties = new Properties();
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   503
            properties.load(in);
51191
96fae3a62612 8208157: requires.VMProps throws NPE for missing properties in "release" file
shurailine
parents: 50914
diff changeset
   504
            String implementorProperty = properties.getProperty("IMPLEMENTOR");
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   505
            if (implementorProperty != null) {
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   506
                return implementorProperty.replace("\"", "");
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   507
            }
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   508
            return errorWithMessage("Can't get 'IMPLEMENTOR' property from 'release' file");
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   509
        } catch (IOException e) {
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   510
            e.printStackTrace();
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   511
            return errorWithMessage("Failed to read 'release' file " + e);
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   512
        }
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   513
    }
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   514
53575
297183cee278 8217666: gc/nvdimm/* should not be included any tiers
sangheki
parents: 53497
diff changeset
   515
    private String isNvdimmTestEnabled() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   516
        String isEnabled = System.getenv("TEST_VM_GC_NVDIMM");
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   517
        return "" + "true".equalsIgnoreCase(isEnabled);
53575
297183cee278 8217666: gc/nvdimm/* should not be included any tiers
sangheki
parents: 53497
diff changeset
   518
    }
297183cee278 8217666: gc/nvdimm/* should not be included any tiers
sangheki
parents: 53497
diff changeset
   519
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   520
    /**
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   521
     * 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
   522
     * 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
   523
     * execution.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   524
     *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   525
     * @param map
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   526
     */
42511
8009d4cba2ea 8170228: register closed @requires property setter
iignatyev
parents: 42006
diff changeset
   527
    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
   528
        String dumpFileName = System.getProperty("vmprops.dump");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   529
        if (dumpFileName == null) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   530
            return;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   531
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   532
        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
   533
        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
   534
        try {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   535
            Files.write(Paths.get(dumpFileName), lines,
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   536
                    StandardOpenOption.APPEND, StandardOpenOption.CREATE);
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   537
        } catch (IOException e) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   538
            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
   539
                    + dumpFileName + "'", e);
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   540
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   541
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   542
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   543
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   544
     * This method is for the testing purpose only.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   545
     *
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   546
     * @param args
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   547
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   548
    public static void main(String args[]) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   549
        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
   550
        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
   551
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   552
}