lab4
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lab4 [2017/01/27 20:11] – franck | lab4 [2018/01/23 02:56] (current) – franck | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== LAB 4 ====== | + | ~~NOTOC~~ |
+ | |||
+ | ====== LAB 3 ====== | ||
====== Listeners ====== | ====== Listeners ====== | ||
Line 67: | Line 69: | ||
* vt.methods | * vt.methods | ||
- | To receive feedback, submit your work as a text file using the submit command before | + | To receive feedback, submit your work as a text file using the submit command before |
- | submit 4315 lab4 <name of the listener> | + | submit 4315 lab3 <name of the listener> |
====== Sample ====== | ====== Sample ====== | ||
Line 83: | Line 85: | ||
To illustrate the BudgetChecker listener, we consider the following app. | To illustrate the BudgetChecker listener, we consider the following app. | ||
+ | <code java> | ||
import java.util.ArrayList; | import java.util.ArrayList; | ||
import java.util.List; | import java.util.List; | ||
Line 96: | Line 99: | ||
} | } | ||
} | } | ||
+ | </ | ||
We can run the listener BudgetChecker without setting any of its properties | We can run the listener BudgetChecker without setting any of its properties | ||
and, hence, not setting any constraints, | and, hence, not setting any constraints, | ||
+ | < | ||
target=Constraints | target=Constraints | ||
classpath=. | classpath=. | ||
cg.enumerate_random=true | cg.enumerate_random=true | ||
listener=gov.nasa.jpf.listener.BudgetChecker | listener=gov.nasa.jpf.listener.BudgetChecker | ||
+ | </ | ||
In this case, no constraints are set. As a result, JPF will run out of memory producing | In this case, no constraints are set. As a result, JPF will run out of memory producing | ||
the following output | the following output | ||
+ | < | ||
JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
Line 116: | Line 123: | ||
====================================================== search started: 1/27/17 1:01 PM | ====================================================== search started: 1/27/17 1:01 PM | ||
[SEVERE] JPF out of memory | [SEVERE] JPF out of memory | ||
+ | ... | ||
+ | </ | ||
We can constrain the maximum amount time used by JPF to 1000 milliseconds as follows. | We can constrain the maximum amount time used by JPF to 1000 milliseconds as follows. | ||
We can assign any long value to the property budget.max_time. | We can assign any long value to the property budget.max_time. | ||
+ | < | ||
target=Constraints | target=Constraints | ||
classpath=. | classpath=. | ||
Line 125: | Line 135: | ||
listener=gov.nasa.jpf.listener.BudgetChecker | listener=gov.nasa.jpf.listener.BudgetChecker | ||
budget.max_time=1000 | budget.max_time=1000 | ||
- | | + | </ |
Since JPF cannot complete within one second, it stops after one second and produces the following output. | Since JPF cannot complete within one second, it stops after one second and produces the following output. | ||
+ | < | ||
JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
Line 138: | Line 150: | ||
====================================================== search constraint | ====================================================== search constraint | ||
max time exceeded: 00:00:01 >= 00:00:01 | max time exceeded: 00:00:01 >= 00:00:01 | ||
+ | ... | ||
+ | </ | ||
The amount heap space used by JPF can be constrained to a maximum number of bits as follows. | The amount heap space used by JPF can be constrained to a maximum number of bits as follows. | ||
We can assign any long value to the property budget.max_heap. | We can assign any long value to the property budget.max_heap. | ||
+ | < | ||
target=Constraints | target=Constraints | ||
classpath=. | classpath=. | ||
Line 147: | Line 162: | ||
listener=gov.nasa.jpf.listener.BudgetChecker | listener=gov.nasa.jpf.listener.BudgetChecker | ||
budget.max_heap=10000000 | budget.max_heap=10000000 | ||
+ | </ | ||
Note that 10000000 bits = 10000000 / (1024 * 1024) megabytes = 9.5 megabytes. | Note that 10000000 bits = 10000000 / (1024 * 1024) megabytes = 9.5 megabytes. | ||
JPF needs more heap space, it stops and produces the following output. | JPF needs more heap space, it stops and produces the following output. | ||
+ | < | ||
JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
Line 162: | Line 178: | ||
====================================================== search constraint | ====================================================== search constraint | ||
max heap exceeded: 10MB >= 9MB | max heap exceeded: 10MB >= 9MB | ||
+ | ... | ||
+ | </ | ||
One can constrain JPF from checking more than 100 bytecode instructions as follows. | One can constrain JPF from checking more than 100 bytecode instructions as follows. | ||
- | We can assign any int value to the property budget.max_insn. | + | We can assign any long value to the property budget.max_insn. |
+ | < | ||
target=Constraints | target=Constraints | ||
classpath=. | classpath=. | ||
Line 171: | Line 190: | ||
listener=gov.nasa.jpf.listener.BudgetChecker | listener=gov.nasa.jpf.listener.BudgetChecker | ||
budget.max_insn=100 | budget.max_insn=100 | ||
+ | </ | ||
Since this constraint is violated, JPF produces the following output. | Since this constraint is violated, JPF produces the following output. | ||
+ | < | ||
JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
Line 184: | Line 205: | ||
====================================================== search constraint | ====================================================== search constraint | ||
max instruction count exceeded: 100 | max instruction count exceeded: 100 | ||
+ | ... | ||
+ | </ | ||
+ | We can also limit the number of states that JPF explores by setting the property budget.max_state. | ||
+ | < | ||
target=Constraints | target=Constraints | ||
classpath=. | classpath=. | ||
Line 191: | Line 216: | ||
listener=gov.nasa.jpf.listener.BudgetChecker | listener=gov.nasa.jpf.listener.BudgetChecker | ||
budget.max_state=100 | budget.max_state=100 | ||
+ | </ | ||
+ | Since the statespace of this app consists of more than 100 states, JPF stops and produces the following output. | ||
- | + | < | |
- | + | ||
JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
Line 206: | Line 231: | ||
====================================================== search constraint | ====================================================== search constraint | ||
max states exceeded: 100 | max states exceeded: 100 | ||
+ | ... | ||
+ | </ | ||
+ | We can also constrain the depth of the search. | ||
+ | |||
+ | < | ||
target=Constraints | target=Constraints | ||
classpath=. | classpath=. | ||
Line 212: | Line 242: | ||
listener=gov.nasa.jpf.listener.BudgetChecker | listener=gov.nasa.jpf.listener.BudgetChecker | ||
budget.max_depth=100 | budget.max_depth=100 | ||
+ | </ | ||
+ | Since the depth of the search is greater than 100 for this app, JPF stops and produces the following output. | ||
+ | < | ||
JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
Line 224: | Line 257: | ||
====================================================== search constraint | ====================================================== search constraint | ||
max search depth exceeded: 100 | max search depth exceeded: 100 | ||
+ | ... | ||
+ | </ | ||
+ | |||
lab4.1485547890.txt.gz · Last modified: 2017/01/27 20:11 by franck