test/lib-test/jdk/test/lib/apps/LingeredAppTest.java
author rriggs
Wed, 02 Oct 2019 13:57:03 -0400
changeset 58446 5c83830390ba
parent 31011 74f74963b502
permissions -rw-r--r--
8231663: Incorrect GPL header in some RMI/SQL package-info.java files Reviewed-by: bpb, iris, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31011
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     1
/*
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     4
 *
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     7
 * published by the Free Software Foundation.
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     8
 *
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    13
 * accompanied this code).
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    14
 *
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    18
 *
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    21
 * questions.
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    22
 */
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    23
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    24
/*
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    25
 * @test
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    26
 * @summary Unit test for LingeredApp
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    27
 * @compile LingeredAppTest.java
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    28
 * @compile LingeredApp.java
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    29
 * @run main LingeredAppTest
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    30
 */
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    31
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    32
package jdk.test.lib.apps;
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    33
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    34
import java.io.IOException;
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    35
import java.util.ArrayList;
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    36
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    37
public class LingeredAppTest {
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    38
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    39
    public static void main(String[] args) {
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    40
        try {
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    41
            System.out.println("Starting LingeredApp with default parameters");
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    42
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    43
            ArrayList<String> cmd = new ArrayList<String>();
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    44
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    45
            // Propagate test.vm.options to LingeredApp, filter out possible empty options
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    46
            String testVmOpts[] = System.getProperty("test.vm.opts","").split("\\s+");
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    47
            for (String s : testVmOpts) {
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    48
                if (!s.equals("")) {
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    49
                    cmd.add(s);
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    50
                }
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    51
            }
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    52
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    53
            cmd.add("-XX:+PrintFlagsFinal");
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    54
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    55
            LingeredApp a = LingeredApp.startApp(cmd);
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    56
            System.out.printf("App pid: %d\n", a.getPid());
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    57
            a.stopApp();
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    58
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    59
            System.out.println("App output:");
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    60
            int count = 0;
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    61
            for (String line : a.getAppOutput()) {
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    62
                count += 1;
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    63
            }
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    64
            System.out.println("Found " + count + " lines in VM output");
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    65
            System.out.println("Test PASSED");
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    66
        } catch (IOException ex) {
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    67
            ex.printStackTrace();
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    68
            System.out.println("Test ERROR");
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    69
            System.exit(3);
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    70
        }
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    71
    }
74f74963b502 8081037: serviceability/sa/ tests time out on Windows
ykantser
parents:
diff changeset
    72
}