comparison src/tests/gov/nasa/jpf/test/vm/threads/LockedStackDepthTest.java @ 0:61d41facf527

initial v8 import (history reset)
author Peter Mehlitz <Peter.C.Mehlitz@nasa.gov>
date Fri, 23 Jan 2015 10:14:01 -0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:61d41facf527
1 /*
2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
4 * All rights reserved.
5 *
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0.
11 *
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.
17 */
18
19 package gov.nasa.jpf.test.vm.threads;
20
21 import gov.nasa.jpf.util.test.TestJPF;
22 import gov.nasa.jpf.vm.Verify;
23
24 import org.junit.Test;
25
26 /**
27 * Tests the functionality of gov.nasa.jpf.listener.LockedStackDepth
28 *
29 * It would be very difficult to put asserts in the test. Hence, asserts are
30 * added to LockedStackDepth.
31 *
32 * Run all of the JPF tests with
33 * listener+=,gov.nasa.jpf.listener.LockedStackDepth to take advantage of the
34 * various tests.
35 */
36 public class LockedStackDepthTest extends TestJPF {
37
38 private static final String LISTENER = "+listener+=,.listener.LockedStackDepth";
39
40 @Test
41 public void recursiveLock() {
42 if (verifyNoPropertyViolation(LISTENER)) {
43 synchronized (this) {
44 synchronized (this) {
45 }
46 }
47 }
48 }
49
50 @Test
51 public void waitRetainsDepth() throws InterruptedException {
52 if (verifyNoPropertyViolation(LISTENER)) {
53 synchronized (this) {
54 synchronized (this) {
55 wait(1);
56 }
57 }
58 }
59 }
60
61 @Test
62 public void breadthFirstSearch() throws InterruptedException {
63 if (verifyNoPropertyViolation(LISTENER, "+search.class=gov.nasa.jpf.search.heuristic.BFSHeuristic")) {
64 synchronized (this) {
65 synchronized (this) {
66 wait(1);
67 }
68 }
69 }
70 }
71
72 @Test
73 public void randomHeuristicSearch() throws InterruptedException {
74 if (verifyNoPropertyViolation(LISTENER, "+search.class=gov.nasa.jpf.search.heuristic.RandomHeuristic")) {
75 synchronized (this) {
76 synchronized (this) {
77 wait(1);
78 }
79 }
80 }
81 }
82
83 @Test
84 public void hitSameStateThroughDifferentSearchPaths() {
85 if (verifyNoPropertyViolation(LISTENER)) {
86 Verify.getBoolean();
87
88 synchronized (this) {
89 }
90
91 Verify.getBoolean();
92 }
93 }
94 }