hotspot/test/native/GTestWrapper.java
author stsmirno
Mon, 17 Oct 2016 18:54:12 -0400
changeset 41705 332239c052cc
parent 40631 ed82623d7831
permissions -rw-r--r--
8165687: Fix license and copyright headers in jd9 under hotspot/test Summary: Legal notices and Oracle copyrights were updated (white and blank space, commas) in tests files for uniformity to meet Oracle requirements. Reviewed-by: dholmes, iris Contributed-by: Stanislav Smirnov <stanislav.smirnov@oracle.com>, Vassili Igouchkine <vassili.igouchkine@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38307
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     1
/*
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     4
 *
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     8
 *
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    14
 *
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    18
 *
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    21
 * questions.
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    22
 */
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    23
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    24
/* @test
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    25
 * @summary a jtreg wrapper for gtest tests
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38731
diff changeset
    26
 * @library /test/lib
38307
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    27
 * @modules java.base/jdk.internal.misc
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    28
 * @run main/native GTestWrapper
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    29
 */
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    30
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    31
import java.util.Arrays;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    32
import java.util.List;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    33
import java.util.stream.Stream;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    34
import java.util.stream.Collectors;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    35
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    36
import java.nio.file.Paths;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    37
import java.nio.file.Path;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    38
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    39
import jdk.test.lib.Platform;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    40
import jdk.test.lib.Utils;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    41
import jdk.test.lib.process.ProcessTools;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    42
import jdk.test.lib.process.OutputAnalyzer;
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    43
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    44
public class GTestWrapper {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    45
    public static void main(String[] args) throws Throwable {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    46
        // gtestLauncher is located in <test_image>/hotspot/gtest/<vm_variant>/
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    47
        // nativePath points either to <test_image>/hotspot/jtreg/native or to <test_image>/hotspot/gtest
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    48
        Path nativePath = Paths.get(System.getProperty("test.nativepath"));
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    49
        String jvmVariantDir = getJVMVariantSubDir();
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    50
        // let's assume it's <test_image>/hotspot/gtest
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    51
        Path path = nativePath.resolve(jvmVariantDir);
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    52
        if (!path.toFile().exists()) {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    53
            // maybe it is <test_image>/hotspot/jtreg/native
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    54
            path = nativePath.getParent()
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    55
                             .getParent()
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    56
                             .resolve("gtest")
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    57
                             .resolve(jvmVariantDir);
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    58
        }
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    59
        if (!path.toFile().exists()) {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    60
            throw new Error("TESTBUG: the library has not been found in " + nativePath);
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    61
        }
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    62
        path = path.resolve("gtestLauncher" + (Platform.isWindows() ? ".exe" : ""));
38731
2c741a995b07 8158106: native/GTestWrapper.java gets SIGABR
ctornqvi
parents: 38307
diff changeset
    63
        ProcessTools.executeCommand(new String[] {
2c741a995b07 8158106: native/GTestWrapper.java gets SIGABR
ctornqvi
parents: 38307
diff changeset
    64
                path.toString(),
2c741a995b07 8158106: native/GTestWrapper.java gets SIGABR
ctornqvi
parents: 38307
diff changeset
    65
                "-jdk",
2c741a995b07 8158106: native/GTestWrapper.java gets SIGABR
ctornqvi
parents: 38307
diff changeset
    66
                System.getProperty("test.jdk")
2c741a995b07 8158106: native/GTestWrapper.java gets SIGABR
ctornqvi
parents: 38307
diff changeset
    67
        }).shouldHaveExitValue(0);
38307
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    68
    }
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    69
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    70
    private static String getJVMVariantSubDir() {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    71
        if (Platform.isServer()) {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    72
            return "server";
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    73
        } else if (Platform.isClient()) {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    74
            return "client";
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    75
        } else if (Platform.isMinimal()) {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    76
            return "minimal";
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    77
        } else {
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    78
            throw new Error("TESTBUG: unsuppported vm variant");
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    79
        }
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    80
    }
c9555da2ae99 8156681: Add jtreg wrapper for hotspot gtest tests
iignatyev
parents:
diff changeset
    81
}