2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package gov.nasa.jpf.test.mc.basic;
20 import gov.nasa.jpf.ListenerAdapter;
21 import gov.nasa.jpf.util.test.TestJPF;
22 import gov.nasa.jpf.vm.ChoiceGenerator;
23 import gov.nasa.jpf.vm.Instruction;
24 import gov.nasa.jpf.vm.ThreadInfo;
25 import gov.nasa.jpf.vm.VM;
26 import gov.nasa.jpf.vm.choice.BreakGenerator;
27 import org.junit.Test;
30 * JPF regression test for breaking transitions when exceeding
31 * vm.max_transition_length. While the program would not terminate outside
32 * JPF, it will terminate when run under JPF because of state matching
34 * the listener is purely informative - if the test fails it doesn't terminate.
35 * It should report two registrations within the loop, the second one matching
36 * the state that was stored after the first one. However, the number of
37 * transition breaks might change with more sophisticated loop detection
39 public class TransitionLengthTest extends TestJPF {
41 public static class Listener extends ListenerAdapter {
43 public void choiceGeneratorRegistered (VM vm, ChoiceGenerator<?> nextCG, ThreadInfo currentThread, Instruction executedInstruction) {
44 if (nextCG instanceof BreakGenerator){
46 System.out.println("registered: " + nextCG);
52 public void testTermination(){
53 if (verifyNoPropertyViolation("+vm.max_transition_length=500",
54 "+listener=" + TransitionLengthTest.class.getName() + "$Listener")){
55 System.out.println("starting loop");
57 // no program state change withing body - this should eventually run into state matching
58 System.out.print(".");
60 // we can never get here outside of JPF