Path: blob/master/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java
41155 views
/*1* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import jdk.test.lib.process.OutputAnalyzer;24import jdk.test.lib.dcmd.CommandExecutor;25import jdk.test.lib.dcmd.PidJcmdExecutor;26import jdk.test.lib.dcmd.MainClassJcmdExecutor;27import jdk.test.lib.dcmd.FileJcmdExecutor;28import jdk.test.lib.dcmd.JMXExecutor;29import nsk.share.jdi.ArgumentHandler;3031import org.testng.annotations.Test;3233/*34* @test35* @bug 822173036* @summary Test of diagnostic command VM.version (tests all DCMD executors)37* @library /test/lib38* /vmTestbase39* @modules java.base/jdk.internal.misc40* java.base/jdk.internal.module41* java.compiler42* java.management43* jdk.internal.jvmstat/sun.jvmstat.monitor44* @run testng/othervm -XX:+UsePerfData VMVersionTest45*/46public class VMVersionTest {4748private static final String TEST_PROCESS_CLASS_NAME = process.TestJavaProcess.class.getName();4950public void run(CommandExecutor executor) {51OutputAnalyzer output = executor.execute("VM.version");52output.shouldMatch(".*(?:HotSpot|OpenJDK).*VM.*");53}5455@Test56public void pid() {57run(new PidJcmdExecutor());58}5960@Test61public void mainClass() {62TestProcessLauncher t = new TestProcessLauncher(TEST_PROCESS_CLASS_NAME);63try {64t.launch();65run(new MainClassJcmdExecutor(TEST_PROCESS_CLASS_NAME));66} finally {67t.quit();68}69}7071@Test72public void mainClassForJar() {73TestProcessJarLauncher t = new TestProcessJarLauncher(TEST_PROCESS_CLASS_NAME);74try {75t.launch();76String jarFile = t.getJarFile();77run(new MainClassJcmdExecutor(jarFile));78} finally {79t.quit();80}81}8283@Test84public void mainClassForModule() {85TestProcessModuleLauncher t = new TestProcessModuleLauncher(TEST_PROCESS_CLASS_NAME);86try {87t.launch();88String moduleName = t.getModuleName();89run(new MainClassJcmdExecutor(moduleName));90} finally {91t.quit();92}93}9495@Test96public void file() {97run(new FileJcmdExecutor());98}99100@Test101public void jmx() {102run(new JMXExecutor());103}104105}106107108