test/jdk/tools/jlink/plugins/VendorInfoPluginsTest.java
author mr
Tue, 29 Oct 2019 08:26:55 -0700
changeset 58842 6c255334120d
child 58915 02ae223a11dc
permissions -rw-r--r--
8232080: jlink plugins for vendor information and run-time options Reviewed-by: ihse, alanb, kvn, bobv, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     1
/*
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     4
 *
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     8
 *
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    13
 * accompanied this code).
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    14
 *
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    18
 *
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    21
 * questions.
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    22
 */
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    23
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    24
import jdk.test.lib.process.*;
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    25
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    26
import tests.Helper;
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    27
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    28
/* @test
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    29
 * @bug 8232080
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    30
 * @summary Test the --vendor-version --vendor-url-bug plugins
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    31
 * @library ../../lib
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    32
 * @library /test/lib
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    33
 * @modules java.base/jdk.internal.jimage
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    34
 *          jdk.jdeps/com.sun.tools.classfile
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    35
 *          jdk.jlink/jdk.tools.jlink.internal
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    36
 *          jdk.jlink/jdk.tools.jmod
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    37
 *          jdk.jlink/jdk.tools.jimage
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    38
 *          jdk.compiler
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    39
 * @build tests.*
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    40
 * @run main VendorInfoPluginsTest
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    41
 */
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    42
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    43
public class VendorInfoPluginsTest {
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    44
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    45
    public static class Crasher {
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    46
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    47
        public static void main(String ... args) throws Exception {
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    48
            var uc = Class.forName("sun.misc.Unsafe");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    49
            var f = uc.getDeclaredField("theUnsafe");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    50
            f.setAccessible(true);
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    51
            var u = (sun.misc.Unsafe)f.get(null);
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    52
            for (long a = 0; a < Long.MAX_VALUE; a += 8)
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    53
                u.putLong(a, -1L);
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    54
        }
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    55
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    56
    }
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    57
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    58
    private static final String VERSION = "XyzzyVM 3.14.15";
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    59
    private static final String BUG_URL = "https://bugs.xyzzy.com/";
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    60
    private static final String VM_BUG_URL = "https://bugs.xyzzy.com/crash/";
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    61
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    62
    public static void main(String[] args) throws Throwable {
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    63
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    64
        Helper helper = Helper.newHelper();
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    65
        if (helper == null) {
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    66
            System.err.println("Test not run");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    67
            return;
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    68
        }
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    69
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    70
        var module = "vendorinfo";
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    71
        helper.generateDefaultJModule(module);
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    72
        var image = helper.generateDefaultImage(new String[] {
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    73
                "--add-modules", "jdk.unsupported",
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    74
                "--vendor-version", VERSION,
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    75
                "--vendor-bug-url", BUG_URL,
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    76
                "--vendor-vm-bug-url", VM_BUG_URL },
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    77
            module).assertSuccess();
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    78
        helper.checkImage(image, module, null, null);
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    79
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    80
        // Properties and --version
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    81
        var launcher
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    82
            = image.resolve("bin/java"
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    83
                            + (System.getProperty("os.name").startsWith("Windows")
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    84
                               ? ".exe" : "")).toString();
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    85
        var oa = ProcessTools.executeProcess(launcher,
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    86
                                             "-XshowSettings:properties",
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    87
                                             "--version");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    88
        oa.stderrShouldMatch("^ +java.vendor.url.bug = " + BUG_URL + "$");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    89
        oa.stderrShouldMatch("^ +java.vendor.version = " + VERSION + "$");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    90
        oa.stdoutShouldMatch("^.*Runtime Environment " + VERSION + " \\(build.*$");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    91
        oa.stdoutShouldMatch("^.*Server VM " + VERSION + " \\(build.*$");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    92
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    93
        // VM error log
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    94
        oa = ProcessTools.executeProcess(launcher,
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    95
                                         "--class-path",
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    96
                                         System.getProperty("test.classes"),
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    97
                                         "VendorInfoPluginsTest$Crasher");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    98
        oa.stdoutShouldMatch("^# +" + VM_BUG_URL + "$");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
    99
        oa.stdoutShouldMatch("^.*Runtime Environment " + VERSION + " \\(.*$");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
   100
        oa.stdoutShouldMatch("^.*Server VM " + VERSION + " \\(.*$");
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
   101
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
   102
    }
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
   103
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents:
diff changeset
   104
}