33
Mini Models EECS 4315 www.cse.yorku.ca/course/4315/ www.cse.yorku.ca/course/4315/ EECS 4315 1 / 28

Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Mini ModelsEECS 4315

www.cse.yorku.ca/course/4315/

www.cse.yorku.ca/course/4315/ EECS 4315 1 / 28

Page 2: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Mini

source: Keld Gydum

www.cse.yorku.ca/course/4315/ EECS 4315 2 / 28

Page 3: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Mini Model

source: Mike Bird

www.cse.yorku.ca/course/4315/ EECS 4315 3 / 28

Page 4: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Model

www.cse.yorku.ca/course/4315/ EECS 4315 4 / 28

Page 5: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Mini Model

www.cse.yorku.ca/course/4315/ EECS 4315 5 / 28

Page 6: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Introduction to Java PathFinderEECS 4315

www.cse.yorku.ca/course/4315/

www.cse.yorku.ca/course/4315/ EECS 4315 6 / 28

Page 7: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Model Checker

property

model

model checker

www.cse.yorku.ca/course/4315/ EECS 4315 7 / 28

Page 8: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Some History

In 1999, Klaus Havelund introduced Java PathFinder (JPF).

Klaus Havelund. Java PathFinder – A Translator from Java toPromela. In, Dennis Dams, Rob Gerth, Stefan Leue and MiekeMassink, editors, Proceedings of the 5th and 6th InternationalSPIN Workshops, volume 1680 of Lecture Notes in ComputerScience, page 152. Springer-Verlag.

www.cse.yorku.ca/course/4315/ EECS 4315 8 / 28

Page 9: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Klaus Havelund

PhD in Computer Sciencefrom the University ofCopenhagen.Senior Research Scientist atNASA’s Jet PropulsionLaboratory.ASE 2014 most influentialpaper award.

Source: Klaus Havelund

www.cse.yorku.ca/course/4315/ EECS 4315 9 / 28

Page 10: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Some History

Others who initially worked on JPF:Michael Lowry (NASA)John Penix (NASA, now Google)Thomas Pressburger (NASA)Jens Ulrik Skakkebaek (Stanford, now Google)Willem Visser (NASA, now Stellenbosch University)

www.cse.yorku.ca/course/4315/ EECS 4315 10 / 28

Page 11: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

First Version of JPF

Java source code

translator

Promela code

SPIN model checker

www.cse.yorku.ca/course/4315/ EECS 4315 11 / 28

Page 12: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

First Version of JPF

Major limitations:Representing all features of Java in Promela is impossible;Mapping bugs found by SPIN in the Promela code back tothe Java code is challenging.

www.cse.yorku.ca/course/4315/ EECS 4315 12 / 28

Page 13: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Second Version of JPF

Java bytecode JPF

configuration files

reports

The second version of JPF is a Java virtual machine (JVM).

www.cse.yorku.ca/course/4315/ EECS 4315 13 / 28

Page 14: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Second Version of JPF

Willem Visser, Klaus Havelund, Guillaume Brat, SeungjoonPark. Model Checking Programs. In Proceedings of the 15thIEEE International Conference on Automated SoftwareEngineering, pages 3–12, Grenoble, France, September 2000.IEEE

The Automated Software Engineering conference series has arich history of good contributions to the area of research anddevelopment. The ASE most influential paper award is an effortto identity the most influential ASE paper 14 years after beingpublished. In 2014, the above paper won this award.

www.cse.yorku.ca/course/4315/ EECS 4315 14 / 28

Page 15: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

import java.util.Random;

public class PrintRandom{

public static void main(String[] args){

Random random = new Random();final int MAX = 9;System.out.println(random.nextInt(MAX + 1));

}}

www.cse.yorku.ca/course/4315/ EECS 4315 15 / 28

Page 16: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

target=PrintRandomclasspath=.

www.cse.yorku.ca/course/4315/ EECS 4315 16 / 28

Page 17: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

JavaPathfinder core system v8.0 (rev 2+) - (C) 2005

===================================================PrintRandom.main()

===================================================0

==================================================no errors detected

==================================================elapsed time: 00:00:00states: new=1,visited=0,backtracked=1,end=1...

=================================================www.cse.yorku.ca/course/4315/ EECS 4315 17 / 28

Page 18: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

QuestionTo how many different executions may the Java code give rise?

Answer10.

QuestionHow many different executions does JPF check?

Answer1.

www.cse.yorku.ca/course/4315/ EECS 4315 18 / 28

Page 19: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

QuestionTo how many different executions may the Java code give rise?

Answer10.

QuestionHow many different executions does JPF check?

Answer1.

www.cse.yorku.ca/course/4315/ EECS 4315 18 / 28

Page 20: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

QuestionTo how many different executions may the Java code give rise?

Answer10.

QuestionHow many different executions does JPF check?

Answer1.

www.cse.yorku.ca/course/4315/ EECS 4315 18 / 28

Page 21: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

QuestionTo how many different executions may the Java code give rise?

Answer10.

QuestionHow many different executions does JPF check?

Answer1.

www.cse.yorku.ca/course/4315/ EECS 4315 18 / 28

Page 22: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

Let’s have a look at the state space diagram.

target=PrintRandomclasspath=.listener=gov.nasa.jpf.listener.StateSpaceDot

www.cse.yorku.ca/course/4315/ EECS 4315 19 / 28

Page 23: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

www.cse.yorku.ca/course/4315/ EECS 4315 20 / 28

Page 24: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

Configure JPF so that it explores all random choices.

target=PrintRandomclasspath=.cg.enumerate_random=truelistener=gov.nasa.jpf.listener.StateSpaceDot

www.cse.yorku.ca/course/4315/ EECS 4315 21 / 28

Page 25: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

Configure JPF so that it explores all random choices.

target=PrintRandomclasspath=.cg.enumerate_random=truelistener=gov.nasa.jpf.listener.StateSpaceDot

www.cse.yorku.ca/course/4315/ EECS 4315 21 / 28

Page 26: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

JavaPathfinder core system v8.0 (rev 2+) - (C) 2005

===================================================PrintRandom.main()

===================================================0123456789

www.cse.yorku.ca/course/4315/ EECS 4315 22 / 28

Page 27: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

Let’s have a look at the state space diagram.

target=PrintRandomclasspath=.cg.enumerate_random=truelistener=gov.nasa.jpf.listener.StateSpaceDot

www.cse.yorku.ca/course/4315/ EECS 4315 23 / 28

Page 28: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

Simple Example

www.cse.yorku.ca/course/4315/ EECS 4315 24 / 28

Page 29: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

The ByteTest Revisited

In Lab 1, we wrote a JUnit test case to test the Byte class.

JPF can only be run on apps, that is, classes that contain amain method.By default JPF checks for uncaught exceptions.

www.cse.yorku.ca/course/4315/ EECS 4315 25 / 28

Page 30: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

The ByteTest Revisited

package quiz;

import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.notification.Failure;

public class RunTest{

public static void main(String[] args)throws Throwable

{Result result =JUnitCore.runClasses(ByteTest.class);for (Failure failure : result.getFailures()){throw failure.getException();

}}

}

www.cse.yorku.ca/course/4315/ EECS 4315 26 / 28

Page 31: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

The ByteTest Revisited

target=quiz.RunTestclasspath=.;/software/jars/junit-4.11.jar;\/software/jars/hamcrest-core-1.3.jarcg.enumerate_random=true

target contains both the class name and the packagename.The JUnit jars need to be added to the classpath.

www.cse.yorku.ca/course/4315/ EECS 4315 27 / 28

Page 32: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

The ByteTest Revisited

By default, JPF stops after detecting a bug.

To find multiple bugs . . .

target=quiz.RunTestclasspath=.;/software/jars/junit-4.11.jar;\/software/jars/hamcrest-core-1.3.jarcg.enumerate_random=truesearch.multiple_errors=true

www.cse.yorku.ca/course/4315/ EECS 4315 28 / 28

Page 33: Mini Models - York University · 2017. 1. 21. · Senior Research Scientist at NASA’s Jet Propulsion Laboratory. ASE 2014 ... Michael Lowry (NASA) John Penix (NASA, now Google)

The ByteTest Revisited

By default, JPF stops after detecting a bug.

To find multiple bugs . . .

target=quiz.RunTestclasspath=.;/software/jars/junit-4.11.jar;\/software/jars/hamcrest-core-1.3.jarcg.enumerate_random=truesearch.multiple_errors=true

www.cse.yorku.ca/course/4315/ EECS 4315 28 / 28