test/jtreg-ext/requires/VMProps.java
author dfuchs
Fri, 06 Sep 2019 14:04:44 +0100
changeset 58031 5aaf53d4fe63
parent 55757 07e998f8f816
child 58428 9b644c06226f
permissions -rw-r--r--
8230694: http.keepAlive system property is inconsistently/incorrectly documented Summary: trivially fixed the net-properties.html file Reviewed-by: alanb
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
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   238
        return "" + (WB.getBooleanVMFlag("EnableJVMCI") != null);
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   239
    }
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   240
9e1dfd06e954 8170226: Implement setting jtreg @requires property vm.jvmci
iignatyev
parents: 42511
diff changeset
   241
    /**
43394
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   242
     * @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
   243
     */
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   244
    protected String vmEmulatedClient() {
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   245
        String vmInfo = System.getProperty("java.vm.info");
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   246
        if (vmInfo == null) {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   247
            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
   248
        }
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   249
        return "" + vmInfo.contains(" emulated-client");
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   250
    }
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   251
68ed4de0f9c8 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 43389
diff changeset
   252
    /**
43389
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   253
     * @return supported CPU features
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   254
     */
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   255
    protected String cpuFeatures() {
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   256
        return CPUInfo.getFeatures().toString();
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   257
    }
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   258
53ff01a9206a 8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java
bmoloden
parents: 42512
diff changeset
   259
    /**
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   260
     * For all existing GC sets vm.gc.X property.
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   261
     * Example vm.gc.G1=true means:
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   262
     *    VM supports G1
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   263
     *    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
   264
     *
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   265
     * @param map - property-value pairs
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   266
     */
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   267
    protected void vmGC(SafeMap map) {
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   268
        for (GC gc: GC.values()) {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   269
            map.put("vm.gc." + gc.name(),
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   270
                    () -> "" + (gc.isSupported()
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   271
                            && (gc.isSelected() || GC.isSelectedErgonomically())));
39377
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   272
        }
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   273
    }
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   274
07739ee0b28a 8151283: Implement setting jtreg @requires property vm.isG1Supported.
dfazunen
parents: 39199
diff changeset
   275
    /**
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   276
     * Selected final flag.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   277
     *
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   278
     * @param map - property-value pairs
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   279
     * @param flagName - flag name
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   280
     */
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   281
    private void vmOptFinalFlag(SafeMap map, String flagName) {
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   282
        map.put("vm.opt.final." + flagName,
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   283
                () -> String.valueOf(WB.getBooleanVMFlag(flagName)));
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   284
    }
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   285
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   286
    /**
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   287
     * Selected sets of final flags.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   288
     *
50908
7c51db95ccb6 8205207: Port Graal unit tests under jtreg
epavlova
parents: 50791
diff changeset
   289
     * @param map - property-value pairs
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   290
     */
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   291
    protected void vmOptFinalFlags(SafeMap map) {
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   292
        vmOptFinalFlag(map, "ClassUnloading");
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   293
        vmOptFinalFlag(map, "UseCompressedOops");
50908
7c51db95ccb6 8205207: Port Graal unit tests under jtreg
epavlova
parents: 50791
diff changeset
   294
        vmOptFinalFlag(map, "EnableJVMCI");
53497
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 53494
diff changeset
   295
        vmOptFinalFlag(map, "EliminateAllocations");
50320
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   296
    }
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   297
df02866807b6 8203923: Add @requires feature to check flag values for the running JVM
stefank
parents: 49630
diff changeset
   298
    /**
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   299
     * @return "true" if VM has a serviceability agent.
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   300
     */
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   301
    protected String vmHasSA() {
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   302
        return "" + Platform.hasSA();
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   303
    }
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   304
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   305
    /**
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   306
     * @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
   307
     * attach to the VM.
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   308
     */
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   309
    protected String vmHasSAandCanAttach() {
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   310
        try {
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   311
            return "" + Platform.shouldSAAttach();
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   312
        } catch (IOException e) {
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   313
            e.printStackTrace();
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   314
            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
   315
        }
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
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 50708
diff changeset
   318
    /**
51214
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   319
     * @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
   320
     * support.
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   321
     */
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   322
    protected String vmHasJFR() {
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   323
        return "" + WB.isJFRIncludedInVmBuild();
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   324
    }
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   325
67736b4846a0 8207830: [aix] disable jfr in build and tests
goetz
parents: 50914
diff changeset
   326
    /**
51753
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   327
     * @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
   328
     */
51753
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   329
    protected String vmRTMCompiler() {
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   330
        boolean isRTMCompiler = false;
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   331
51753
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   332
        if (Compiler.isC2Enabled() &&
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   333
            (Platform.isX86() || Platform.isX64() || Platform.isPPC())) {
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   334
            isRTMCompiler = true;
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   335
        }
51753
763aa4d1d596 8209972: [GRAAL] Don't run RTM tests with Graal
gromero
parents: 51341
diff changeset
   336
        return "" + isRTMCompiler;
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   337
    }
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   338
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   339
    /**
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   340
     * @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
   341
     */
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   342
    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
   343
        return "" + CPUInfo.hasFeature("rtm");
46225
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   344
    }
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   345
f99654379e9c 8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents: 43394
diff changeset
   346
    /**
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   347
     * @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
   348
     */
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   349
    protected String vmAOT() {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   350
        // builds with aot have jaotc in <JDK>/bin
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   351
        Path bin = Paths.get(System.getProperty("java.home"))
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   352
                        .resolve("bin");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   353
        Path jaotc;
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   354
        if (Platform.isWindows()) {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   355
            jaotc = bin.resolve("jaotc.exe");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   356
        } else {
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   357
            jaotc = bin.resolve("jaotc");
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   358
        }
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   359
        return "" + Files.exists(jaotc);
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   360
    }
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   361
53494
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   362
    /*
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   363
     * @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
   364
     */
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   365
    protected String vmAotEnabled() {
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   366
        return "" + (WB.aotLibrariesCount() > 0);
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   367
    }
8fd43dacaef7 8216180: [AOT] compiler/intrinsics/bigInteger/TestMulAdd.java crashed with AOT enabled
iignatyev
parents: 51753
diff changeset
   368
46238
661b22bb24d2 8185536: @key aot should be replaced w/ @requires vm.aot
iignatyev
parents: 46225
diff changeset
   369
    /**
46242
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   370
     * Check for CDS support.
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   371
     *
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   372
     * @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
   373
     */
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   374
    protected String vmCDS() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   375
        return "" + WB.isCDSIncludedInVmBuild();
46242
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   376
    }
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   377
9465c23e4e0d 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46239
diff changeset
   378
    /**
48155
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   379
     * 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
   380
     *
49008
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   381
     * @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
   382
     */
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   383
    protected String vmCDSForCustomLoaders() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   384
        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
   385
    }
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   386
551de50b4ff7 8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents: 47814
diff changeset
   387
    /**
49008
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   388
     * 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
   389
     *
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   390
     * @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
   391
     */
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   392
    protected String vmCDSForArchivedJavaHeap() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   393
        return "" + ("true".equals(vmCDS()) && WB.isJavaHeapArchiveSupported());
49008
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   394
    }
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   395
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48957
diff changeset
   396
    /**
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   397
     * 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
   398
     *
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   399
     * @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
   400
     */
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   401
    protected String isGraalEnabled() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   402
        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
   403
    }
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   404
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   405
    /**
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   406
     * Check if Compiler1 is present.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   407
     *
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   408
     * @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
   409
     */
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   410
    protected String isCompiler1Enabled() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   411
        return "" + Compiler.isC1Enabled();
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   412
    }
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   413
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   414
    /**
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   415
     * Check if Compiler2 is present.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   416
     *
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   417
     * @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
   418
     */
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   419
    protected String isCompiler2Enabled() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   420
        return "" + Compiler.isC2Enabled();
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 51251
diff changeset
   421
    }
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   422
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   423
   /**
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   424
     * A simple check for docker support
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   425
     *
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   426
     * @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
   427
     */
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   428
    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
   429
        boolean isSupported = false;
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   430
        if (Platform.isLinux()) {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   431
           // currently docker testing is only supported for Linux,
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   432
           // on certain platforms
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   433
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   434
           String arch = System.getProperty("os.arch");
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   435
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   436
           if (Platform.isX64()) {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   437
              isSupported = true;
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   438
           } else if (Platform.isAArch64()) {
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   439
              isSupported = true;
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   440
           } else if (Platform.isS390x()) {
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   441
              isSupported = true;
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   442
           } else if (arch.equals("ppc64le")) {
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   443
              isSupported = true;
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   444
           }
48880
ee49ac008730 8196062: Enable docker container related tests for linux ppc64le
mbaesken
parents: 48155
diff changeset
   445
        }
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   446
49344
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   447
        if (isSupported) {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   448
           try {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   449
              isSupported = checkDockerSupport();
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   450
           } catch (Exception e) {
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   451
              isSupported = false;
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   452
           }
e55d7a31cfa7 8196590: Enable docker container related tests for linux AARCH64
dsamersoff
parents: 49008
diff changeset
   453
         }
47615
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   454
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   455
        return "" + isSupported;
47615
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
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   458
    private boolean checkDockerSupport() throws IOException, InterruptedException {
55757
07e998f8f816 8228434: jdk/net/Sockets/Test.java fails after JDK-8227642
sgehwolf
parents: 55746
diff changeset
   459
        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
   460
        Process p = pb.start();
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   461
        p.waitFor(10, TimeUnit.SECONDS);
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   462
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   463
        return (p.exitValue() == 0);
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   464
    }
6210a27c3704 8181592: [TESTBUG] Docker test utils and docker jdk basic test
mseledtsov
parents: 47576
diff changeset
   465
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   466
    private String implementor() {
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   467
        try (InputStream in = new BufferedInputStream(new FileInputStream(
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   468
                System.getProperty("java.home") + "/release"))) {
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   469
            Properties properties = new Properties();
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   470
            properties.load(in);
51191
96fae3a62612 8208157: requires.VMProps throws NPE for missing properties in "release" file
shurailine
parents: 50914
diff changeset
   471
            String implementorProperty = properties.getProperty("IMPLEMENTOR");
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   472
            if (implementorProperty != null) {
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   473
                return implementorProperty.replace("\"", "");
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   474
            }
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   475
            return errorWithMessage("Can't get 'IMPLEMENTOR' property from 'release' file");
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   476
        } catch (IOException e) {
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   477
            e.printStackTrace();
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   478
            return errorWithMessage("Failed to read 'release' file " + e);
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   479
        }
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   480
    }
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 50455
diff changeset
   481
53575
297183cee278 8217666: gc/nvdimm/* should not be included any tiers
sangheki
parents: 53497
diff changeset
   482
    private String isNvdimmTestEnabled() {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   483
        String isEnabled = System.getenv("TEST_VM_GC_NVDIMM");
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   484
        return "" + "true".equalsIgnoreCase(isEnabled);
53575
297183cee278 8217666: gc/nvdimm/* should not be included any tiers
sangheki
parents: 53497
diff changeset
   485
    }
297183cee278 8217666: gc/nvdimm/* should not be included any tiers
sangheki
parents: 53497
diff changeset
   486
47576
7645833d326f 8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal
epavlova
parents: 46242
diff changeset
   487
    /**
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   488
     * 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
   489
     * 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
   490
     * execution.
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   491
     *
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   492
     * @param map
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   493
     */
42511
8009d4cba2ea 8170228: register closed @requires property setter
iignatyev
parents: 42006
diff changeset
   494
    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
   495
        String dumpFileName = System.getProperty("vmprops.dump");
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   496
        if (dumpFileName == null) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   497
            return;
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   498
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   499
        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
   500
        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
   501
        try {
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   502
            Files.write(Paths.get(dumpFileName), lines,
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   503
                    StandardOpenOption.APPEND, StandardOpenOption.CREATE);
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   504
        } catch (IOException e) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   505
            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
   506
                    + dumpFileName + "'", e);
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   507
        }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   508
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   509
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   510
    /**
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   511
     * This method is for the testing purpose only.
53906
a6fb5e60588f 8209807: improve handling exception in requires.VMProps
iignatyev
parents: 53575
diff changeset
   512
     *
37400
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   513
     * @param args
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   514
     */
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   515
    public static void main(String args[]) {
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   516
        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
   517
        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
   518
    }
7a596e23c0da 8152432: Implement setting jtreg @requires properties vm.flavor, vm.bits, vm.compMode
dfazunen
parents:
diff changeset
   519
}