jdk/test/tools/launcher/TestSpecialArgs.java
author stefank
Mon, 25 Aug 2014 09:10:13 +0200
changeset 26314 f8bc1966fb30
parent 25816 2c05592cf0f2
child 29114 a9b39a645e85
permissions -rw-r--r--
8055416: Several vm/gc/heap/summary "After GC" events emitted for the same GC ID Reviewed-by: brutisso, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12527
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
     1
/*
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
     2
 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
12527
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
     4
 *
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
     7
 * published by the Free Software Foundation.
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
     8
 *
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    13
 * accompanied this code).
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    14
 *
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    18
 *
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    21
 * questions.
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    22
 */
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    23
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    24
/*
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    25
 * @test
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    26
 * @bug 7124089 7131021 8042469
12527
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    27
 * @summary Checks for MacOSX specific flags are accepted or rejected, and
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    28
 *          MacOSX platforms specific environment is consistent.
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    29
 * @compile -XDignore.symbol.file TestSpecialArgs.java EnvironmentVariables.java
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    30
 * @run main TestSpecialArgs
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    31
 */
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    32
import java.util.HashMap;
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    33
import java.util.HashSet;
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    34
import java.util.Map;
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    35
import java.util.Set;
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    36
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    37
public class TestSpecialArgs extends TestHelper {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    38
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    39
    public static void main(String... args) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    40
        final Map<String, String> envMap = new HashMap<>();
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    41
        envMap.put("_JAVA_LAUNCHER_DEBUG", "true");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    42
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    43
        TestResult tr = doExec(envMap, javaCmd, "-XstartOnFirstThread", "-version");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    44
        if (isMacOSX) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    45
            if (!tr.contains("In same thread")) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    46
                System.out.println(tr);
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    47
                throw new RuntimeException("Error: not running in the same thread ?");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    48
            }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    49
            if (!tr.isOK()) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    50
                System.out.println(tr);
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    51
                throw new RuntimeException("Error: arg was rejected ????");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    52
            }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    53
        } else {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    54
            if (tr.isOK()) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    55
                System.out.println(tr);
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    56
                throw new RuntimeException("Error: argument was accepted ????");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    57
            }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    58
        }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    59
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    60
        tr = doExec(javaCmd, "-Xdock:/tmp/not-available", "-version");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    61
        if (isMacOSX) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    62
            if (!tr.isOK()) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    63
                System.out.println(tr);
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    64
                throw new RuntimeException("Error: arg was rejected ????");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    65
            }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    66
        } else {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    67
            if (tr.isOK()) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    68
                System.out.println(tr);
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    69
                throw new RuntimeException("Error: argument was accepted ????");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    70
            }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
    71
        }
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    72
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    73
        /*
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    74
         * test argument : -XX:NativeMemoryTracking=value
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    75
         * A JVM flag, comsumed by the JVM, but requiring launcher
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    76
         * to set an environmental variable if and only if value is supplied.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    77
         * Test and order:
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    78
         * 1) execute with valid parameter: -XX:NativeMemoryTracking=MyValue
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    79
         *    a) check for correct env variable name: "NMT_LEVEL_" + pid
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    80
         *    b) check that "MyValue" was found in local env.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    81
         * 2) execute with invalid parameter: -XX:NativeMemoryTracking=
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    82
         *    !) Won't find "NativeMemoryTracking:"
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    83
         *       Code to create env variable not executed.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    84
         * 3) execute with invalid parameter: -XX:NativeMemoryTracking
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    85
         *    !) Won't find "NativeMemoryTracking:"
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    86
         *       Code to create env variable not executed.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    87
         * 4) give and invalid value and check to make sure JVM commented
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    88
         */
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    89
        { // NativeMemoryTracking
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    90
            String launcherPidString = "launcher.pid=";
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    91
            String envVarPidString = "TRACER_MARKER: NativeMemoryTracking: env var is NMT_LEVEL_";
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    92
            String NMT_Option_Value = "off";
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    93
            String myClassName = "helloworld";
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    94
            boolean haveLauncherPid = false;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    95
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    96
            // === Run the tests ===
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    97
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    98
            // ---Test 1a
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
    99
            tr = doExec(envMap,javaCmd, "-XX:NativeMemoryTracking=" + NMT_Option_Value,
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   100
                        "-version");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   101
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   102
            // get the PID from the env var we set for the JVM
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   103
            String envVarPid = null;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   104
            for (String line : tr.testOutput) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   105
                if (line.contains(envVarPidString)) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   106
                    int sindex = envVarPidString.length();
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   107
                    envVarPid = line.substring(sindex);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   108
                    break;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   109
                }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   110
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   111
            // did we find envVarPid?
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   112
            if (envVarPid == null) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   113
                System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   114
                throw new RuntimeException("Error: failed to find env Var Pid in tracking info");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   115
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   116
            // we think we found the pid string.  min test, not "".
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   117
            if (envVarPid.length() < 1) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   118
                System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   119
                throw new RuntimeException("Error: env Var Pid in tracking info is empty string");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   120
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   121
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   122
            /*
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   123
             * On Linux, Launcher Tracking will print the PID.  Use this info
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   124
             * to validate what we got as the PID in the Launcher itself.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   125
             * Linux is the only one that prints this, and trying to get it
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   126
             * here for win is awful.  So let the linux test make sure we get
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   127
             * the valid pid, and for non-linux, just make sure pid string is
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   128
             * non-zero.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   129
             */
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   130
            if (isLinux) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   131
                // get what the test says is the launcher pid
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   132
                String launcherPid = null;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   133
                for (String line : tr.testOutput) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   134
                    int index = line.indexOf(launcherPidString);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   135
                    if (index >= 0) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   136
                        int sindex = index + launcherPidString.length();
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   137
                        int tindex = sindex + line.substring(sindex).indexOf("'");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   138
                        System.out.println("DEBUG INFO: sindex = " + sindex);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   139
                        System.out.println("DEBUG INFO: searching substring: " + line.substring(sindex));
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   140
                        System.out.println("DEBUG INFO: tindex = " + tindex);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   141
                        // DEBUG INFO
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   142
                        System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   143
                        launcherPid = line.substring(sindex, tindex);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   144
                        break;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   145
                    }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   146
                }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   147
                if (launcherPid == null) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   148
                    System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   149
                    throw new RuntimeException("Error: failed to find launcher Pid in launcher tracking info");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   150
                }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   151
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   152
                // did we create the env var with the correct pid?
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   153
                if (!launcherPid.equals(envVarPid)) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   154
                    System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   155
                    System.out.println("Error: wrong pid in creating env var");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   156
                    System.out.println("Error Info: launcherPid = " + launcherPid);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   157
                    System.out.println("Error Info: envVarPid   = " + envVarPid);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   158
                    throw new RuntimeException("Error: wrong pid in creating env var");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   159
                }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   160
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   161
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   162
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   163
            // --- Test 1b
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   164
            if (!tr.contains("NativeMemoryTracking: got value " + NMT_Option_Value)) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   165
                System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   166
                throw new RuntimeException("Error: Valid param failed to set env variable");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   167
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   168
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   169
            // --- Test 2
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   170
            tr = doExec(envMap,javaCmd, "-XX:NativeMemoryTracking=",
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   171
                        "-version");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   172
            if (tr.contains("NativeMemoryTracking:")) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   173
                System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   174
                throw new RuntimeException("Error: invalid param caused env variable to be erroneously created");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   175
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   176
            if (!tr.contains("Syntax error, expecting -XX:NativeMemoryTracking=")) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   177
                System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   178
                throw new RuntimeException("Error: invalid param not checked by JVM");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   179
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   180
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   181
            // --- Test 3
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   182
            tr = doExec(envMap,javaCmd, "-XX:NativeMemoryTracking",
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   183
                        "-version");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   184
            if (tr.contains("NativeMemoryTracking:")) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   185
                System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   186
                throw new RuntimeException("Error: invalid param caused env variable to be erroneously created");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   187
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   188
            if (!tr.contains("Syntax error, expecting -XX:NativeMemoryTracking=")) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   189
                System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   190
                throw new RuntimeException("Error: invalid param not checked by JVM");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   191
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   192
            // --- Test 4
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   193
            tr = doExec(envMap,javaCmd, "-XX:NativeMemoryTracking=BADVALUE",
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   194
                        "-version");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   195
            if (!tr.contains("expecting -XX:NativeMemoryTracking")) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   196
                System.out.println(tr);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   197
                throw new RuntimeException("Error: invalid param did not get JVM Syntax error message");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   198
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   199
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   200
        } // NativeMemoryTracking
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   201
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 12527
diff changeset
   202
12527
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   203
        // MacOSX specific tests ensue......
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   204
        if (!isMacOSX)
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   205
            return;
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   206
        Set<String> envToRemove = new HashSet<>();
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   207
        Map<String, String> map = System.getenv();
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   208
        for (String s : map.keySet()) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   209
            if (s.startsWith("JAVA_MAIN_CLASS_")
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   210
                    || s.startsWith("APP_NAME_")
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   211
                    || s.startsWith("APP_ICON_")) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   212
                envToRemove.add(s);
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   213
            }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   214
        }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   215
        runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   216
                "EnvironmentVariables", "JAVA_MAIN_CLASS_*",
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   217
                "EnvironmentVariables");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   218
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   219
        runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   220
                "-Xdock:name=TestAppName", "EnvironmentVariables",
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   221
                "APP_NAME_*", "TestAppName");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   222
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   223
        runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   224
                "-Xdock:icon=TestAppIcon", "EnvironmentVariables",
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   225
                "APP_ICON_*", "TestAppIcon");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   226
    }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   227
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   228
    static void runTest(Set<String> envToRemove, String... args) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   229
        TestResult tr = doExec(null, envToRemove, args);
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   230
        if (!tr.isOK()) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   231
            System.err.println(tr.toString());
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   232
            throw new RuntimeException("Test Fails");
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   233
        }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   234
    }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
diff changeset
   235
}