jdk/test/com/sun/jdi/PopSynchronousTest.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 24973 8c4bc3fa4c4e
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *  @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 *  @bug 4467564
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *  @summary Test the popping of frames in synchronous context
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *           (that is, when stopped at an event)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *  @author Robert Field
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *  @run build TestScaffold VMConnection TargetListener TargetAdapter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *  @run compile -g PopSynchronousTest.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *  @run main PopSynchronousTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    /********** target program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
class PopSynchronousTarg {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static String s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    static PopSynchronousTarg sole;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    synchronized void a(int y, boolean w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        if (y == 6 && w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            s += "@";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            s += " aArgFail ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    String b(String h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        if (h.equals("yo")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            s += "[";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            s += " bArgFail ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        a(6, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        s += "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        return s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    long c() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        s += "<";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        synchronized (s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            b("yo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        s += ">";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        return 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    static void p() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        s += "(";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if (sole.c() != 17) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            s += " cReturnFail ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        s += ")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    static void report() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public static void main(String[] args){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        s = new String();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        sole = new PopSynchronousTarg();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        for (int i = 0; i < 100; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            p();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            // System.out.println(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            report();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /********** test program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
public class PopSynchronousTest extends TestScaffold {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    ReferenceType targetClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    ThreadReference mainThread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    int stateIndex = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    String expected = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    static final String[] calls =  {"a", "b", "c", "p", "main"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    static final int popMax = calls.length - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    static final String[] states =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    {"main-i", "p-e", "p-i", "c-e", "c-i", "b-e", "b-i", "a-e", "a-l", "b-l", "c-l", "p-l", "main-r", "report-e"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    static final String[] output =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    {"",       "",    "(",   "",    "<",   "",    "[",   "",    "@",   "]",   ">",   ")",   "",       ""};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    PopSynchronousTest (String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        super(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public static void main(String[] args)      throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        new PopSynchronousTest(args).startTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /********** test assist **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    StackFrame frameFor(String methodName) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        Iterator it = mainThread.frames().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        while (it.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            StackFrame frame = (StackFrame)it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            if (frame.location().method().name().equals(methodName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                return frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        failure("FAIL: " + methodName + " not on stack");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    String actual() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        Field field = targetClass.fieldByName("s");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        StringReference sr = (StringReference)(targetClass.getValue(field));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        return sr.value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    void checkExpected() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        if (!actual().equals(expected)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            failure("FAIL: expected value: " + expected +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                    " got: " + actual());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    int methodIndex(String methodName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        for (int i = 0; i < popMax; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            if (methodName.equals(calls[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                return i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    boolean isTop(String methodName) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return mainThread.frame(0).location().method().name().equals(methodName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    void checkTop(String methodName, boolean atStart) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        Location loc = mainThread.frame(0).location();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        Method meth = loc.method();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        String name = meth.name();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        if (!isTop(methodName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            failure("FAIL: expected " + methodName +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    " at top of stack, instead: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        } else if ((meth.location().codeIndex() == loc.codeIndex()) != atStart) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            failure("FAIL: not at expect position: " + loc.codeIndex());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    void checkState() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        String name = states[stateIndex];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        int dash = name.indexOf('-');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        String methodName = name.substring(0,dash);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        String posName = name.substring(dash+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        checkTop(methodName, posName.equals("e"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        checkExpected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    void incrementState() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        stateIndex = (stateIndex + 1) % (states.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    void resetState(String stateName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        for (int i=0; i < states.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            if (states[i].equals(stateName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                stateIndex = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        failure("TEST FAILURE: cannot find state: " + stateName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    void resetExpected() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        println("Current value: " + actual());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        Field field = targetClass.fieldByName("s");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        expected = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        ((ClassType)targetClass).setValue(field, vm().mirrorOf(expected));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    void stateTo(String stateName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            incrementState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            expected += output[stateIndex];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        } while(!states[stateIndex].equals(stateName));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    void resumeTo(String methodName) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        List meths = targetClass.methodsByName(methodName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        Method meth = (Method)(meths.get(0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        resumeTo(meth.location());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        stateTo(methodName + "-e");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    void pop(String methodName) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        mainThread.popFrames(frameFor(methodName));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        resetState(methodName + "-e");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        --stateIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    void reenter(String methodName) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        pop(methodName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        stepIntoInstruction(mainThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        incrementState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    /********** test core **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    protected void runTests() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
         * Get to the top of main()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
         * to determine targetClass and mainThread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        BreakpointEvent bpe = startToMain("PopSynchronousTarg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        targetClass = bpe.location().declaringType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        mainThread = bpe.thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
         * Testing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        /* individual tests */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        for (int i = 0; i < popMax; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            String from = calls[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            for (int j = i; j < popMax; ++j) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                String to = calls[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                String prev = calls[j+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                println("TEST pop from '" + from + "' to '" + to + "'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                resumeTo(from);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                reenter(to);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                resumeTo("report");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                resetExpected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        /* sequential tests */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        println("TEST pop a b c p");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        resumeTo("a");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        pop("a");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        pop("b");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        pop("c");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        pop("p");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        resumeTo("report");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        resetExpected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        println("TEST pop a c p");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        resumeTo("a");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        pop("a");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        pop("c");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        pop("p");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        resumeTo("report");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        resetExpected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        println("TEST stress a");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        resumeTo("a");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        for (int i = 0; i < 100; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            reenter("a");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        resumeTo("report");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        resetExpected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        println("TEST stress c");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        resumeTo("c");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        for (int i = 0; i < 100; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            reenter("c");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        resumeTo("report");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        resetExpected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
         * we are done, get rid of target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        vm().dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
         * deal with results of test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
         * if anything has called failure("foo") testFailed will be true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        if (!testFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            println("PopSynchronousTest: passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            throw new Exception("PopSynchronousTest: failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
}