Software Testing Prof. Dr. Holger Schlingloff Humboldt-Universität zu Berlin and Fraunhofer Institute of Computer Architecture and Software Technology.

Slides:



Advertisements
Similar presentations
Black Box Checking Book: Chapter 9 Model Checking Finite state description of a system B. LTL formula. Translate into an automaton P. Check whether L(B)
Advertisements

Modeling issues Book: chapters 4.12, 5.4, 8.4, 10.1.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
1 Fault Diagnosis for Timed Automata Stavros Tripakis VERIMAG.
1 Model checking. 2 And now... the system How do we model a reactive system with an automaton ? It is convenient to model systems with Transition systems.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
An Introduction to the Model Verifier verds Wenhui Zhang September 15 th, 2010.
UPPAAL Introduction Chien-Liang Chen.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Timed Automata.
Software Failure: Reasons Incorrect, missing, impossible requirements * Requirement validation. Incorrect specification * Specification verification. Faulty.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Lecture 4&5: Model Checking: A quick introduction Professor Aditya Ghose Director, Decision Systems Lab School of IT and Computer Science University of.
Specification Formalisms Book: Chapter 5. Properties of formalisms Formal. Unique interpretation. Intuitive. Simple to understand (visual). Succinct.
Describing Syntax and Semantics
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
Abstract Verification is traditionally done by determining the truth of a temporal formula (the specification) with respect to a timed transition system.
Software Testing and QA Theory and Practice (Chapter 10: Test Generation from FSM Models) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
02/06/05 “Investigating a Finite–State Machine Notation for Discrete–Event Systems” Nikolay Stoimenov.
Cheng/Dillon-Software Engineering: Formal Methods Model Checking.
Regular Model Checking Ahmed Bouajjani,Benget Jonsson, Marcus Nillson and Tayssir Touili Moran Ben Tulila
Timed UML State Machines Ognyana Hristova Tutor: Priv.-Doz. Dr. Thomas Noll June, 2007.
Zvi Kohavi and Niraj K. Jha 1 Capabilities, Minimization, and Transformation of Sequential Machines.
AMOST Experimental Comparison of Code-Based and Model-Based Test Prioritization Bogdan Korel Computer Science Department Illinois Institute of Technology.
Institute for Applied Information Processing and Communications 1 Karin Greimel Semmering, Open Implication.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
Advanced Technology Center Slide 1 Requirements-Based Testing Dr. Mats P. E. Heimdahl University of Minnesota Software Engineering Center Dr. Steven P.
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Software Engineering Research paper presentation Ali Ahmad Formal Approaches to Software Testing Hierarchal GUI Test Case Generation Using Automated Planning.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
On Reducing the Global State Graph for Verification of Distributed Computations Vijay K. Garg, Arindam Chakraborty Parallel and Distributed Systems Laboratory.
CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: LTL Model Checking Copyright , Matt Dwyer, John Hatcliff,
Conformance Test Suites, Extensionally Arend Rensink University of Twente Dutch Workshop on Formal Testing Techniques University of Twente 13 September.
Lecture 81 Regional Automaton CS 5270 Lecture 8. Lecture 82 What We Need to Do Problem: –We need to analyze the timed behavior of a TTS. –The timed behavior.
Natallia Kokash (Accepted for PACO’2011) ACG, 31/05/ Input-output conformance testing for channel-based connectors 1.
Conformance Test Experiments for Distributed Real-Time Systems Rachel Cardell-Oliver Complex Systems Group Department of Computer Science & Software Engineering.
1 Black-box conformance testing for real-time systems Stavros Tripakis VERIMAG Joint work with Moez Krichen.
Petri Nets Lecturer: Roohollah Abdipour. Agenda Introduction Petri Net Modelling with Petri Net Analysis of Petri net 2.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Introduction to Software Testing Paul Ammann & Jeff Offutt Updated 24-August 2010.
Verification & Validation By: Amir Masoud Gharehbaghi
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
Chapter 8 Asynchronous System Model by Mikhail Nesterenko “Distributed Algorithms” by Nancy A. Lynch.
ECE/CS 584: Verification of Embedded Computing Systems Model Checking Timed Automata Sayan Mitra Lecture 09.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Model Checking Lecture 2. Model-Checking Problem I |= S System modelSystem property.
CS5270 Lecture 41 Timed Automata I CS 5270 Lecture 4.
SS 2017 Software Verification Timed Automata
Software Testing.
Finite State Machines Dr K R Bond 2009
Prof. Dr. Holger Schlingloff 1,2 Dr. Esteban Pavese 1
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Structural testing, Path Testing
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Timed Automata Formal Systems Pallab Dasgupta Professor,
SS 2018 Software Verification ML, state machines
CSEP590 – Model Checking and Automated Verification
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

Software Testing Prof. Dr. Holger Schlingloff Humboldt-Universität zu Berlin and Fraunhofer Institute of Computer Architecture and Software Technology FIRST

Outline of this Lecture Series 2006/11/24: Introduction, Definitions, Examples 2006/11/25-1: Functional testing 2006/11/25-2: Structural testing 2006/11/26-1: Model-based test generation 2006/11/26-2: Specification-based test generation Next week: Your turn!

Outline of This Lecture Test generation from Finite State Machines Test generation from UML StateCharts Test generation from Timed Automata

Description of Systems Finite automata have been known since the 1960’s  Moore / Mealy: used to describe relations between words (input sequence is transformed into output sequence)  Rabin / Scott: used to describe sets of words (accepting / non-accepting states) Can be used to describe the control flow of any system  states are (equivalence classes of) configurations of the SUT  transitions are actions (external or internal) changing the state

Labelled Transition Systems “finite automaton without accepting states” formally: (S,L,T,s 0 )  S: finite or countable nonempty set of states  L: finite set of labels,  L  transition relation T  S  (L  {  })  S  s 0 initial state Run=finite sequence {(s i l i s i+1 ) i  N }, where s 0 is the initial state and (s i l i s i+1 )  T Trace = sequence of observable actions (labels  ) of a run Undirected communication! Actions just “happen”!

Example: A Light Switch can be switched up and down may internally switch off cf. windshield wiper example offlow high up dn 

Test Generation Remarks: each “box” can be manual or automated if everything is automated, only the tools are tested Requirements: SUT must accept inputs from test driver SUT must provide recognisable outputs for test driver SUT must be resettable by test driver SUT must be deterministic Spec (FSM) Test Generator SUT Test Suite Test Driver / Evaluator Test Results Code Generator

Conformance Given an LTS, what does it mean that an implementation is “correct” with respect to this model?  same structure? same states? same state classes?  same behaviour? same observable behaviour?  same choices? fewer choices? more choices?  same timing? more specific timing? Fault model (extra/missing state, unexpected output, quiescence, …) Conformance notions (Tretmans)

Trace Refinement Observable behaviour: set of sequences of visible actions of the SUT Traces (P) = set of observable behaviours of process P Imp  T Spec iff Traces(Imp)  Traces(Spec) pre-order (transitive, reflexive)  minimal element is the empty trace  comparable to language inclusion in finite automata theory

Testing Trace Refinement Test case = trace Test suite = set of traces Test execution of trace  for Imp and Spec:    Traces(Imp)  pass    Traces(Imp)  Traces(Spec)  pass  fail, else Verdict of a test suite is the conjunction of individual verdicts Complete test suite: set of all traces over the alphabet Imp  T Spec iff complete test suite passes not feasible, thus additional hypotheses (length of traces, number of certain actions etc.)

Failures Failure = ( , A), where  is a sequence of observable actions, A is a set of actions Failures(P) = set of failures ( , A), such that there is an execution of P where  can be observed, and afterwards no action from A is activated (P after  refuses A) in automata: „non-transitions“ Imp  F Spec iff Failures(Imp)  Failures(Spec) also a partial order finer than trace-Refinement: Imp  F Spec  Imp  T Spec

Failure Refinement Imp  F Spec iff Failures(Imp)  Failures(Spec) Imp  F Spec iff (Imp after  refuses A) implies (Spec after  refuses A)  Imp may only refuse those actions which are also refused bySpec  Imp may only perform those actions which are allowed by Spec  Imp has „less deadlocks“ than Spec Refinement with respect to this relation  transformational development  correctness proofs

Testing of Failure Refinement Test suite T = set of failures ( , A) Complete test suite = set of all failures for a set of observable events Verdict of a test ( , A) with respect to Imp and Spec    Traces(Imp)  pass  ( ,a)  Traces(Imp) for some a  A  pass  ( ,A)  Failures(Imp)  Failures(Spec)  pass  fail, else Verdict of a test suite: all test cases pass Test of an implementation Imp Imp  F Spec iff complete test suite passes (under certain side-conditions)

Conformance Imp conf Spec iff for all  in Traces(Spec): (Imp after  refuses A)  (Spec after  refuses A)  for action sequences of the specification same as  F  Imp may implement „additional functionaliy“  weaker than  F (i.e. Imp  F Spec  Imp conf Spec) conformance testing similar as with failure- refinement-testing widely used as a correctness criterion

IOCO Taking also inputs and outputs into consideration All inputs are always enabled out(P after  )={a! | P may execute  and then output a!} Imp ioco Spec iff for all  in Traces(Spec): (out(Imp after  )  out(Spec after  ) Idea  Imp is more deterministic than Spec with respect to specified inputs  Imp may implement additional functionality for unspecified inputs

Implementation: TGV TGV “Test Generation with Verification” Conformance testing for reactive systems, black box test Automated test generation from LTS, IOCO Interaction via PCOs Verdict  fail: a non-conformance was observed  pass: trace could be executed in the SUT  inconc: else

TGV Example

TGV Testing Purposes A testing purpose in TGV is a “small” LTS with additional transitions ACCEPT, REFUSE TGV builds the cartesian product of spec and testing purpose Test generation: determinisation of LTS and TP, enumeration of traces

Short break!

UML StateCharts can be seen as LTS with  hierarchy  parallelism  inheritance

Parallelism What is the meaning of parallelism in the specification?  structural: must be implemented in parallel  engineering: may be implemented in any order  pragmatic: will be implemented according to the tool’s scheduling strategy

Test Generation from StateCharts ATG (“automated test generator”): Add-on to the UML-tool Rhapsody by ILogix / IBM First, the model is translated into C++ by the Rhapsody code generator Then, inputs and outputs to the model / SUT are identified Then, ATG constructs test cases from the generated code according to certain coverage goals  all states  all transitions  MC/DC

A “Real-Life” Example A safety protocol for industrial automation

Let’s make a test: When I open this window, the whole thing will surely crash…

Test Generation from UML State Machines Has been investigated for some time now Often, „flattening“ of state machines and depth-first search is used, transition tour algorithm All-States, All-Transitions, Modified Condition / Decision Coverage (MCDC) criteria Commercial and experimental research tools available Leiros

Example: Seat control

Procedure for Test Generation Model physical dependencies by an environment model (e.g. motor movement and sensor value) In this case, no separate user model is necessary (user can press any button at any time) Translate into C++ by Telelogic Rhapsody Separate interfaces into „required“ and „provided“ Use e.g. ATG (Automatic Test Generator) for the automatic construction of a test suite Clean up the result (i.e., purge non-visible events, remove duplicate and included test sequences etc.)

Coverage ATG supports MCDC  every condition in a decision in the program has taken on each possible outcome at least once  each condition has been shown to affect that decision outcome independently  every point of entry and exit in the program has been reached at least once MCDC is widely used  Minimal requirement in DO178b  Subsumes All-Transitions, All-Events and All-Local-States ATG strives for MCDC on the generated code  state machines are translated into case-statements  additional C++ code in actions is added “as such”

Experimental result Six test cases of up to 7 events are generated  Very short sequences, basically each local state is visited  Local data variables and parameterized events are neglected  No test cases which move the seat forward, back and forward again (potential state error)

Improving Test Coverage Minimality of test suite is not an issue  One test case per use case may not be sufficient  Adjustable coverage criterion is needed Want to use commercially available test generator  proven-in-use technology  use as a basis for extending the coverage  pre-processing automatically augments the model  post-processing combines and filters the test cases Coverage is the product of generator coverage and enhancement function

Transition Instrumentation Several ways of enhancing a model  Additional states (and transitions) - increases model, but not necessarily coverage  Additional variables and conditions in transitions - does not change the state machine - can be used to provide additional test goals for the test case generator (“user defined test goals”)  Additional actions in transitions - can be used to provide additional information to the post-processing, e.g., state identification, variable values etc. Transparent transition instrumentation Extended transition instrumentation

Example: Sequence-based Coverage E.g., want to drive the control part of the example through all 2-transitions Augment this part of the state machine; test generator determines which other transitions are necessary New additional counter variables: ad, ae, af, ag, ah, bd, be, bf, bg, bh, cd, ce, cf, cg, ch, da, db, dc, ea, eb, ec, fd, fe, ff, fg, fh, gd, ge, gf, gg, gh, hd, he, hf, hg, hh

Enhanced Test Suite

Real Time Real Time concepts in UML (-state diagrams) (a)after (time) as a trigger (b)absolute time point (after start) as a trigger Informal semantics (a)transition will be executed t time units after becoming active (b)transition will be executed at the given time point Often, this is not sufficient  no minimal / maximal waiting times  no possibility of using several clocks State 1State 2 after (5 ms) / Activity

Timed Automata Extension of LTS by clocks  All clocks are constantly running (no stopwatches)  All clocks run at the same speed (perfect clocks, t’=1)  Clocks can be reset by transitions  Clocks can influence the switching of transitions S1 S2 x<2 a, x:=0 x>1, b One clock x. No invariant at s1, so the system may stay arbitrarily long in s1. When transitioning to s2 by a the clock will be reset to 0. In s2 the clock is running. After at least 1 time unit the transition to s is possible, after at most 2 time units it must happen.

Example Double-click switch  Click on, click off  After clicking twice fastly in a row, it becomes brigther Additional requirement  after at most 300 ms turn darker again More about timed automata: Rajeev Alur, Tom Henzinger R. Alur and T.A. Henzinger. Real-time logics: complexity and expressiveness. Information and Computation 104(1):35-77, 1993 R. Alur and D.L. Dill. A theory of timed automata. Theoretical Computer Science 126: , offlowbright klick x:=0 x>3 x  3 y  300 y>300 y:=0

Formal Definition Assume a set X of time variables. A timed condition is a Boolean combination of formulas of the kind x<c, x  c (where c is any rational number) A timed automaton is a tupel consisting of  a finite set L of locations  a subset L 0 of initial locations  a finite alphabet  of events  a finite set  of clocks (clock-variables)  An invariant Inv(s) for every location (timed condition, optional)  a finite set E of transitions consisting of - source, target - event from the alphabet (optional) - timed condition (optional) - set of clocks to be reset (optional)

Semantics of Timed Automata Each timed automaton is assigned an infinite LTS:  states: (l, v) where l is a location and v is an assignment of clocks with real numbers which satisfies Inv(l)  initial state: (l 0,(0,…,0))  transitions - control transition: (l,v) –a–>(l´,v´) if a transition (l,a,g,r,l´) exists such that v satisfies g and v´=v[r:=0] - time transition: (l,v) –d–>(l´,v´) if l´=l and v´=v+d and both v and v´ satisfy Inv(l) Each path through the transition system is an execution of the timed automaton  control and time transitions strictly alternating  semantics = set of (infinite) executions, non-Zeno

Determinism Attention: if e.g. the conditions are inconsistent, the set of executions may be empty Additional requirements to take care of such situations  the timed conditions are mutually inconsistent (at least those for the same event)  they sum up to true, i.e. the disjunction of all timed conditions is a tautology Often combined with other determinism requirements, e.g. input enabledness

Extensions of Timed Automata Input / Output – Timed Automata  partitioning of  in inputs (i?), outputs (o!), and internal events  each transition can be labelled by an input or an internal event, and at the same time by several outputs Additional variables v 1,…,v n with finite domains W 1,…,W n  location = (place, values (w 1,…,w n )) Parallel and hierarchical automata  similar to StateCharts  usual automata product semantics (interleaving)  only for convenience in modelling

Test Generation from TA Which one to choose? (Random choice might result in „bad coverage“) Wanted: a strategy which covers all behaviours

Idea: Equivalence Classes Partition the infinite state space into finitely many „regions“ such that all regions are behaviorally „similar“ cover the region graph with untimed methods

Quotients of Automata Recall the definition of the quotient automaton of a finite automaton with respect to a partitioning of the state space  abstraction of certain variables - smaller domains e.g. Int  {-maxint,…,-1},{0},{1,…,maxint} - elimination of variables (unit domain)  states in the quotient automaton are equivalence classes of states in the original automaton  this is a coarsening of the specification, the set of executions becomes larger

Quotients of Timed Automata With timed automata  abstraction of clock variables: the language of the untimed automaton strictly encompasses the language of the respective timed automaton  maybe too coarse (why did we introduce time after all?) Two quotient constructions have been proposed  Region equivalence  Zone equivalence ab a x:=0 x>10 b

Regions Finite partitioning of the state space Definition region equivalence: Let c max be the largest constant occurring in the automaton. v  R u iff the integral part of all clock valuations is equal or both >c max. the fractional part is both =0 or both >0 if x<c max and y<c max are clocks, then (x  y in v iff x  y in u) x y A region (equivalence class)

Zones Finite set of inequalities All possible <-relations between all clock variables It is sufficient to check this condition for linear combinations of variables (c=k 1 *c 1 +…+k n *c n ) Definition: w  Z w’ iff w and w’ satisfy the same inequalities x i < c, x i = c, x i – x j < c, x i –x j =c where x i, x j are clocks and c  c max is some constant

Finiteness of the State Space The relations  have a finite index  i.e. there are only finitely many reqchable regions / zones  i.e. the region/zone graph is finite Proof idea (regions)  follows from the definition of  R : there are only finitely many integral parts  c max and finitely many comparisons of fractional parts Proof idea (zones)  with finitely many rational numbers there are only finitely many linear combinations smaller than a given bound  each timed automaton contains only finitely many constants  thus there are only finitely many conditions of the mentioned form

Construction of the Region Graph Theorem: the region graph satisfies the same safety properties a the original timed automaton  thus, a complete test suite for the region graph will uncover all safety errors in the timed automaton x y Successor regions, Succ(r) r Reset region r[y:=0] r[x:=0]

Example #Regions depends on #Locations, #Constants, #Clocks i.A. exponential in the number of clocks and the number and size of constants (PSPACE-complete)

UppAal, Kronos, Rabbit… Tools for the construction of the region graph  animated simulation  temporal verification  test generation (UppAal) different internal representations  sets of inequalities  binary decision diagrams (BDDs)  difference bound matrices (DBMs) --- Presentation UPPAAL ? ---

© Uli Stein This operation must be performed with extreme precision. First, let’s check our watches: It’s now exactly 11:32 and 45 seconds I have it approximately 10 o’clock… My watch shows five minutes to nine… Mine is half past two…