hotspot/test/serviceability/dcmd/DynLibDcmdTest.java
author iignatyev
Sat, 19 Jul 2014 00:34:20 +0400
changeset 25736 6f35dbe32581
parent 24835 be963975e2f7
child 28489 f395f4b55ea1
permissions -rw-r--r--
8032449: Get rid of JMX in test/compiler Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     1
import java.util.HashSet;
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     2
import java.util.Set;
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     3
import com.oracle.java.testlibrary.Platform;
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     4
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     5
/*
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     6
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     7
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     8
 *
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
     9
 * This code is free software; you can redistribute it and/or modify it
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    10
 * under the terms of the GNU General Public License version 2 only, as
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    11
 * published by the Free Software Foundation.
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    12
 *
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    13
 * This code is distributed in the hope that it will be useful, but WITHOUT
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    15
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    16
 * version 2 for more details (a copy is included in the LICENSE file that
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    17
 * accompanied this code).
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    18
 *
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    19
 * You should have received a copy of the GNU General Public License version
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    20
 * 2 along with this work; if not, write to the Free Software Foundation,
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    21
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    22
 *
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    23
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    24
 * or visit www.oracle.com if you need additional information or have any
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    25
 * questions.
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    26
 */
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    27
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    28
/*
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    29
 * @test
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    30
 * @summary Test of VM.dynlib diagnostic command via MBean
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    31
 * @library /testlibrary
24835
be963975e2f7 8043915: Tests get ClassNotFoundException: com.oracle.java.testlibrary.StreamPumper
ykantser
parents: 22490
diff changeset
    32
 * @build com.oracle.java.testlibrary.* DcmdUtil
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    33
 * @run main DynLibDcmdTest
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    34
 */
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    35
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    36
public class DynLibDcmdTest {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    37
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    38
    public static void main(String[] args) throws Exception {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    39
        String result = DcmdUtil.executeDcmd("VM.dynlibs");
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    40
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    41
        String osDependentBaseString = null;
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    42
        if (Platform.isSolaris()) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    43
            osDependentBaseString = "lib%s.so";
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    44
        } else if (Platform.isWindows()) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    45
            osDependentBaseString = "%s.dll";
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    46
        } else if (Platform.isOSX()) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    47
            osDependentBaseString = "lib%s.dylib";
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    48
        } else if (Platform.isLinux()) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    49
            osDependentBaseString = "lib%s.so";
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    50
        }
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    51
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    52
        if (osDependentBaseString == null) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    53
            throw new Exception("Unsupported OS");
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    54
        }
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    55
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    56
        Set<String> expectedContent = new HashSet<>();
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    57
        expectedContent.add(String.format(osDependentBaseString, "jvm"));
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    58
        expectedContent.add(String.format(osDependentBaseString, "java"));
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    59
        expectedContent.add(String.format(osDependentBaseString, "management"));
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    60
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    61
        for(String expected : expectedContent) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    62
            if (!result.contains(expected)) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    63
                throw new Exception("Dynamic library list output did not contain the expected string: '" + expected + "'");
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    64
            }
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    65
        }
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    66
    }
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff changeset
    67
}