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.
19 package gov.nasa.jpf.util.test;
21 import gov.nasa.jpf.Config;
22 import gov.nasa.jpf.Property;
23 import gov.nasa.jpf.util.TypeRef;
24 import gov.nasa.jpf.vm.NotDeadlockedProperty;
27 * @author Nastaran Shafiei <nastaran.shafiei@gmail.com>
29 * This is a root class for testing multi-processes code. This forces
30 * JPF to use MultiProcessVM and DistributedSchedulerFactory
32 public abstract class TestMultiProcessJPF extends TestJPF {
36 protected void setTestTargetKeys(Config conf, StackTraceElement testMethod) {
37 conf.put("target.entry", "runTestMethod([Ljava/lang/String;)V");
38 conf.put("target.replicate", Integer.toString(numOfPrc));
39 conf.put("target", testMethod.getClassName());
40 conf.put("target.test_method", testMethod.getMethodName());
41 conf.put("vm.class", "gov.nasa.jpf.vm.MultiProcessVM");
42 conf.put("vm.scheduler_factory.class", "gov.nasa.jpf.vm.DistributedSchedulerFactory");
45 protected native int getProcessId();
47 protected boolean mpVerifyAssertionErrorDetails (int prcNum, String details, String... args){
52 unhandledException( getCaller(), "java.lang.AssertionError", details, args);
57 protected boolean mpVerifyAssertionError (int prcNum, String... args){
62 unhandledException( getCaller(), "java.lang.AssertionError", null, args);
67 protected boolean mpVerifyNoPropertyViolation (int prcNum, String...args){
72 noPropertyViolation(getCaller(), args);
77 protected boolean mpVerifyUnhandledExceptionDetails (int prcNum, String xClassName, String details, String... args){
82 unhandledException( getCaller(), xClassName, details, args);
87 protected boolean mpVerifyUnhandledException (int prcNum, String xClassName, String... args){
92 unhandledException( getCaller(), xClassName, null, args);
97 protected boolean mpVerifyJPFException (int prcNum, TypeRef xClsSpec, String... args){
104 Class<? extends Throwable> xCls = xClsSpec.asNativeSubclass(Throwable.class);
106 jpfException( getCaller(), xCls, args);
108 } catch (ClassCastException ccx){
109 fail("not a property type: " + xClsSpec);
110 } catch (ClassNotFoundException cnfx){
111 fail("property class not found: " + xClsSpec);
117 protected boolean mpVerifyPropertyViolation (int prcNum, TypeRef propertyClsSpec, String... args){
124 Class<? extends Property> propertyCls = propertyClsSpec.asNativeSubclass(Property.class);
125 propertyViolation( getCaller(), propertyCls, args);
127 } catch (ClassCastException ccx){
128 fail("not a property type: " + propertyClsSpec);
129 } catch (ClassNotFoundException cnfx){
130 fail("property class not found: " + propertyClsSpec);
136 protected boolean mpVerifyDeadlock (int prcNum, String... args){
141 propertyViolation( getCaller(), NotDeadlockedProperty.class, args);