1 import org.testng.annotations.Test; 2 import org.testng.Assert; 3 4 import jdk.test.lib.OutputAnalyzer; 5 import jdk.test.lib.Platform; 6 import jdk.test.lib.dcmd.CommandExecutor; 7 import jdk.test.lib.dcmd.JMXExecutor; 8 9 /* 10 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. 11 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12 * 13 * This code is free software; you can redistribute it and/or modify it 14 * under the terms of the GNU General Public License version 2 only, as 15 * published by the Free Software Foundation. 16 * 17 * This code is distributed in the hope that it will be useful, but WITHOUT 18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 * version 2 for more details (a copy is included in the LICENSE file that 21 * accompanied this code). 22 * 23 * You should have received a copy of the GNU General Public License version 24 * 2 along with this work; if not, write to the Free Software Foundation, 25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26 * 27 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 28 * or visit www.oracle.com if you need additional information or have any 29 * questions. 30 */ 31 32 /* 33 * @test 34 * @summary Test of VM.dynlib diagnostic command via MBean 35 * @library /testlibrary 36 * @modules java.base/jdk.internal.misc 37 * java.compiler 38 * java.management 39 * jdk.jvmstat/sun.jvmstat.monitor 40 * @build jdk.test.lib.* 41 * @build jdk.test.lib.dcmd.* 42 * @run testng DynLibsTest 43 */ 44 45 public class DynLibsTest { 46 47 public void run(CommandExecutor executor) { 48 OutputAnalyzer output = executor.execute("VM.dynlibs"); 49 50 String osDependentBaseString = null; 51 if (Platform.isAix()) { 52 osDependentBaseString = "lib%s.so"; 53 } else if (Platform.isLinux()) { 54 osDependentBaseString = "lib%s.so"; 55 } else if (Platform.isOSX()) { 56 osDependentBaseString = "lib%s.dylib"; 57 } else if (Platform.isSolaris()) { 58 osDependentBaseString = "lib%s.so"; 59 } else if (Platform.isWindows()) { 60 osDependentBaseString = "%s.dll"; 61 } 62 63 if (osDependentBaseString == null) { 64 Assert.fail("Unsupported OS"); 65 } 66 67 output.shouldContain(String.format(osDependentBaseString, "jvm")); 68 output.shouldContain(String.format(osDependentBaseString, "java")); 69 output.shouldContain(String.format(osDependentBaseString, "management")); 70 } 71 72 @Test 73 public void jmx() { 74 run(new JMXExecutor()); 75 } 76 }