jdk/test/tools/launcher/ExecutionEnvironment.java
author ksrini
Sat, 28 Jan 2012 10:46:46 -0800
changeset 11687 f13cadbb0bb5
parent 10053 43930b0d0564
child 12047 320a714614e9
permissions -rw-r--r--
7127906: (launcher) convert the launcher regression tests to java Reviewed-by: darcy, naoto
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 {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    64
    static final String LD_LIBRARY_PATH    = "LD_LIBRARY_PATH";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    65
    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
    66
    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
    67
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    68
    // Note: these paths need not exist on the filesytem
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    69
    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
    70
    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
    71
    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
    72
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    73
    static final String[] LD_PATH_STRINGS = {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    74
        LD_LIBRARY_PATH + "=" + LD_LIBRARY_PATH_VALUE,
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    75
        LD_LIBRARY_PATH_32 + "=" + LD_LIBRARY_PATH_32_VALUE,
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    76
        LD_LIBRARY_PATH_64 + "=" + LD_LIBRARY_PATH_64_VALUE
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    77
    };
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    78
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    79
    static final File testJarFile = new File("EcoFriendly.jar");
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 int errors = 0;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    82
    static int passes = 0;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    83
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
    84
    static final String LIBJVM = isWindows ? "jvm.dll" : "libjvm.so";
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    85
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    86
    static void createTestJar() {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    87
        try {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
    88
            List<String> codeList = new ArrayList<>();
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    89
            codeList.add("static void printValue(String name, boolean property) {\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    90
            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
    91
            codeList.add("    System.out.println(name + \"=\" + value);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    92
            codeList.add("}\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    93
            codeList.add("public static void main(String... args) {\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    94
            codeList.add("    System.out.println(\"Execute test:\");\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    95
            codeList.add("    printValue(\"os.name\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    96
            codeList.add("    printValue(\"os.arch\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    97
            codeList.add("    printValue(\"os.version\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    98
            codeList.add("    printValue(\"sun.arch.data.model\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    99
            codeList.add("    printValue(\"java.library.path\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   100
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   101
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH_32 + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   102
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH_64 + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   103
            codeList.add("}\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   104
            String[] clist = new String[codeList.size()];
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   105
            createJar(testJarFile, codeList.toArray(clist));
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   106
        } catch (FileNotFoundException fnfe) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   107
            throw new RuntimeException(fnfe);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   108
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   109
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   110
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   111
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   112
     * 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
   113
     * 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
   114
     * environment should be pristine.
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
    private static void ensureEcoFriendly() {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   117
        TestResult tr = null;
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   118
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   119
        Map<String, String> env = new HashMap<>();
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   120
        for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   121
            String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   122
            env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   123
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   124
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   125
        tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   126
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   127
        if (!tr.isNotZeroOutput()) {
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   128
            System.out.println(tr);
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   129
            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
   130
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   131
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   132
        for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   133
            if (!tr.contains(x)) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   134
                System.out.println("FAIL: did not get <" + x + ">");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   135
                System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   136
                errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   137
            } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   138
                passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   139
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   140
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   141
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   142
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
     * 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
   145
     * data model
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
    static void ensureNoExec() {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   148
        Map<String, String> env = new HashMap<>();
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   149
        env.put(JLDEBUG_KEY, "true");
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   150
        TestResult tr = doExec(env, javaCmd, "-version");
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   151
        if (tr.testOutput.contains(EXPECTED_MARKER)) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   152
            System.out.println("FAIL: EnsureNoExecs: found expected warning <" +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   153
                    EXPECTED_MARKER +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   154
                    "> the process execing ?");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   155
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   156
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   157
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   158
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   159
        return;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   160
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   161
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
     * 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
   164
     * and the expected java.library.path behaviour.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   165
     * For Generic platforms (All *nixes):
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   166
     *    * 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
   167
     * For Solaris 32-bit
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   168
     *    * 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
   169
     * For Solaris 64-bit
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   170
     *    * 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
   171
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   172
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   173
    static void verifyJavaLibraryPath() {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   174
        TestResult tr = null;
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   175
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   176
        Map<String, String> env = new HashMap<>();
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   177
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   178
        if (isLinux) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   179
            for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   180
                String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   181
                env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   182
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   183
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   184
            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   185
            verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   186
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   187
            // no override
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   188
            env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   189
            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
   190
            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   191
            verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   192
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   193
            env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   194
            for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   195
                String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   196
                env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   197
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   198
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   199
            // verify the override occurs, since we know the invocation always
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   200
            // 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
   201
            // expectation to be the same.
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   202
            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   203
            verifyJavaLibraryPathOverride(tr, true);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   204
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   205
            // 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
   206
            if (dualModePresent() && is32Bit) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   207
                // verify the override occurs
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   208
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   209
                for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   210
                    String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   211
                    env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   212
                }
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   213
                tr = doExec(env, javaCmd, "-d64", "-jar",
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   214
                    testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   215
                verifyJavaLibraryPathOverride(tr, false);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   216
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   217
                // no override
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   218
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   219
                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
   220
                tr = doExec(env, javaCmd, "-jar",
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   221
                        testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   222
                verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   223
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   224
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   225
            // 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
   226
            if (java64Cmd != null && is64Bit) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   227
                // verify the override occurs
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   228
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   229
                for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   230
                    String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   231
                    env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   232
                }
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   233
                tr = doExec(env, java64Cmd, "-d32", "-jar",
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   234
                    testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   235
                verifyJavaLibraryPathOverride(tr, true);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   236
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   237
                // no override
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   238
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   239
                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
   240
                tr = doExec(env, java64Cmd, "-d32", "-jar",
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   241
                        testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   242
                verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   243
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   244
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   245
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   246
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   247
    private static void verifyJavaLibraryPathGeneric(TestResult tr) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   248
        if (!tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   249
            System.out.print("FAIL: verifyJavaLibraryPath: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   250
            System.out.println(" java.library.path does not contain " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   251
                    LD_LIBRARY_PATH_VALUE);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   252
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   253
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   254
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   255
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   256
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   257
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   258
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   259
    private static void verifyJavaLibraryPathOverride(TestResult tr,
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   260
            boolean is32Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   261
        // make sure the 32/64 bit value exists
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   262
        if (!tr.matches("java.library.path=.*" +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   263
                (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
   264
            System.out.print("FAIL: verifyJavaLibraryPathOverride: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   265
            System.out.println(" java.library.path does not contain " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   266
                    (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
   267
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   268
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   269
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   270
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   271
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   272
        // make sure the generic value is absent
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   273
        if (tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   274
            System.out.print("FAIL: verifyJavaLibraryPathOverride: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   275
            System.out.println(" java.library.path contains " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   276
                    LD_LIBRARY_PATH_VALUE);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   277
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   278
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   279
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   280
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   281
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   282
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   283
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   284
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   285
     * 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
   286
     * -server, however 32-bit VMs support -client and -server.
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
    static void verifyVmSelection() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   289
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   290
        TestResult tr = null;
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   291
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   292
        if (is32Bit) {
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   293
            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
   294
            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
   295
                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
   296
                System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   297
                errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   298
            } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   299
                passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   300
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   301
        }
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   302
        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
   303
        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
   304
            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
   305
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   306
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   307
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   308
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   309
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   310
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   311
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   312
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   313
     * 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
   314
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   315
    static void verifyNoSymLink() {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   316
        if (is64Bit) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   317
            return;
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
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   320
        File symLink = null;
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   321
        String libPathPrefix = isSDK ? "jre/lib" : "/lib";
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   322
        symLink = new File(JAVAHOME, libPathPrefix +
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   323
                getJreArch() + "/" + LIBJVM);
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   324
        if (symLink.exists()) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   325
            System.out.println("FAIL: The symlink exists " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   326
                    symLink.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   327
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   328
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   329
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   330
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   331
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   332
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   333
    public static void main(String... args) throws Exception {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 10053
diff changeset
   334
        if (isWindows) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   335
            System.out.println("Warning: noop on windows");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   336
            return;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   337
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   338
        // create our test jar first
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   339
        createTestJar();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   340
        ensureNoExec();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   341
        verifyVmSelection();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   342
        ensureEcoFriendly();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   343
        verifyJavaLibraryPath();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   344
        verifyNoSymLink();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   345
        if (errors > 0) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   346
            throw new Exception("ExecutionEnvironment: FAIL: with " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   347
                    errors + " errors and passes " + passes );
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   348
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   349
            System.out.println("ExecutionEnvironment: PASS " + passes);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   350
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   351
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   352
}