lab2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lab2 [2016/01/13 17:13] – franck | lab2 [2018/01/02 22:03] (current) – franck | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Read the notes. | + | ====== Lab 2 ====== |
+ | |||
+ | |||
+ | * In your home directory create a directory named .jpf (note that the name of the directory starts with a dot). | ||
+ | * In the created directory, create a file named site.properties with the following contents. | ||
+ | < | ||
+ | # JPF site configuration | ||
+ | jpf-core=/ | ||
+ | extensions=${jpf-core} | ||
+ | </ | ||
+ | * In your home directory create a directory name 4315. | ||
+ | * In the created directory 4315, create a directory named lab2. | ||
+ | * In the created directory lab2, create the class RandomFraction with the following content. | ||
+ | <code java> | ||
+ | import java.util.Random; | ||
+ | |||
+ | public class RandomFraction { | ||
+ | public static void run() { | ||
+ | Random random = new Random(System.currentTimeMillis()); | ||
+ | System.out.println(1 / random.nextInt(1000000)); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | * Compile the RandomFraction | ||
+ | * In the created directory lab2, create the class RandomFractionTest with the following content. | ||
+ | <code java> | ||
+ | public class RandomFractionTest { | ||
+ | public static void main(String[] args) { | ||
+ | RandomFraction.run(); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | * Compile the RandomFractionTest class. | ||
+ | * Run the RandomFractionTest class. | ||
+ | * Create the file RandomFractionTest.jpf with the following content. | ||
+ | < | ||
+ | target=RandomFractionTest | ||
+ | classpath=. | ||
+ | </ | ||
+ | * Run Java PathFinder (JPF) on RandomFractionTest by running | ||
+ | < | ||
+ | jpf RandomFractionTest.jpf | ||
+ | </ | ||
+ | It should produce output similar to the following. | ||
+ | < | ||
+ | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
+ | |||
+ | |||
+ | ====================================================== system under test | ||
+ | RandomFractionTest.main() | ||
+ | |||
+ | ====================================================== search started: 1/14/17 12:06 PM | ||
+ | 0 | ||
+ | ====================================================== results | ||
+ | no errors detected | ||
+ | |||
+ | ====================================================== statistics | ||
+ | elapsed time: | ||
+ | states: | ||
+ | search: | ||
+ | choice generators: | ||
+ | heap: | ||
+ | instructions: | ||
+ | max memory: | ||
+ | loaded code: classes=62, | ||
+ | |||
+ | ====================================================== search finished: 1/14/17 12:06 PM | ||
+ | </ | ||
+ | * To the file RandomFractionTest.jpf add the following. | ||
+ | < | ||
+ | cg.enumerate_random=true | ||
+ | </ | ||
+ | * Run JPF on RandomFractionTest again. | ||
+ | < | ||
+ | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
+ | |||
+ | |||
+ | ====================================================== system under test | ||
+ | RandomFractionTest.main() | ||
+ | |||
+ | ====================================================== search started: 1/14/17 12:19 PM | ||
+ | |||
+ | ====================================================== error 1 | ||
+ | gov.nasa.jpf.vm.NoUncaughtExceptionsProperty | ||
+ | java.lang.ArithmeticException: | ||
+ | at RandomFraction.run(RandomFraction.java: | ||
+ | at RandomFractionTest.main(RandomFractionTest.java: | ||
+ | |||
+ | |||
+ | ====================================================== snapshot #1 | ||
+ | thread java.lang.Thread: | ||
+ | call stack: | ||
+ | at RandomFraction.run(RandomFraction.java: | ||
+ | at RandomFractionTest.main(RandomFractionTest.java: | ||
+ | |||
+ | |||
+ | ====================================================== results | ||
+ | error #1: gov.nasa.jpf.vm.NoUncaughtExceptionsProperty " | ||
+ | |||
+ | ====================================================== statistics | ||
+ | elapsed time: | ||
+ | states: | ||
+ | search: | ||
+ | choice generators: | ||
+ | heap: | ||
+ | instructions: | ||
+ | max memory: | ||
+ | loaded code: classes=66, | ||
+ | |||
+ | ====================================================== search finished: 1/14/17 12:19 PM | ||
+ | </ | ||
- | Bonus marks: for each mistake in the notes that is first reported by email before Saturday January 16, you receive 0.1 bonus mark, up to a maximum of 1.5 in total. |
lab2.1452705201.txt.gz · Last modified: 2016/01/13 17:13 by franck