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.data;
20 import gov.nasa.jpf.util.test.TestJPF;
21 import gov.nasa.jpf.vm.Verify;
23 import org.junit.Test;
26 * regression test for TimeModel implementations
28 public class TimeModelTest extends TestJPF {
31 public void testSystemTime(){
33 if (verifyNoPropertyViolation("+vm.time.class=.vm.SystemTime")){
34 long t1 = System.currentTimeMillis();
35 System.out.printf("t1 = %d\n", t1);
37 boolean b2 = Verify.getBoolean();
38 long t2 = System.currentTimeMillis();
39 System.out.printf(" t2 = %d\n", t2);
41 boolean b3 = Verify.getBoolean();
42 long t3 = System.currentTimeMillis();
43 System.out.printf(" t3 = %d\n", t3);
45 assertTrue((t3 >= t2) && (t2 >= t1));
50 public void testPathTime(){
53 Verify.resetCounter(0);
54 Verify.resetCounter(1);
57 if (verifyNoPropertyViolation("+vm.time.class=.vm.ConstInsnPathTime")){
58 long t1 = System.currentTimeMillis();
59 System.out.printf("t1 = %d\n", t1);
61 boolean b2 = Verify.getBoolean(true); // we do falseFirst
62 long t2 = System.currentTimeMillis();
63 System.out.printf(" t2 = %d\n", t2);
65 if (b2){ // has to be second time around
66 assertTrue(t2 == Verify.getCounter(0));
68 Verify.setCounter(0,(int)t2);
72 boolean b3 = Verify.getBoolean(true); // store the result so that we don't state match
73 long t3 = System.currentTimeMillis();
74 System.out.printf(" t3 = %d\n", t3);
76 if (b3){ // has to be second time around
77 assertTrue(t3 == Verify.getCounter(1));
79 Verify.setCounter(1,(int)t3);
82 assertTrue((t3 > t2) && (t2 > t1));