jdk/test/tools/launcher/ExecutionEnvironment.java
author ksrini
Fri, 30 Mar 2012 17:22:02 -0700
changeset 12303 498f8b38423b
parent 12047 320a714614e9
child 20201 50cc2d25a60b
permissions -rw-r--r--
7158090: (launcher) newly added ToolsOpts.java fails on openjdk builds Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
     1
/*
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
     2
 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
     4
 *
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
     8
 *
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    13
 * accompanied this code).
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    14
 *
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4340
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4340
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4340
diff changeset
    21
 * questions.
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    22
 */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    23
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    24
/*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    25
 * @test
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    26
 * @bug 4780570 4731671 6354700 6367077 6670965 4882974
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    27
 * @summary Checks for LD_LIBRARY_PATH and execution  on *nixes
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
    28
 * @compile -XDignore.symbol.file ExecutionEnvironment.java
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    29
 * @run main ExecutionEnvironment
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    30
 */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    31
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    32
/*
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    33
 * This tests for various things as follows:
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    34
 * Ensures that:
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    35
 *   1. uneccessary execs do not occur
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    36
 *   2. the environment is pristine,  users environment variable wrt.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    37
 *      LD_LIBRARY_PATH if set are not modified in any way.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    38
 *   3. the correct vm is chosen with -server and -client options
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    39
 *   4. the VM on Solaris correctly interprets the LD_LIBRARY_PATH32
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    40
 *      and LD_LIBRARY_PATH64 variables if set by the user, ie.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    41
 *      i. on 32 bit systems:
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    42
 *         a. if LD_LIBRARY_PATH32 is set it will override LD_LIBRARY_PATH
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    43
 *         b. LD_LIBRARY_PATH64 is ignored if set
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    44
 *      ii. on 64 bit systems:
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    45
 *            a. if LD_LIBRARY_PATH64 is set it will override LD_LIBRARY_PATH
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    46
 *            b. LD_LIBRARY_PATH32 is ignored if set
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    47
 *   5. no extra symlink exists on Solaris ie.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    48
 *      jre/lib/$arch/libjvm.so -> client/libjvm.so
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    49
 * TODO:
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    50
 *      a. perhaps we need to add a test to audit all environment variables are
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    51
 *         in pristine condition after the launch, there may be a few that the
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    52
 *         launcher may add as implementation details.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    53
 *      b. add a pldd for solaris to ensure only one libjvm.so is linked
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    54
 */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    55
import java.io.File;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    56
import java.io.FileNotFoundException;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    57
import java.util.ArrayList;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    58
import java.util.HashMap;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    59
import java.util.List;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    60
import java.util.Map;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    61
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    62
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
    63
public class ExecutionEnvironment extends TestHelper {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
    64
    static final String LD_LIBRARY_PATH    = TestHelper.isMacOSX
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
    65
            ? "DYLD_LIBRARY_PATH"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
    66
            : "LD_LIBRARY_PATH";
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    67
    static final String LD_LIBRARY_PATH_32 = LD_LIBRARY_PATH + "_32";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    68
    static final String LD_LIBRARY_PATH_64 = LD_LIBRARY_PATH + "_64";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    69
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    70
    // Note: these paths need not exist on the filesytem
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    71
    static final String LD_LIBRARY_PATH_VALUE    = "/Bridge/On/The/River/Kwai";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    72
    static final String LD_LIBRARY_PATH_32_VALUE = "/Lawrence/Of/Arabia";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    73
    static final String LD_LIBRARY_PATH_64_VALUE = "/A/Passage/To/India";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    74
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    75
    static final String[] LD_PATH_STRINGS = {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    76
        LD_LIBRARY_PATH + "=" + LD_LIBRARY_PATH_VALUE,
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    77
        LD_LIBRARY_PATH_32 + "=" + LD_LIBRARY_PATH_32_VALUE,
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    78
        LD_LIBRARY_PATH_64 + "=" + LD_LIBRARY_PATH_64_VALUE
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    79
    };
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    80
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    81
    static final File testJarFile = new File("EcoFriendly.jar");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    82
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    83
    static int errors = 0;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    84
    static int passes = 0;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    85
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
    86
    static final String LIBJVM = TestHelper.isWindows
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
    87
            ? "jvm.dll"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
    88
            : "libjvm" + (TestHelper.isMacOSX ? ".dylib" : ".so");
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    89
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    90
    static void createTestJar() {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    91
        try {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
    92
            List<String> codeList = new ArrayList<>();
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    93
            codeList.add("static void printValue(String name, boolean property) {\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    94
            codeList.add("    String value = (property) ? System.getProperty(name) : System.getenv(name);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    95
            codeList.add("    System.out.println(name + \"=\" + value);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    96
            codeList.add("}\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    97
            codeList.add("public static void main(String... args) {\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    98
            codeList.add("    System.out.println(\"Execute test:\");\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    99
            codeList.add("    printValue(\"os.name\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   100
            codeList.add("    printValue(\"os.arch\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   101
            codeList.add("    printValue(\"os.version\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   102
            codeList.add("    printValue(\"sun.arch.data.model\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   103
            codeList.add("    printValue(\"java.library.path\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   104
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   105
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH_32 + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   106
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH_64 + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   107
            codeList.add("}\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   108
            String[] clist = new String[codeList.size()];
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   109
            createJar(testJarFile, codeList.toArray(clist));
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   110
        } catch (FileNotFoundException fnfe) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   111
            throw new RuntimeException(fnfe);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   112
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   113
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   114
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   115
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   116
     * tests if the launcher pollutes the LD_LIBRARY_PATH variables ie. there
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   117
     * should not be any new variables or pollution/mutations of any kind, the
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   118
     * environment should be pristine.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   119
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   120
    private static void ensureEcoFriendly() {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   121
        TestResult tr = null;
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   122
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   123
        Map<String, String> env = new HashMap<>();
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   124
        for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   125
            String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   126
            env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   127
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   128
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   129
        tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   130
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   131
        if (!tr.isNotZeroOutput()) {
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   132
            System.out.println(tr);
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   133
            throw new RuntimeException("Error: No output at all. Did the test execute ?");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   134
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   135
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   136
        for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   137
            if (!tr.contains(x)) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   138
                System.out.println("FAIL: did not get <" + x + ">");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   139
                System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   140
                errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   141
            } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   142
                passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   143
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   144
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   145
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   146
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   147
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   148
     * ensures that there are no execs as long as we are in the same
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   149
     * data model
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   150
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   151
    static void ensureNoExec() {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   152
        Map<String, String> env = new HashMap<>();
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   153
        env.put(JLDEBUG_KEY, "true");
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   154
        TestResult tr = doExec(env, javaCmd, "-version");
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   155
        if (tr.testOutput.contains(EXPECTED_MARKER)) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   156
            System.out.println("FAIL: EnsureNoExecs: found expected warning <" +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   157
                    EXPECTED_MARKER +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   158
                    "> the process execing ?");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   159
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   160
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   161
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   162
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   163
        return;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   164
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   165
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   166
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   167
     * This test ensures that LD_LIBRARY_PATH* values are interpreted by the VM
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   168
     * and the expected java.library.path behaviour.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   169
     * For Generic platforms (All *nixes):
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   170
     *    * All LD_LIBRARY_PATH variable should be on java.library.path
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   171
     * For Solaris 32-bit
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   172
     *    * The LD_LIBRARY_PATH_32 should override LD_LIBRARY_PATH if specified
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   173
     * For Solaris 64-bit
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   174
     *    * The LD_LIBRARY_PATH_64 should override LD_LIBRARY_PATH if specified
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   175
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   176
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   177
    static void verifyJavaLibraryPath() {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   178
        TestResult tr = null;
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   179
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   180
        Map<String, String> env = new HashMap<>();
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   181
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
   182
        if (TestHelper.isLinux || TestHelper.isMacOSX) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   183
            for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   184
                String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   185
                env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   186
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   187
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   188
            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   189
            verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   190
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   191
            // no override
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   192
            env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   193
            env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   194
            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   195
            verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   196
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   197
            env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   198
            for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   199
                String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   200
                env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   201
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   202
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   203
            // verify the override occurs, since we know the invocation always
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   204
            // uses by default is 32-bit, therefore we also set the test
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   205
            // expectation to be the same.
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   206
            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   207
            verifyJavaLibraryPathOverride(tr, true);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   208
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   209
            // try changing the model from 32 to 64 bit
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   210
            if (dualModePresent() && is32Bit) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   211
                // verify the override occurs
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   212
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   213
                for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   214
                    String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   215
                    env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   216
                }
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   217
                tr = doExec(env, javaCmd, "-d64", "-jar",
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   218
                    testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   219
                verifyJavaLibraryPathOverride(tr, false);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   220
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   221
                // no override
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   222
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   223
                env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   224
                tr = doExec(env, javaCmd, "-jar",
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   225
                        testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   226
                verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   227
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   228
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   229
            // try changing the model from 64 to 32 bit
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   230
            if (java64Cmd != null && is64Bit) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   231
                // verify the override occurs
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   232
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   233
                for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   234
                    String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   235
                    env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   236
                }
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   237
                tr = doExec(env, java64Cmd, "-d32", "-jar",
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   238
                    testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   239
                verifyJavaLibraryPathOverride(tr, true);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   240
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   241
                // no override
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   242
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   243
                env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   244
                tr = doExec(env, java64Cmd, "-d32", "-jar",
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   245
                        testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   246
                verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   247
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   248
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   249
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   250
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   251
    private static void verifyJavaLibraryPathGeneric(TestResult tr) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   252
        if (!tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   253
            System.out.print("FAIL: verifyJavaLibraryPath: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   254
            System.out.println(" java.library.path does not contain " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   255
                    LD_LIBRARY_PATH_VALUE);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   256
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   257
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   258
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   259
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   260
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   261
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   262
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   263
    private static void verifyJavaLibraryPathOverride(TestResult tr,
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   264
            boolean is32Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   265
        // make sure the 32/64 bit value exists
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   266
        if (!tr.matches("java.library.path=.*" +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   267
                (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE) + ".*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   268
            System.out.print("FAIL: verifyJavaLibraryPathOverride: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   269
            System.out.println(" java.library.path does not contain " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   270
                    (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE));
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   271
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   272
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   273
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   274
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   275
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   276
        // make sure the generic value is absent
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   277
        if (tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   278
            System.out.print("FAIL: verifyJavaLibraryPathOverride: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   279
            System.out.println(" java.library.path contains " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   280
                    LD_LIBRARY_PATH_VALUE);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   281
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   282
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   283
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   284
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   285
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   286
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   287
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   288
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   289
     * ensures we have indeed exec'ed the correct vm of choice, all VMs support
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   290
     * -server, however 32-bit VMs support -client and -server.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   291
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   292
    static void verifyVmSelection() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   293
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   294
        TestResult tr = null;
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   295
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   296
        if (is32Bit) {
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   297
            tr = doExec(javaCmd, "-client", "-version");
10053
43930b0d0564 7043125: TEST: tools/launcher/VersionCheck.java fails just against openjdk7 (b141 & b138-nightly) promoted
ksrini
parents: 9244
diff changeset
   298
            if (!tr.matches(".*Client VM.*")) {
43930b0d0564 7043125: TEST: tools/launcher/VersionCheck.java fails just against openjdk7 (b141 & b138-nightly) promoted
ksrini
parents: 9244
diff changeset
   299
                System.out.println("FAIL: the expected vm -client did not launch");
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   300
                System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   301
                errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   302
            } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   303
                passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   304
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   305
        }
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   306
        tr = doExec(javaCmd, "-server", "-version");
10053
43930b0d0564 7043125: TEST: tools/launcher/VersionCheck.java fails just against openjdk7 (b141 & b138-nightly) promoted
ksrini
parents: 9244
diff changeset
   307
        if (!tr.matches(".*Server VM.*")) {
43930b0d0564 7043125: TEST: tools/launcher/VersionCheck.java fails just against openjdk7 (b141 & b138-nightly) promoted
ksrini
parents: 9244
diff changeset
   308
            System.out.println("FAIL: the expected vm -server did not launch");
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   309
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   310
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   311
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   312
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   313
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   314
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   315
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   316
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   317
     * checks to see there is no extra libjvm.so than needed
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   318
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   319
    static void verifyNoSymLink() {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   320
        if (is64Bit) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   321
            return;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   322
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   323
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   324
        File symLink = null;
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   325
        String libPathPrefix = isSDK ? "jre/lib" : "/lib";
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   326
        symLink = new File(JAVAHOME, libPathPrefix +
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   327
                getJreArch() + "/" + LIBJVM);
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   328
        if (symLink.exists()) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   329
            System.out.println("FAIL: The symlink exists " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   330
                    symLink.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   331
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   332
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   333
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   334
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   335
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   336
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   337
    public static void main(String... args) throws Exception {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   338
        if (isWindows) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   339
            System.out.println("Warning: noop on windows");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   340
            return;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   341
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   342
        // create our test jar first
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   343
        createTestJar();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   344
        ensureNoExec();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   345
        verifyVmSelection();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   346
        ensureEcoFriendly();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   347
        verifyJavaLibraryPath();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   348
        verifyNoSymLink();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   349
        if (errors > 0) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   350
            throw new Exception("ExecutionEnvironment: FAIL: with " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   351
                    errors + " errors and passes " + passes );
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   352
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   353
            System.out.println("ExecutionEnvironment: PASS " + passes);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   354
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   355
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   356
}