Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/klass/class001/class001.java
40955 views
/*1* Copyright (c) 2002, 2020, 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*/2223/*24* @test25*26* @summary converted from VM Testbase nsk/jdb/class/class001.27* VM Testbase keywords: [jpda, jdb]28* VM Testbase readme:29* DECSRIPTION30* A positive test case for the 'class <class_id>' command.31* The test checks if jdb correctly replies on request for32* given debuggee class via 'class' command.33* The test fails if :34* - string "is not a valid" found in reply,35* - reply does not contain full name of a checked class.36* Otherwise the test passes.37* COMMENTS38*39* @library /vmTestbase40* /test/lib41* @build nsk.jdb.klass.class001.class001a42* @run main/othervm43* nsk.jdb.klass.class001.class00144* -arch=${os.family}-${os.simpleArch}45* -waittime=546* -debugee.vmkind=java47* -transport.address=dynamic48* -jdb=${test.jdk}/bin/jdb49* -java.options="${test.vm.opts} ${test.java.opts}"50* -workdir=.51* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"52*/5354package nsk.jdb.klass.class001;5556import nsk.share.*;57import nsk.share.jdb.*;5859import java.io.*;60import java.util.*;6162public class class001 extends JdbTest {6364public static void main (String argv[]) {65System.exit(run(argv, System.out) + JCK_STATUS_BASE);66}6768public static int run(String argv[], PrintStream out) {69debuggeeClass = DEBUGGEE_CLASS;70firstBreak = FIRST_BREAK;71lastBreak = LAST_BREAK;72return new class001().runTest(argv, out);73}7475static final String PACKAGE_NAME = "nsk.jdb.klass.class001";76static final String TEST_CLASS = PACKAGE_NAME + ".class001";77static final String DEBUGGEE_CLASS = TEST_CLASS + "a";78static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";79static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";80static final String NOT_VALID_SAMPLE = "is not a valid";8182static String[] checkedClasses = {83DEBUGGEE_CLASS,84DEBUGGEE_CLASS + "$InnerInt1",85DEBUGGEE_CLASS + "$Inner2",86DEBUGGEE_CLASS + "$Inner3",87DEBUGGEE_CLASS + "$Inner4",88DEBUGGEE_CLASS + "$Inner5",89DEBUGGEE_CLASS + "$Inner6",90PACKAGE_NAME + ".Outer1"91};9293/* ------------------------------------- */9495protected void runCases() {96String[] reply;97Paragrep grep;98int count;99Vector v;100String found;101102jdb.setBreakpointInMethod(LAST_BREAK);103reply = jdb.receiveReplyFor(JdbCommand.cont);104105for (int i = 0; i < checkedClasses.length; i++) {106if (!checkClass(checkedClasses[i])) {107success = false;108}109}110111jdb.contToExit(1);112}113114private boolean checkClass (String className) {115String[] reply;116Paragrep grep;117int count;118String found;119boolean result = true;120121reply = jdb.receiveReplyFor(JdbCommand._class + className);122123grep = new Paragrep(reply);124found = grep.findFirst(NOT_VALID_SAMPLE);125if (found.length() > 0) {126log.complain("Failed to report class " + className);127result = false;128}129found = grep.findFirst(className);130if (found.length() == 0) {131log.complain("Failed to report class " + className);132result = false;133}134return result;135}136}137138139