test/jdk/tools/launcher/Test7029048.java
author goetz
Mon, 14 Jan 2019 00:00:00 +0100
changeset 53273 bbc79e0ec9ee
parent 53229 76a4b08fdf59
child 53373 6d1c1f4fc3d5
permissions -rw-r--r--
8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName() and adapt all tests. Summary: Also cleanup some switches over OSes and use File.pathSeparator. Reviewed-by: dholmes, mdoerr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
     1
/*
53273
bbc79e0ec9ee 8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName() and adapt all tests.
goetz
parents: 53229
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
     4
 *
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
     8
 *
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    13
 * accompanied this code).
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    14
 *
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    18
 *
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    21
 * questions.
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    22
 */
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    23
53273
bbc79e0ec9ee 8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName() and adapt all tests.
goetz
parents: 53229
diff changeset
    24
/**
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    25
 * @test
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    26
 * @bug 7029048
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    27
 * @summary Checks for LD_LIBRARY_PATH on *nixes
53273
bbc79e0ec9ee 8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName() and adapt all tests.
goetz
parents: 53229
diff changeset
    28
 * @library /test/lib
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
    29
 * @compile -XDignore.symbol.file ExecutionEnvironment.java Test7029048.java
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    30
 * @run main Test7029048
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    31
 */
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    32
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    33
/*
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
    34
 * 7029048: test for LD_LIBRARY_PATH set to different paths which may or
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
    35
 * may not contain a libjvm.so, but we test to ensure that the launcher
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    36
 * behaves correctly in all cases.
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    37
 */
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    38
import java.io.File;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    39
import java.io.IOException;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    40
import java.nio.file.Files;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    41
import java.util.ArrayList;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    42
import java.util.HashMap;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    43
import java.util.List;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    44
import java.util.Map;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    45
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
    46
public class Test7029048 extends TestHelper {
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    47
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    48
    static int passes = 0;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    49
    static int errors = 0;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    50
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    51
    private static final String LIBJVM = ExecutionEnvironment.LIBJVM;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    52
    private static final String LD_LIBRARY_PATH =
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    53
            ExecutionEnvironment.LD_LIBRARY_PATH;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    54
    private static final String LD_LIBRARY_PATH_64 =
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    55
            ExecutionEnvironment.LD_LIBRARY_PATH_64;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    56
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    57
    private static final File libDir =
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    58
            new File(System.getProperty("sun.boot.library.path"));
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    59
    private static final File srcServerDir = new File(libDir, "server");
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    60
    private static final File srcLibjvmSo = new File(srcServerDir, LIBJVM);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    61
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    62
    private static final File dstLibDir = new File("lib");
53229
76a4b08fdf59 8210669: Some launcher tests assume a pre-JDK 9 run-time image layout
mr
parents: 47216
diff changeset
    63
    private static final File dstServerDir = new File(dstLibDir, "server");
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    64
    private static final File dstServerLibjvm = new File(dstServerDir, LIBJVM);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    65
53229
76a4b08fdf59 8210669: Some launcher tests assume a pre-JDK 9 run-time image layout
mr
parents: 47216
diff changeset
    66
    private static final File dstClientDir = new File(dstLibDir, "client");
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    67
    private static final File dstClientLibjvm = new File(dstClientDir, LIBJVM);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    68
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    69
    private static final Map<String, String> env = new HashMap<>();
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    70
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    71
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    72
    static String getValue(String name, List<String> in) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    73
        for (String x : in) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    74
            String[] s = x.split("=");
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    75
            if (name.equals(s[0].trim())) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    76
                return s[1].trim();
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    77
            }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    78
        }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    79
        return null;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    80
    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    81
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
    82
    static void run(Map<String, String> env,
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    83
            int nLLPComponents, String caseID) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    84
        env.put(ExecutionEnvironment.JLDEBUG_KEY, "true");
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    85
        List<String> cmdsList = new ArrayList<>();
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
    86
        cmdsList.add(javaCmd);
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    87
        cmdsList.add("-server");
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    88
        cmdsList.add("-jar");
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    89
        cmdsList.add(ExecutionEnvironment.testJarFile.getAbsolutePath());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    90
        String[] cmds = new String[cmdsList.size()];
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
    91
        TestResult tr = doExec(env, cmdsList.toArray(cmds));
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
    92
        System.out.println(tr);
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    93
        analyze(tr, nLLPComponents, caseID);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    94
    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    95
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
    96
    static void analyze(TestResult tr, int nLLPComponents, String caseID) {
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    97
        String envValue = getValue(LD_LIBRARY_PATH, tr.testOutput);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    98
       /*
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
    99
        * the envValue can never be null, since the test code should always
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   100
        * print a "null" string.
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   101
        */
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   102
        if (envValue == null) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   103
            System.out.println(tr);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   104
            throw new RuntimeException("NPE, likely a program crash ??");
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   105
        }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   106
        String values[] = envValue.split(File.pathSeparator);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   107
        if (values.length == nLLPComponents) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   108
            System.out.println(caseID + " :OK");
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   109
            passes++;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   110
        } else {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   111
            System.out.println("FAIL: test7029048, " + caseID);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   112
            System.out.println(" expected " + nLLPComponents
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   113
                    + " but got " + values.length);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   114
            System.out.println(envValue);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   115
            System.out.println(tr);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   116
            errors++;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   117
        }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   118
    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   119
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   120
    /*
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   121
     * A crucial piece, specifies what we should expect, given the conditions.
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   122
     * That is for a given enum type, the value indicates how many absolute
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   123
     * environment variables that can be expected. This value is used to base
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   124
     * the actual expected values by adding the set environment variable usually
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   125
     * it is 1, but it could be more if the test wishes to set more paths in
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   126
     * the future.
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   127
     */
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   128
    private static enum LLP_VAR {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   129
        LLP_SET_NON_EXISTENT_PATH(0),   // env set, but the path does not exist
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   130
        LLP_SET_EMPTY_PATH(0),          // env set, with a path but no libjvm.so
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   131
        LLP_SET_WITH_JVM(3);            // env set, with a libjvm.so
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   132
        private final int value;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   133
        LLP_VAR(int i) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   134
            this.value = i;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   135
        }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   136
    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   137
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   138
    /*
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   139
     * test for 7029048
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   140
     */
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   141
    static void test7029048() throws IOException {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   142
        String desc = null;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   143
        for (LLP_VAR v : LLP_VAR.values()) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   144
            switch (v) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   145
                case LLP_SET_WITH_JVM:
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   146
                    // copy the files into the directory structures
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
   147
                    copyFile(srcLibjvmSo, dstServerLibjvm);
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   148
                    // does not matter if it is client or a server
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
   149
                    copyFile(srcLibjvmSo, dstClientLibjvm);
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   150
                    desc = "LD_LIBRARY_PATH should be set";
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   151
                    break;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   152
                case LLP_SET_EMPTY_PATH:
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   153
                    if (!dstClientDir.exists()) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   154
                        Files.createDirectories(dstClientDir.toPath());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   155
                    } else {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   156
                        Files.deleteIfExists(dstClientLibjvm.toPath());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   157
                    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   158
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   159
                    if (!dstServerDir.exists()) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   160
                        Files.createDirectories(dstServerDir.toPath());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   161
                    } else {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   162
                        Files.deleteIfExists(dstServerLibjvm.toPath());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   163
                    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   164
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   165
                    desc = "LD_LIBRARY_PATH should not be set";
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   166
                    break;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   167
                case LLP_SET_NON_EXISTENT_PATH:
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   168
                    if (dstLibDir.exists()) {
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
   169
                        recursiveDelete(dstLibDir);
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   170
                    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   171
                    desc = "LD_LIBRARY_PATH should not be set";
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   172
                    break;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   173
                default:
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   174
                    throw new RuntimeException("unknown case");
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   175
            }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   176
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   177
            /*
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   178
             * Case 1: set the server path
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   179
             */
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   180
            env.clear();
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   181
            env.put(LD_LIBRARY_PATH, dstServerDir.getAbsolutePath());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   182
            run(env, v.value + 1, "Case 1: " + desc);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   183
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   184
            /*
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   185
             * Case 2: repeat with client path
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   186
             */
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   187
            env.clear();
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   188
            env.put(LD_LIBRARY_PATH, dstClientDir.getAbsolutePath());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   189
            run(env, v.value + 1, "Case 2: " + desc);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   190
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
   191
            if (isSolaris) {
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
   192
                /*
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
   193
                 * Case 3: set the appropriate LLP_XX flag,
45062
37ed4313c8c1 8169646: Remove launcher's -d32/-d64 option
ksrini
parents: 21812
diff changeset
   194
                 * java64 LLP_64 is relevant, LLP_32 is ignored
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
   195
                 */
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
   196
                env.clear();
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
   197
                env.put(LD_LIBRARY_PATH_64, dstServerDir.getAbsolutePath());
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 12047
diff changeset
   198
                run(env, v.value + 1, "Case 3: " + desc);
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   199
            }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   200
        }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   201
        return;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   202
    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   203
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   204
    public static void main(String... args) throws Exception {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
   205
        if (TestHelper.isWindows || TestHelper.isMacOSX) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
   206
            System.out.println("Note: applicable on neither Windows nor MacOSX");
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   207
            return;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   208
        }
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   209
        if (!TestHelper.haveServerVM) {
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   210
            System.out.println("Note: test relies on server vm, not found, exiting");
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   211
            return;
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   212
        }
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   213
        // create our test jar first
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   214
        ExecutionEnvironment.createTestJar();
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   215
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   216
        // run the tests
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   217
        test7029048();
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   218
        if (errors > 0) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   219
            throw new Exception("Test7029048: FAIL: with "
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   220
                    + errors + " errors and passes " + passes);
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
   221
        } else if (isSolaris && passes < 9) {
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   222
            throw new Exception("Test7029048: FAIL: " +
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   223
                    "all tests did not run, expected " + 9 + " got " + passes);
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 9244
diff changeset
   224
        } else if (isLinux && passes < 6) {
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   225
             throw new Exception("Test7029048: FAIL: " +
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   226
                    "all tests did not run, expected " + 6 + " got " + passes);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   227
        } else {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   228
            System.out.println("Test7029048: PASS " + passes);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   229
        }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   230
    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
diff changeset
   231
}