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

Slides:



Advertisements
Similar presentations
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Advertisements

Lecture 24 MAS 714 Hartmut Klauck
Signals and Systems March 25, Summary thus far: software engineering Focused on abstraction and modularity in software engineering. Topics: procedures,
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
1 How to transform an analyzer into a verifier. 2 OUTLINE OF THE LECTURE a verification technique which combines abstract interpretation and Park’s fixpoint.
© M. Winter COSC 4P41 – Functional Programming Testing vs Proving Testing –uses a set of “typical” examples, –symbolic testing, –may find errors,
Timed Automata.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
Theory of Testing and SATEL. 2 Presentation Structure Theory of testing SATEL (Semi-Automatic TEsting Language) –Test Intentions –SATEL semantics –CO-OPN.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Introduction to Computability Theory
School of Computing and Mathematics, University of Huddersfield CAS2545: WEEK 11 LECTURE: n The meaning of Algebraic Specifications TUTORIAL/PRACTICAL:
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Katz Formal Specifications Larch 1 Algebraic Specification and Larch Formal Specifications of Complex Systems Shmuel Katz The Technion.
Principles of Object-Oriented Software Development Behavioral refinement.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
1 Ivan Lanese Computer Science Department University of Bologna Italy Concurrent and located synchronizations in π-calculus.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Describing Syntax and Semantics
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
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.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
1 Program Correctness CIS 375 Bruce R. Maxim UM-Dearborn.
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Introduction to Formal Methods Based on Jeannette M. Wing. A Specifier's Introduction to Formal Methods. IEEE Computer, 23(9):8-24, September,
SOFTWARE DESIGN.
1 Automatic Refinement and Vacuity Detection for Symbolic Trajectory Evaluation Orna Grumberg Technion Haifa, Israel Joint work with Rachel Tzoref.
1 Relational Expressions Relational expressions: –Expressions that compare operands –Sometimes called conditions –Evaluated to yield a result –Typically.
Automatic Test Generation from here until the end (of my Phd.) University of Geneva Levi Lúcio SMV & Les Diablerets.
1 Levi Lúcio © A Test Selection Language for CO-OPN Specifications Levi Lúcio, Luis Pedro and Didier Buchs University of Geneva.
Reactive systems – general
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Natallia Kokash (Accepted for PACO’2011) ACG, 31/05/ Input-output conformance testing for channel-based connectors 1.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Semantics In Text: Chapter 3.
Ceg860 (Prasad)LADT1 Specification and Implementation of Abstract Data Types Algebraic Techniques.
1 CSEP590 – Model Checking and Automated Verification Lecture outline for August 6, 2003.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
May University of Glasgow Generalising Feature Interactions in Muffy Calder, Alice Miller Dept. of Computing Science University of Glasgow.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
Chapter 8 Testing. Principles of Object-Oriented Testing Å Object-oriented systems are built out of two or more interrelated objects Å Determining the.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Describing Syntax and Semantics
Software Testing.
Logics for Data and Knowledge Representation
Software Testing (Lecture 11-a)
Algebraic Specification Software Specification Lecture 34
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 algebraic specifications  LOTOS specification language - Abstract data types, terms, denotations - Process algebra, composition of processes  Test generation from LOTOS ADTs - Testing hypotheses - Test suite refinement

Test Generation State of the art: Test generation from  executable code (coverage tools)  scripting languages, e.g. TTCN-3  graphical models, e.g. StateCharts Research problems: Test generation from  UML interaction diagrams  algebraic and logic specification languages  natural language

Specification Based Testing (formal) Specification = (formal) description of the intended behaviour of the SUT  formal = syntax & semantics & algorithms  in a certain sense, FORTRAN and C are formal specification languages  specification need not be executable Specification transformation  refinement and abstraction are relations between different specifications  conformance is a relation between a test suite and a specification or implementation  relation between test suites?

Example Language: Lotos Algebraic specification language (Language of Temporal Ordering Specification)  defined and used in telecommunications  standardised (ISO 8807, 1989)  much theory, some practical examples  supports object-oriented design  extension / variants (e.g. CSP-CASL) Syntax  abstract data type  process algebraic behavior description Semantics  term algebra, equalities impose equivalence partitioning, initial semantics  traces, failures, divergence semantics for process part Algorithms  correctness proofs, model checking  transformational development  test case generation Literatur: Kenneth J. Turner, The Formal Specification Language LOTOS: A Course for Users. CS872/lotos-users.pdf

LOTOS Syntax Abstract data type  data type identifier(s)  functions / operations with type  defining equations Process algebraic behaviour description  recursive process definitions  parallelism and synchronisation / communication

Example: ADT Stack type Stack is Boolean formalsorts Element sorts Stack opns empty : Stack - > Bool emptyStack : - > Stack push : Element, Stack - > Stack peek : Stack - > Element pop : Stack - > Stack eqns forall e: Element, s: Stack ofsort Bool empty(emptyStack) = true; empty(push(e,s)) = false; ofsort Element peek(push(e,s)) = e; ofsort Stack pop(push(e,s)) = s; endtype (* Stack *) Exercise: opn search

Semantics of Terms Term algebra: all well-typed expressions Free algebra („Herbrand-Universum“): no equations, each term is its own denotation Equations induce an equivalence partitioning Several possibilities for the semantics  initial semantics: smallest equivalence partitioning of the free algebra (everything is unequal unless you can show that it‘s equal)  loose semantics: some partitioning which respects the equations

Instantiation Stack corresponds to an abstract class Concrete class: type NatStack is GenericStack actualizedby NaturalNumber using sortnames Nat for Element NatStack for Stack endtype (* NatStack *)

Further LOTOS Possibilities Conditional equations Parametrised Types (abstracte classes) Overloading of functions (polymorphism)  e.g. equality  ofsort for marking the type Renaming and subtyping  type B is A renamedby sortnames... for...

Process Part Extension of ADT‘s by behavioral descriptions Base component: action  internal action: invisible to the outside  observable action: value appears at the connection point (gate) - g!e: sending of expression e via gate g - g?x:s[c]: receiving a new value of type s for variable x at gate g if condition c holds  intuitively: the connection points transmit values of the corresponding abstract data type

Process Definitions Processes are used to denote behaviour  process P […] = … Three main possibilities for composition of processes  sequentialisation: (P>>Q) or (a; P) (a is an action)  alternatives: ([c 1 ]-> P [] [c 2 ]-> Q]  parallelism: (P |[g 1,…,g n ]| Q) (P || Q) and (P ||| Q) are abbreviations for synchronisation on all or no gate Recursive process definitions  stop as regular end (no action executable)  exit as return from a process definition  other syntactical sugaring

Communication, Synchronisation, Coordination (P |[g]| Q) may  either perform an action from P or Q which does not concern g, or  perform a common action on gate g, if it is executable both for P and for Q - Communication: g!e and g?x:s[c] Transmitting the value e to x, if c holds - Synchronisation: g!e 1 and g!e 2 If e 1 = e 2 =e, then e appears at g - Coordination: g?x 1 :s[c 1 ] and g?x 2 :s[c 2 ] At g some value e, appears which satisfies c 1 and c 2

Semantics of Processes If two parallel processes cannot synchronize, deadlock results  g!5 |[g]| g?x:Nat [x>7]  g 1 !5 |[g 1,g 2 ]| g 2 ?x:Nat Event (g,e): executing an action g!e or g?x where x=e Traces(P): set of all sequences of observable events of a process Trace-, failure-, divergence-semantics

Examples for Processes process Boss [in] : noexit = choice item : Nat_Sort [] in!item >> Boss [in] endproc process ToDo [in, out] (liste: Stack) : noexit = (in?item; ToDo[in,out](push(item,liste)) [] [not empty(liste)] -> out!peek(liste); ToDo[in,out](pop(liste)) ) endproc process Slave [out] : noexit = out? x; i >> Slave [out] endproc System specification: Boss |[in]| ToDo |[out]| Slave

Further Language Constructs In the process part, you can use  parameterised processes process P[g 1,g 2 ](p 1 :s 1, p 2 :s 2 ) : exit = … endproc  local variable definitions let name : sorte = expr in...  generalised sequences, alternatives, parallelism expr 1 >> accept pardef in expr 2 choice g in [a1, a2, a3] [ ] B [g] par g in [a1, a2, a3] || B [g]  disabling, hiding, locale processes, … P [> Q, hide g in P, where process P = …  a module concept library importierte Datentypen endlib

LOTOS System Specification specification S [a, b, c, d] : noexit library predefined Data types endlib type ExampleType is sorts ExampleSorts opns ExampleOperations: ExampleSorts - > ExampleSorts endtype behaviour (P [a, b, c] |[b]| Q [b, d]) where process P[a, b, c]... endproc process Q[b, d]... endproc endspec

A Larger Example (part 1)

A Larger Example (part 2) Assume we are given a program which claims to implement this specification. How can we test it? Source: M.-C. Gaudel, P. R. James. Testing Algebraic Data Types and Processes: A Unifying Theory. Formal Aspects of Computing, 10(5-6), (1999) pp

Break?

Test Generation from ADTs Given ADT Spec= (Σ, Eq)  implementation Imp is correct wrt. Spec if all axioms are satisfied for all terms  term-generated models  test case for universally quantified formula is one particular instance Test case: ground instance of axiom  e.g. pop(push(„a“, emptyStack)) = emptyStack  Problem: how to choose terms? Test verdict: evaluation of instance  may be arbitrarily hard, even undecidable  problems: non-primitive data types, partial functions G. Bernot, M.-C. Gaudel, B. Marre: Software testing based on formal specifications: a theory and a tool. Software Engineering Journal Volume 6.6, pp (Nov. 1991)

Procedure for Test Generation Exhaustive test suite: if all tests in the suite pass, then the implementation is correct Testing hypotheses  regularity  uniformity  observational context Complete test suite wrt. test hypothesis Test suite refinement  stronger hypotheses  more errors detected

Exhaustive Test Suites Test suite T: set of ground formulas  Assumption: each object is term generated  Example: s(s(s(z)))=p(s(z),s(s(z))) Test oracle O  T (bzw. O: T  {true,false})  determines for each test case whether it passes or fails (follows from the axioms or not)  e.g. s(s(s(z)))=p(s(z),s(s(z)))  true  in general this problem is undecidable! Exhaustive test suite: a set of test cases, such that the following holds: if all test cases pass, then the implementation is correct  in general infinite  how to find an approximation?

Testing Context Testing context TC: (T, O, H)  test suite T (set of ground terms)  test oracle O  T (or O: T  {true,false})  testing hypothesis H for the implementation H  O=T  Correct(Imp,Spec) Minimal testing hypothesis: „empty assumption“  the set of all derivable ground formulas, or the set of all ground instances of equalities is a complete test suite Maximal testing hypothesis: „Imp is correct“  empty set is a complete test suite

Testing Hypotheses Regularity hypothesis  “The SUT contains no irregularities” Uniformity hypothesis  “the SUT acts uniform on its data” Observability hypothesis  “the SUT data can be identified by finite observations”

Regularity Hypothesis Assume a complexity measure for formulas Regularity hypothesis: If some statement A holds for all formulas up to a certain size , then A holds for all formulas Allows to restrict attention to those test cases smaller than   e.g. p(x,y)=p(y,x) for |x|<3, |y|<3

Uniformity Hypothesis Assume a property of expressions Uniformity hypothesis: If any statement holds for all formulas containing expressions with this property, then it holds for all formulas Generalisation of the regularity hypothesis Allows to restrict test cases to certain variable patterns Application: partitioning of domains extrem case: collapsing a domain to a single representative  cf. abstraction of variables in the previous lecture

Observability Hypothesis (1) Equality of primitive data types (boolean, integer,…) is observable How to observe equality of compound (non-primitive) data types?  special equality function in Imp ?  transfers the problem  component-wise comparison: replace x=y by C 1 (x)=C 1 (y), C 2 (x)=C 2 (y), … Observable context: Mapping of compound to primitive data type Leibnitz‘s extensionaly principle: two object are identical if they behave equally in each observable context

Observability Hypothesis (2) Leibnitz‘ principle can be used for testing Problem: „very many“ possible contexts Fix a set of contexts for each compound data type Observability hypothesis: If any statement holds for all observable contexts, than it holds for all formulas special case of uniformity hypothesis Allows reduction to primitive comparisons Example: top and second stack element, hash or similar

Test Suite Refinement TC 2 refines TC 1 (TC 2 <TC 1 ), if  TC 2 has stronger hypotheses than TC 1 H 2  H 1  TC 2 can discover at least as many faults as TC 1 failed(T 1,Imp)  failed(T 2,Imp)  TC 2 has more passed tests than TC 1 pass(T 2,Imp)  pass(T 1,Imp) The set of all ground terms with empty testing hypothesis is the largest test suite in this partial order Test case development = Adding hypotheses to this largest test suite

Method of Refinement Starting with the exhaustive test suite, add  Regularity hypotheses for defined types  Uniformity hypotheses for imported types  Observation functions and -hypotheses for compound types … until the test suite is complete and the oracle is decidable and well-defined Tool support possible

Example Uniformity hypothesis „all variables equal“ yields 4 test cases „Unfolding“ of Pack yields new test cases

Testing the process part For ADT  correctness of Imp wrt. Spec = all equations / formulas of Spec are satisfied by Imp For PA  correctness defined by observable behaviour  simulation or containment of behaviour  ioco

Test generation for Full Lotos One test suite for the data part and one for the process part Use of the data type properties in testing of the processes  Example: Splitting <= into < and =  Example: Size(ε)=0, Size(o.m)=… yields four test cases for the process part [Size(x)+Size(y) …  Calculation of limit values from the equations

Some test cases for the example Find tests for Compact(7): Uniformity hypotheses and representative values for Max, newMax, and Size(x)+Size(y)>Max Research: systematic derivation by an algorithm

Non implementable specification