Model-driven Test Generation Oleg Sokolsky September 22, 2004.

Slides:



Advertisements
Similar presentations
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Advertisements

ECE Synthesis & Verification - L271 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Model Checking basics.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Grey Box testing Tor Stålhane. What is Grey Box testing Grey Box testing is testing done with limited knowledge of the internal of the system. Grey Box.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Spin Tutorial (some verification options). Assertion is always executable and has no other effect on the state of the system than to change the local.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
CS 582 / CMPE 481 Distributed Systems Fault Tolerance.
CSE115/ENGR160 Discrete Mathematics 03/03/11 Ming-Hsuan Yang UC Merced 1.
1 Jan Tretmans Embedded Systems Institute Eindhoven Radboud University Nijmegen Model-Based Testing.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Software Engineering, COMP201 Slide 1 Protocol Engineering Protocol Specification using CFSM model Lecture 30.
Department of CIS University of Pennsylvania 1/31/2001 Specification-based Protocol Testing Hyoung Seok Hong Oleg Sokolsky CSE 642.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
System Design Research Laboratory Specification-based Testing with Linear Temporal Logic Li Tan Oleg Sokolsky Insup Lee University of Pennsylvania.
Software Testing and QA Theory and Practice (Chapter 10: Test Generation from FSM Models) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
1 Jan Tretmans Embedded Systems Institute Eindhoven, NL Radboud University Nijmegen, NL Model-Based Testing with Labelled Transition.
Copyright © Siemens AG All rights reserved. Essential Criteria on MBT to Ensure Quality of Software in Industry PVR Murthy Andreas Ulrich Siemens.
CMSC 345 Fall 2000 Unit Testing. The testing process.
Software Engineering Chapter 23 Software Testing Ku-Yaw Chang Assistant Professor Department of Computer Science and Information.
Testing with Formal Methods Ed Brinksma course 2004 A Formal Framework.
Model Based Conformance Testing for Extensible Internet Protocols Anastasia Tugaenko Scientific Adviser: Nikolay Pakulin, PhD.
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
CS6133 Software Specification and Verification
Model Based Testing Group 7  Nishanth Chandradas ( )  George Stavrinides ( )  Jeyhan Hizli ( )  Talvinder Judge ( )  Saajan.
Grey Box testing Tor Stålhane. What is Grey Box testing Grey Box testing is testing done with limited knowledge of the internal of the system. Grey Box.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Conformance Test Suites, Extensionally Arend Rensink University of Twente Dutch Workshop on Formal Testing Techniques University of Twente 13 September.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
Natallia Kokash (Accepted for PACO’2011) ACG, 31/05/ Input-output conformance testing for channel-based connectors 1.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
1 Black-box conformance testing for real-time systems Stavros Tripakis VERIMAG Joint work with Moez Krichen.
Systems Analysis and Design in a Changing World, Fourth Edition
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
Formal Testing with Input-Output Transition Systems Ed Brinksma Course 2004.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Mutation Testing Breaking the application to test it.
4/22/02VU '021 Specification-Based Techniques for Validation at Run-time and Design-time* Insup Lee SDRL (Systems Design Research Lab) RTG (Real-Time Systems.
Test Generation for Input/Output Transition Systems Ed Brinksma Course 2004.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Testing Integral part of the software development process.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
A Review of Software Testing - P. David Coward
Formal methods: Lecture
Software Testing.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Software Engineering (CSI 321)
Input Space Partition Testing CS 4501 / 6501 Software Testing
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Structural testing, Path Testing
CHAPTER 4 Test Design Techniques
UNIT-4 BLACKBOX AND WHITEBOX TESTING
White-Box Testing.
Software testing.
Chapter 10 – Software Testing
Producing short counterexamples using “crucial events”
White-Box Testing Techniques II
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

Model-driven Test Generation Oleg Sokolsky September 22, 2004

Outline and scope Classification of model-driven testing Conformance testing for communication protocols Coverage-based testing –Coverage criteria –Coverage-based test generation Can we do more? (open questions)

Testing classification By component level –Unit testing –Integration testing –System testing By abstraction level –Black box –White box –Grey box ???

Testing classification By purpose –Functional testing –Performance testing –Robustness testing –Stress testing Who performs testing? –Developers –In-house QA –Third-party

Functional testing An implementation can exhibit a variety of behaviors For each behavior, we can tell whether it is correct or not A test can be applied to the implementation and accept or reject one or more behaviors –The test fails if a behavior is rejected A test suite is a finite collection of tests –Testing fails if any test in the suite fails

Formal methods in testing “Testing can never demonstrate the absence of errors, only their presence.” Edsger W. Dijkstra How can formal methods help? Add rigor! –Reliably identify what should to be tested –Provide basis for test generation –Provide basis for test execution

Model-driven testing Rely on a model of the system –Different interpretations of a model Model is a requirement –Black-box conformance testing –QA or third party Model is a design artifact –Grey-box unit/system testing –QA or developers

Conformance testing A specification prescribes legal behaviors Does the implementation conform to the specification? –Need the notion of conformance Not interested in: –How the system is implemented? –What went wrong if an error is found? –What else the system can do?

Test hypothesis How do we relate beasts of different species? –Implementation is a physical object –Specification is a formal object Assume there is a formal model that is faithful to implementation –We do not know it! Define conformance between the model and the specification –Generate tests to demonstrate conformance

Conformance testing with LTS Requirement is specified as a labeled transition system Implementation is modeled as an input-output transition system Conformance relation is given by ioco –[Tretmans96] –Built upon earlier work on testing preorders

Historical reference Process equivalences: –Trace equivalence/preorder is too coarse –Bisimulation/simulation is too fine Middle ground: –Failures equivalence in CSP –may- and must-testing by Hennessy –Testing preorder by de Nicola –They are all the same! Right notion but hard to compute

Testing architecture Implementation relation Test generation algorithm Test execution engine

Input-Output Transition Systems dime coffee nickel tea S1 S2 S3 S4 S0 L I = { ?dime, ?nickel } L U = { !coffee, !tea } dime, nickelcoffee, tea from user to machinefrom machine to user initiative with userinitiative with machine machine cannot refuseuser cannot refuse inputoutput L I L U L I  L U =  L I  L U = L ! ? ? !

Input-Output Transition Systems L I = { ?dime, ?nickel } L U = { !coffee, !tea } Input-Output Transition Systems IOTS (L I,L U )  LTS (L I  L U ) IOTS is LTS with Input-Output and always enabled inputs: for all states s, for all inputs ?a  L I : ?dime ?nickel ?dime ! coffee ?nickel !tea S ?a

Preorders on IOTS implementation i specification s environment e imp i  IOTS(L I,L U ) s  LTS(L I  L U ) imp  IOTS (L I,L U ) x LTS (L I  L U ) Observing IOTS where system inputs interact with environment outputs, and vice versa

Preorders on IOTS implementation i specification s environment e  IOTS(L U,L I ) imp i imp s   e  E. obs ( e, i )  obs (e, s ) i  IOTS(L I,L U ) s  LTS(L I  L U )

Input-Output Testing Relation implementation i specification s environment e obs ( e, p ) = ( traces (e||p ), qtraces (e||p ) ) qtraces(p) =   L*. p after  refuses L U  iot i  iot s   e  IOTS(L U,L I ). obs ( e, i )  obs (e, s ) i  IOTS(L I,L U ) s  LTS(L I  L U )

Testing preorders – a side note One of the reasons for using IOTS over LTS is that  iot is computationally simpler than conventional testing preorder –Testing preorder requires us to compare sets of pairs (trace, refusal set) –At the same time  iot allows us to use inclusion of weakly quiescent traces: inputs can never be refused by i, and outputs can never be refused by e i after  refuses A  A =  or A = L U

Representing quiescence Extend IOTS with quiescent transitions –deterministic  -trace automata ?dime ?nickel ?dime ! coffee ?nickel !tea ?dime ?nickel ?dime ! coffee ?nickel !tea    p:  p:

Conformance relation ioconf Finally… i  iot s    L*.out(  i after  )  out(  s after  ) Allow underspecification –restrict to traces of s i ioconf s = def  traces(  s)  L*.out(  i after  )  out(  s after  ) ioconf F : use arbitrary F instead of traces of s Conformance relation ioco accounts for repetitive quiescence

Test cases A test case is a deterministic IOTS(L U,L I ) with finite behaviors –Note reversed inputs and outputs –Do not allow choice between outputs or between input and output Verdict function : S → {fail,pass} Test run: i passes t = def (i||t) after  deadlocks  (t after  )=pass ?dime ! coffee !tea pass fail

Test generation Test suite T s for a specification s is complete: i ioconf s iff  t  Ts. i passes t Test suite T s is sound if i ioconf s   t  Ts. i passes t Complete test suites are usually infinite –Aim at generating sound test suites

Test generation algorithm Gen(  s, F ) –Choose non-deterministically: 1. t = stop and  (t) = pass 2. t = a. Gen(  ’ s, F after a), with  s →  ’ s  (t) = pass 3. a

Example F = dime.coffee ?dime ! coffee !tea pass fail  not in F after dime and not quiescent quiescent Wrong output Right output output- enabled ?dime ?nickel ?dime ! coffee ?nickel !tea     p:

Test purposes Where does F come from? Test purposes: –Requirements, use cases –Automata, message sequence charts Test purposes represent “interesting” or “significant” behaviors –Define “interesting” or “significant”… Can we come up with test purposes automatically?

Summary: conformance testing Advantages: –Very rigorous formal foundation –Size of the test suite is controlled by use cases Disadvantages: –How much have we learned about the system that passed the test suite? –Does not guarantee coverage

Coverage-based testing Traditional: –Tests are derived from the implementation structure (code) Model-driven: –Cover the model instead of code –Model should be much closer to the implementation in structure Relies on coverage criteria

Coverage criteria and tests [HongLeeSokolskyUral02] Control flow: –all-states –all-transitions Data flow: –all-defs –all-uses –all-inputs –all-outputs Test is a linear sequence of inputs and outputs

Specifications: EFSM Transition systems equipped with variables Transitions have guards and update blocks IDLEBUSY t1: insert[m+x<=5] /m:=m+x t4: display/y:=m t5: display/y:=m t3: done t2: coffee[m>1] /m:=m-1

Coverage criteria Each coverage criterion is represented by a set of temporal logic formulas –WCTL: a subset of CTL Atomic propositions p 1,…,p n Temporal operators EX, EU, EF Conjunctions: at most one non-atomic conjunct Negations is applied only to atomic propositions Unrestricted disjunctions E.g.: EF(p 1 & EFp 2 ) –WCTL formulas have linear witnesses

All-states coverage criterion IDLEBUSY t1: insert[m+x<=5] /m:=m+x t4: display/y:=m t5: display/y:=m t3: done t2: coffee[m>1] /m:=m-1 Requires every state be covered at least once With every state s, associate EF( s & EF exit ) EF(idle & EFexit) EF(busy & EFexit) IDLEBUSY

All-transitions coverage criterion Requires every transition be covered at least once With every transition t, associate EF( t & EF exit ) IDLEBUSY t1: insert[m+x<=5] /m:=m+x t4: display/y:=m t5: display/y:=m t3: done t2: coffee[m>1] /m:=m-1 EF(t1 & EFexit) EF(t2 & EFexit) EF(t3 & EFexit) EF(t4 & EFexit) EF(t5 & EFexit) t1: insert[m+x<=5] /m:=m+x t4: display/y:=m t5: display/y:=m t3: done t2: coffee[m>1] /m:=m-1

Data flow: definitions and uses Definition: a value is assigned to a variable Use: a value of a variable is used in an expression Variables are defined and used in transitions Definition-use pair: (v,t,t’) –v is defined by t –v is used by t’ –There is a path from t to t’ free from other definitions of v

Covering a du-pair With a du-pair (v, t, t’), associate –EF( t & EXE[! def ( v ) U ( t’ & EF exit )]) –def ( v ) : disjunction of all transitions that define v IDLEBUSY t1: insert[m+x<=5] /m:=m+x t4: display/y:=m t5: display/y:=m t3: done t2: coffee[m>1] /m:=m-1 t1: insert[m+x<=5] /m:=m+x t2: coffee[m>1] /m:=m-1 EF(t1 & EXE[!(t1 | t2) U (t2 & EFexit)])

Data-flow coverage criteria All-defs coverage criterion: a definition-clear path –from every definition to some use All-uses coverage criterion: a definition-clear path –from every definition to every use IDLEBUSY t1: insert[m+x<=5] /m:=m+x t4: display/y:=m t5: display/y:=m t3: done t2: coffee[m>1] /m:=m-1 All-uses coverage criterion EF(t1 & EXE[!(t1 | t2) U (t1 & EFexit)]) EF(t1 & EXE[!(t1 | t2) U (t2 & EFexit)]) EF(t1 & EXE[!(t1 | t2) U (t4 & EFexit)]) EF(t1 & EXE[!(t1 | t2) U (t5 & EFexit)]) EF(t2 & EXE[!(t1 | t2) U (t1 & EFexit)]) EF(t2 & EXE[!(t1 | t2) U (t2 & EFexit)]) EF(t2 & EXE[!(t1 | t2) U (t4 & EFexit)]) EF(t2 & EXE[!(t1 | t2) U (t5 & EFexit)])

Data flow chains Affect pair (v, t, v’, t’): the value of v used by t affects the value of v’ defined at t’ –Either t=t’ ( (v,t) directly affects (v’,t’) ) or –there is a du-pair (v’’,t,t’’) s.t. (v,t) directly affects (v’’,t) and (v’’,t’’) affects (v’,t’) t5: display/y:=m IDLEBUSY t1: insert[m+x<=5] /m:=m+x t4: display/y:=m t3: done t2: coffee[m>1] /m:=m-1 (x, t1) directly affects (m, t1) t1: insert[m+x<=5] /m:=m+x (x, t1) affects (y, t5) t1: insert[m+x<=5] /m:=m+x t5: display/y:=m

Data flow chain coverage Affect pair (v, t, v’, t’) –May consist of an arbitrary number of definition-use pairs –We extend CTL with least fixpoint operators Alternatively, we can use (alternation-free) mu- calculus All-inputs coverage criterion –Requires a path from every input to some output be covered at least once All-outputs coverage criterion –Requires a path from every input to every output be covered at least once

Test Generation Model checker System model Logic formula True or false Witness or counterexample Coverage criterion Model checker System model A set of logic formulas A set of witnesses

Test Generation Generating a witness for a formula –Cost: the length of a witness –A minimal-cost witness for a formula Existing model checkers generate a minimal-cost witness by breadth-first search of state space E[ U ]

Test Generation Costs –The total length of witnesses or –The number of witnesses Both optimization problems are NP-hard E[ U ]

Coverage for distributed systems What if our system is a collection of components? Possible solutions: –Generate tests for each components Clearly unsatisfactory; does not test integration –Generate tests from the product of component models Too many redundant tests Non-determinism is another problem

Example Producer-consumer with acknowledgements

Covering product transition system Linear tests bring trouble: send?.ack!.recv! –May fail if the system chooses a different path Tests differ in interleavings of independent events –No need to test send?.ack!.recv! send?.recv!.ack! separately State explosion in test suite!

Partial orders for test generation Use event structures instead of transition systems [Heninger97] Test generation covers the event structure Allows natural generation of distributed testers

Prime event structures (PES) Set of events E –Events are occurrences of actions Causality relation –Partial order Conflict relation –irreflexive and symmetric Labeling function Finite causality Conflict inheritance

Producer-consumer PES Structure is infinite –Initial part is shown Causally unrelated and non-conflicting events can occur together Behaviors will start repeating –Can stop with finite structure

Test generation with PES Project PES on observable actions, propagating conflicts Every path in the PES should be covered Tests consist of distributed testers with coordination messages between tests –Coordination messages are inserted when there is a causal edge between locations

Summary: coverage-based testing Advantages: –Exercise the specification to the desired degree –Does not rely on test purpose selection Disadvantages: –Large and unstructured test suites –If the specification is an overapproximation, tests may be infeasible

Generation of test purposes Recent work: [HenningerLuUral-03] Construct PES Generate MSC (message sequence charts) to cover PES Use MSC as test purposes in ioco -based test generation

Controllability of testing Conformance testing may not provide enough guarantees –With branching tests, test purpose behavior may be avoided –What if I never see ack ? Problem: inherent uncertainty in the system

How to contain uncertainty? Avoidance (no need to increase control) –During testing, compute confidence measure E. g., accumulate coverage –Stop at the desired confidence level Prevention (add more control) –Use instrumentation to resolve uncertainty –What to instrument? Use model for guidance Anyone needs a project to work on?

Test generation tools TorX –Based on ioco –On-the-fly test generation and execution –Symbolic testing (data parameterization) –LOTOS, Promela, … – TGV –Based on symbolic ioconf –LOTOS, SDL, UML –