jdk/test/tools/launcher/ExecutionEnvironment.java
author never
Mon, 12 Jul 2010 22:27:18 -0700
changeset 5926 a36f90d986b6
parent 5506 202f599c92aa
child 9244 84d85c90d5db
permissions -rw-r--r--
6968385: malformed xml in sweeper logging Reviewed-by: kvn
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
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4340
diff changeset
     2
 * Copyright (c) 2009, 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
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    28
 * @compile -XDignore.symbol.file ExecutionEnvironment.java TestHelper.java
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
/*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    33
 * This test tests for various things as follows:
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
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    63
public class ExecutionEnvironment {
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 JLDEBUG_KEY = "_JAVA_LAUNCHER_DEBUG";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    74
    static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    75
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    76
    static final String[] LD_PATH_STRINGS = {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    77
        LD_LIBRARY_PATH + "=" + LD_LIBRARY_PATH_VALUE,
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    78
        LD_LIBRARY_PATH_32 + "=" + LD_LIBRARY_PATH_32_VALUE,
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    79
        LD_LIBRARY_PATH_64 + "=" + LD_LIBRARY_PATH_64_VALUE
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
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    82
    static final File testJarFile = new File("EcoFriendly.jar");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    83
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    84
    static int errors = 0;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    85
    static int passes = 0;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    86
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    87
    private static void createTestJar() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    88
        try {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    89
            List<String> codeList = new ArrayList<String>();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    90
            codeList.add("static void printValue(String name, boolean property) {\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    91
            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
    92
            codeList.add("    System.out.println(name + \"=\" + value);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    93
            codeList.add("}\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    94
            codeList.add("public static void main(String... args) {\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    95
            codeList.add("    System.out.println(\"Execute test:\");\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    96
            codeList.add("    printValue(\"os.name\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    97
            codeList.add("    printValue(\"os.arch\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    98
            codeList.add("    printValue(\"os.version\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
    99
            codeList.add("    printValue(\"sun.arch.data.model\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   100
            codeList.add("    printValue(\"java.library.path\", true);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   101
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   102
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH_32 + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   103
            codeList.add("    printValue(\"" + LD_LIBRARY_PATH_64 + "\", false);\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   104
            codeList.add("}\n");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   105
            String[] clist = new String[codeList.size()];
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   106
            TestHelper.createJar(testJarFile, codeList.toArray(clist));
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   107
        } catch (FileNotFoundException fnfe) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   108
            throw new RuntimeException(fnfe);
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
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   113
     * 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
   114
     * 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
   115
     * environment should be pristine.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   116
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   117
    private static void ensureEcoFriendly() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   118
        TestHelper.TestResult tr = null;
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
        Map<String, String> env = new HashMap<String, String>();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   121
        for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   122
            String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   123
            env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   124
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   125
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   126
        tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   127
                testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   128
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   129
        if (!tr.isNotZeroOutput()) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   130
            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
   131
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   132
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   133
        for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   134
            if (!tr.contains(x)) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   135
                System.out.println("FAIL: did not get <" + x + ">");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   136
                System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   137
                errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   138
            } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   139
                passes++;
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
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   145
     * 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
   146
     * data model
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
    static void ensureNoExec() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   149
        Map<String, String> env = new HashMap<String, String>();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   150
        env.put(JLDEBUG_KEY, "true");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   151
        TestHelper.TestResult tr =
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   152
                TestHelper.doExec(env, TestHelper.javaCmd, "-version");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   153
        if (tr.testOutput.contains(EXPECTED_MARKER)) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   154
            System.out.println("FAIL: EnsureNoExecs: found expected warning <" +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   155
                    EXPECTED_MARKER +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   156
                    "> the process execing ?");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   157
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   158
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   159
            passes++;
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
        return;
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
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
     * 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
   166
     * and the expected java.library.path behaviour.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   167
     * For Generic platforms (All *nixes):
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   168
     *    * 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
   169
     * For Solaris 32-bit
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   170
     *    * 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
   171
     * For Solaris 64-bit
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   172
     *    * 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
   173
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   174
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   175
    static void verifyJavaLibraryPath() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   176
        TestHelper.TestResult tr = null;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   177
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   178
        Map<String, String> env = new HashMap<String, String>();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   179
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   180
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   181
        if (TestHelper.isLinux) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   182
            for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   183
                String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   184
                env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   185
            }
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
            tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   188
                    testJarFile.getAbsolutePath());
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);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   194
            tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   195
                    testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   196
            verifyJavaLibraryPathGeneric(tr);
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
            env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   199
            for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   200
                String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   201
                env.put(pairs[0], pairs[1]);
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
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   204
            // verify the override occurs, since we know the invocation always
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   205
            // 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
   206
            // expectation to be the same.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   207
            tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   208
                    testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   209
            verifyJavaLibraryPathOverride(tr, true);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   210
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   211
            // try changing the model from 32 to 64 bit
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   212
            if (TestHelper.java64Cmd != null && TestHelper.is32Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   213
                // verify the override occurs
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   214
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   215
                for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   216
                    String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   217
                    env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   218
                }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   219
                tr = TestHelper.doExec(env, TestHelper.javaCmd, "-d64", "-jar",
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   220
                    testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   221
                verifyJavaLibraryPathOverride(tr, false);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   222
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   223
                // no override
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   224
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   225
                env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   226
                tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   227
                        testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   228
                verifyJavaLibraryPathGeneric(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   229
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   230
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   231
            // try changing the model from 64 to 32 bit
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   232
            if (TestHelper.java64Cmd != null && TestHelper.is64Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   233
                // verify the override occurs
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   234
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   235
                for (String x : LD_PATH_STRINGS) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   236
                    String pairs[] = x.split("=");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   237
                    env.put(pairs[0], pairs[1]);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   238
                }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   239
                tr = TestHelper.doExec(env, TestHelper.java64Cmd, "-d32", "-jar",
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   240
                    testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   241
                verifyJavaLibraryPathOverride(tr, true);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   242
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   243
                // no override
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   244
                env.clear();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   245
                env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   246
                tr = TestHelper.doExec(env, TestHelper.java64Cmd, "-d32", "-jar",
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   247
                        testJarFile.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   248
                verifyJavaLibraryPathGeneric(tr);
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
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   251
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   252
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   253
    private static void verifyJavaLibraryPathGeneric(TestHelper.TestResult tr) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   254
        if (!tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   255
            System.out.print("FAIL: verifyJavaLibraryPath: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   256
            System.out.println(" java.library.path does not contain " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   257
                    LD_LIBRARY_PATH_VALUE);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   258
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   259
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   260
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   261
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   262
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   263
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   264
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   265
    private static void verifyJavaLibraryPathOverride(TestHelper.TestResult tr,
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   266
            boolean is32Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   267
        // make sure the 32/64 bit value exists
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   268
        if (!tr.matches("java.library.path=.*" +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   269
                (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
   270
            System.out.print("FAIL: verifyJavaLibraryPathOverride: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   271
            System.out.println(" java.library.path does not contain " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   272
                    (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
   273
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   274
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   275
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   276
            passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   277
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   278
        // make sure the generic value is absent
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   279
        if (tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   280
            System.out.print("FAIL: verifyJavaLibraryPathOverride: ");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   281
            System.out.println(" java.library.path contains " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   282
                    LD_LIBRARY_PATH_VALUE);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   283
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   284
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   285
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   286
            passes++;
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
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   290
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   291
     * 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
   292
     * -server, however 32-bit VMs support -client and -server.
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   293
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   294
    static void verifyVmSelection() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   295
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   296
        TestHelper.TestResult tr = null;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   297
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   298
        if (TestHelper.is32Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   299
            tr = TestHelper.doExec(TestHelper.javaCmd, "-client", "-version");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   300
            if (!tr.matches("Java.*Client VM.*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   301
                System.out.println("FAIL: the expected vm -client did launch");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   302
                System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   303
                errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   304
            } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   305
                passes++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   306
            }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   307
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   308
        tr = TestHelper.doExec(TestHelper.javaCmd, "-server", "-version");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   309
        if (!tr.matches("Java.*Server VM.*")) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   310
            System.out.println("FAIL: the expected vm -server did launch");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   311
            System.out.println(tr);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   312
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   313
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   314
            passes++;
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
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
     * 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
   320
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   321
    static void verifyNoSymLink() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   322
        if (TestHelper.is64Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   323
            return;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   324
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   325
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   326
        File symLink = null;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   327
        String libPathPrefix = TestHelper.isSDK ? "jre/lib" : "/lib";
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   328
        symLink = new File(TestHelper.JAVAHOME, libPathPrefix +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   329
                TestHelper.getJreArch() + "/libjvm.so");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   330
        if (symLink.exists()) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   331
            System.out.println("FAIL: The symlink exists " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   332
                    symLink.getAbsolutePath());
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   333
            errors++;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   334
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   335
            passes++;
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
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   338
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   339
    public static void main(String... args) throws Exception {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   340
        if (TestHelper.isWindows) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   341
            System.out.println("Warning: noop on windows");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   342
            return;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   343
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   344
        // create our test jar first
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   345
        createTestJar();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   346
        ensureNoExec();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   347
        verifyVmSelection();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   348
        ensureEcoFriendly();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   349
        verifyJavaLibraryPath();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   350
        verifyNoSymLink();
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   351
        if (errors > 0) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   352
            throw new Exception("ExecutionEnvironment: FAIL: with " +
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   353
                    errors + " errors and passes " + passes );
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   354
        } else {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   355
            System.out.println("ExecutionEnvironment: PASS " + passes);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   356
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   357
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
diff changeset
   358
}