Path: blob/master/test/jdk/com/sun/jdi/DataModelTest.java
41149 views
/*1* Copyright (c) 2001, 2002, 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* @ test:it only runs from SparcToSparcV9Test.sh25* @bug 447831226* @summary Test debugging with mixed 32/64bit VMs.27*28* @author Tim Bell29*30* The basic version of this test (32-bit to 32-bit) should pass31* on all platforms. The SparcToSparcv9Test.sh script uses this32* test to exercise other combinations on SPARC v9 platforms only.33*34* @run build TestScaffold VMConnection TargetListener TargetAdapter35* @run compile -g DataModelTest.java36* @run driver DataModelTest37*/38import com.sun.jdi.*;39import com.sun.jdi.event.*;40import com.sun.jdi.request.*;4142import java.util.*;4344/********** target program **********/4546class DataModelTarg {47static String dataModel;48public DataModelTarg () {49dataModel = System.getProperty("sun.arch.data.model");50}51public void ready () {52System.out.println("sun.arch.data.model is: " + dataModel);53}54public static void main(String[] args){55System.out.println("Howdy!");56DataModelTarg my = new DataModelTarg();57my.ready();58System.out.println("Goodbye from DataModelTarg!");59}60}6162/********** test program **********/6364public class DataModelTest extends TestScaffold {6566DataModelTest (String args[]) {67super(args);68}6970public static void main(String[] args) throws Exception {71new DataModelTest(args).startTests();72}7374protected void runTests() throws Exception {75/*76* Get to the top of ready()77*/78BreakpointEvent bpe = startTo("DataModelTarg", "ready", "()V");7980ObjectReference targetObject = bpe.thread().frame(0).thisObject();81ReferenceType rt = targetObject.referenceType();82Field field = rt.fieldByName("dataModel");83Value v = targetObject.getValue(field);84StringReference sv = (StringReference) v;85String expectedValue = System.getProperty("EXPECTED", "32");86if (!expectedValue.equals(sv.value())) {87failure("Expecting sun.arch.data.model = " + expectedValue +88" but got " + sv.value() + " instead.");89}90/*91* resume the target listening for events92*/93listenUntilVMDisconnect();9495/*96* deal with results of test97* if anything has called failure("foo") testFailed will be true98*/99if (!testFailed) {100println("DataModelTest: passed");101} else {102throw new Exception("DataModelTest: failed");103}104}105}106107108