Mercurial > hg > truffle
annotate test/serviceability/dcmd/DynLibDcmdTest.java @ 14513:16c705d792be
Merge
author | morris |
---|---|
date | Fri, 28 Feb 2014 08:02:20 -0800 |
parents | afa21611f918 |
children |
rev | line source |
---|---|
14246
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
1 import java.util.HashSet; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
2 import java.util.Set; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
3 import com.oracle.java.testlibrary.Platform; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
4 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
5 /* |
afa21611f918
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. |
afa21611f918
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. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
8 * |
afa21611f918
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 |
afa21611f918
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 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
11 * published by the Free Software Foundation. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
12 * |
afa21611f918
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 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
afa21611f918
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 |
afa21611f918
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 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
17 * accompanied this code). |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
18 * |
afa21611f918
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 |
afa21611f918
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, |
afa21611f918
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. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
22 * |
afa21611f918
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 |
afa21611f918
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 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
25 * questions. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
26 */ |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
27 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
28 /* |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
29 * @test |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
30 * @summary Test of VM.dynlib diagnostic command via MBean |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
31 * @library /testlibrary |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
32 * @compile DcmdUtil.java |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
33 * @run main DynLibDcmdTest |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
34 */ |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
35 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
36 public class DynLibDcmdTest { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
37 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
38 public static void main(String[] args) throws Exception { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
39 String result = DcmdUtil.executeDcmd("VM.dynlibs"); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
40 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
41 String osDependentBaseString = null; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
42 if (Platform.isSolaris()) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
43 osDependentBaseString = "lib%s.so"; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
44 } else if (Platform.isWindows()) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
45 osDependentBaseString = "%s.dll"; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
46 } else if (Platform.isOSX()) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
47 osDependentBaseString = "lib%s.dylib"; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
48 } else if (Platform.isLinux()) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
49 osDependentBaseString = "lib%s.so"; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
50 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
51 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
52 if (osDependentBaseString == null) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
53 throw new Exception("Unsupported OS"); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
54 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
55 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
56 Set<String> expectedContent = new HashSet<>(); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
57 expectedContent.add(String.format(osDependentBaseString, "jvm")); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
58 expectedContent.add(String.format(osDependentBaseString, "java")); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
59 expectedContent.add(String.format(osDependentBaseString, "management")); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
60 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
61 for(String expected : expectedContent) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
62 if (!result.contains(expected)) { |
afa21611f918
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 + "'"); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
64 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
65 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
66 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
67 } |