Technology of Test Case Generation Levi Lúcio University of Geneva Marko Samer Vienna University of Technology.

Slides:



Advertisements
Similar presentations
1 Verification by Model Checking. 2 Part 1 : Motivation.
Advertisements

Chapter 3 Objects, types, and values Bjarne Stroustrup
.NET Technology. Introduction Overview of.NET What.NET means for Developers, Users and Businesses Two.NET Research Projects:.NET Generics AsmL.
Auto-Generation of Test Cases for Infinite States Reactive Systems Based on Symbolic Execution and Formula Rewriting Donghuo Chen School of Computer Science.
Applications of Synchronization Coverage A.Bron,E.Farchi, Y.Magid,Y.Nir,S.Ur Tehila Mayzels 1.
Delta Debugging and Model Checkers for fault localization
A System to Generate Test Data and Symbolically Execute Programs Lori A. Clarke September 1976.
PLDI’2005Page 1June 2005 Example (C code) int double(int x) { return 2 * x; } void test_me(int x, int y) { int z = double(x); if (z==y) { if (y == x+10)
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Hand Trace and Output for: int digit = 0; int number = 1423; do { digit = number % 10; System.out.println(digit); number = number / 10; } while (number.
1 T.Y. Chen Swinburne University of Technology, Australia T.H. Tse and Zhiquan Zhou The University of Hong Kong Semi-Proving: an Integrated Method Based.
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
LIFE CYCLE MODELS FORMAL TRANSFORMATION
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
Programming recap. Do you know these? LOW LEVEL 1 st generation: machine language (110011) 2 nd generation: assembly language (ADD, SUB) HIGH LEVEL 3.
Overview. What is Computer Programming? It is the process of planning a sequence of steps (called instructions) for a computer to follow. 2 STEP 1 STEP.
The Software Model Checker BLAST by Dirk Beyer, Thomas A. Henzinger, Ranjit Jhala and Rupak Majumdar Presented by Yunho Kim Provable Software Lab, KAIST.
Commutativity Analysis: A New Analysis Technique for Parallelizing Compilers Martin C. Rinard Pedro C. Diniz April 7 th, 2010 Youngjoon Jo.
Prof. Busch - LSU1 Decidable Languages. Prof. Busch - LSU2 Recall that: A language is Turing-Acceptable if there is a Turing machine that accepts Also.
4 July 2005 overview Traineeship: Mapping of data structures in multiprocessor systems Nick de Koning
Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages.
Character String Predicate Based Automatic Software Test Data Generation Ruilian Zhao Computer Science Dept. Beijing University of Chemical Technology.
Recursively Enumerable and Recursive Languages
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
Low Density Parity Check Codes LDPC ( Low Density Parity Check ) codes are a class of linear bock code. The term “Low Density” refers to the characteristic.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Fall 2005Costas Busch - RPI1 Recursively Enumerable and Recursive Languages.
Parameterizing Random Test Data According to Equivalence Classes Chris Murphy, Gail Kaiser, Marta Arias Columbia University.
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
AUTOMATIC CONCOLIC TEST GENERATION WITH VIRTUAL PROTOTYPES FOR POST-SILICON VALIDATION Reviewer: Shin-Yann Ho Instructor: Jie-Hong Jiang.
Formal Techniques for Verification Using SystemC By Nasir Mahmood.
1 Presenter: Ming-Shiun Yang Sah, A., Balakrishnan, M., Panda, P.R. Design, Automation & Test in Europe Conference & Exhibition, DATE ‘09. A Generic.
1/20 Symbolic Execution and Program Testing Charngki PSWLAB Symbolic Execution and Program Testing James C.King IBM Thomas J.Watson Research Center.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
1 A Static Analysis Approach for Automatically Generating Test Cases for Web Applications Presented by: Beverly Leung Fahim Rahman.
Using Execution Paths to Evolve Software Patches ThanhVu Nguyen*, Westley Weimer**, Claires Le Gouges**, Stephanie Forrest* * University of New Mexico.
CSC 338: Compiler design and implementation
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
Composition of UML Described Refactoring Rules Presented by Chin-Yi Tsai.
Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
Chapter 3 Part II Describing Syntax and Semantics.
Formal Verification of Synchronization Issues of SpecC Description with Automatic Abstraction Thanyapat Sakunkonchak Masahiro Fujita Department of Electronics.
A System to Generate Test Data and Symbolically Execute Programs Lori A. Clarke Presented by: Xia Cheng.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:
A Test Case + Mock Class Generator for Coding Against Interfaces Mainul Islam, Christoph Csallner Software Engineering Research Center (SERC) Computer.
W1-1 University of Washington Computer Programming I Recursion © 2000 UW CSE.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Recursively Enumerable and Recursive Languages
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
Software Architecture for Multimodal Interactive Systems : Voice-enabled Graphical Notebook.
Introduction to Automata Theory
Introduction to Automata Theory
High Coverage Detection of Input-Related Security Faults
Introduction to Computer Programming
Verify that the function satisfies the three hypotheses of Rolle's Theorem on the given interval. Then find all numbers c that satisfy the conclusion of.
Finding the equation of a line
Decidable Languages Costas Busch - LSU.
Patterns to KNOW.
A Trusted Safety Verifier for Process Controller Code
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
SOFTWARE ENGINEERING INSTITUTE
Presentation transcript:

Technology of Test Case Generation Levi Lúcio University of Geneva Marko Samer Vienna University of Technology

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Overview Introduction Model Checking Symbolic Execution Theorem Proving Conclusions

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Introduction In this presentation three technologies for test case generation are introduced; –Symbolic Execution; –Theorem Proving; –Model Checking (presentation not available); All the models used by these methods can be reduced to state machines; Test case generation can be seen as state space exploration for traces obeying a criteria.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Overview Introduction Model Checking Symbolic Execution Theorem Proving Conclusions

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Overview Introduction Model Checking Symbolic Execution Theorem Proving Conclusions

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Symbolic Execution Talk Overview The technique –How symbolic execution works; –Issues related to the approach; –Symbolic execution of abstract models; Test case generation –A classification of test case generation frameworks using symbolic execution; –Abstract model based test case generation; –Code based test case generation.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Symbolic Execution Technique invented in the 1970s for verifying the consistency of code; The main principle consists of executing the code with symbolic inputs… … in which a symbolic input consists of replacing a « real input » (number, string, structure, object) with a symbol; For example, if the program asks a number to the user, «  » would be passed to the program as a representation of all possible numbers.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation The technique Allows exploring the possible control paths in an program. Calculates the path condition for each control path, composed of symbolic equations. Int foo (int a, int b) { 1a++; 2if (a>b) 3 a=a-b; 4else 5 a=b-a; 6if (a<=-1) 7 a=-a; 8return a } Control paths for foo 1,2,3,6,7,8 1,2,3,6,8 1,2,5,6,7,8 1,2,5,6,8

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation The technique (cont) a:  b:  PC: True a:  +1  b:  PC: True (1) a:  b:  PC:  (3) (8) a:  b:  PC:  a:  b:  PC:  a:  b:  PC:  (2 -true)(2 - false) … a:  b:  PC:  a:  b:  PC:  (6 - true)(6 - false) No solution for PC equations: Infeasible Control Path (search backtracks) Int foo (int a, int b) { 1a++; 2if (a>b) 3 a=a-b; 4else 5 a=b-a; 6if (a<=-1) 7 a=-a; 8return a }

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation The technique (cont) From the symbolic execution of foo, one can retrieve the following information: Control PathPath Condition 1,2,3,6,7,8  Not feasible 1,2,3,6,8    1,2,5,6,7,8  Not feasible 1,2,5,6,8    Each path condition fully documents the decisions taken during the execution of the code.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test case generation It is possible to generate test cases by finding values that satisfy the path condition equations: Control PathPath ConditionExample test case 1,2,5,6,8  Test case (a=1, b=3) would force the execution of foo to follow the control path 1,2,5,6,8; Test cases are thus created as by-products of the activity of symbolic execution; Symbolic execution uncovered that in the case of foo instruction 7 is never reached...

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Issues related to the approach Dealing with loops –Loops generate infinite control paths (unless the number of iterations is known). Solution? Prompt the user at each loop iteration; Establish an upper bound for the number of iterations; Try to automatically find a fixed point to the loop (costly). Solving path condition equations –Necessary for: understanding when a path is infeasible; generating test cases. –Algorithms heavy on computing resources.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Symbolic execution of abstract models Up until now we have considered symbolic execution only as a “white box” verification technique… However, nothing prevents from applying the same technique to an abstract model (state machine) Code Abstract Model (state machine) Symbolic Execution Test Cases State space of a model can be symbolically searched for interesting control paths; Symbolic execution reduces state space explosion by associating classes of inputs.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Symbolic execution for test case generation In the text several frameworks for test case generation from different models of the application are studied; We classify the frameworks according to two axis: Application model Synergies with other verification techniques Model Checking Theorem proving Abstract (B, AUTOFOCUS, CO-OPN), Code (Java)

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Abstract model based test case generation In the text three frameworks are described that have their starting point on different abstract models: –B(framework from Legeard, Peureux et al) –AUTOFOCUS(framework from Pretschner et al) –CO-OPN(framework from Buchs et al) The models can be considered as state machines and the technique for test case generation is similar: Abstract Model (state machine) Logic Programming Model Test Cases Translation step Symbolic state space search

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Abstract model based test case generation (cont) The step of translation into a logic programming language (theorem prover) is necessary to: –Animate the (static) abstract specification; –Search the state space; –Perform symbolic execution. Two kinds of logic programming languages may be used: –Pure Prolog; –Constraint Logic Programming (CLP) Languages: enabled to deal with numeric constraints at the unification level.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test generation from an Abstract Model Example The specification language chosen is B - supports development of C code from an abstract model; In B an application can be seen as a state machine: –States: defined by state variables; –Transitions: parameterized operations. Framework from Legeard et al divides the activity of test case generation into three steps: –Translating B into CLPS-B (custom CLP language); –Calculate boundary states for the application; –Generate the test case traces through the state space.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test generation from an Abstract Model Example (cont) In a boundary state one or more state variables assume a boundary value; Calculation of boundary values is done by partitioning the domain of state variables (by symbolic execution): Successive operations pose the following constraints on a given state variable x with enumerated domain [1..10]: x  {1,2,3,4,5} x ≠ 3 P-Domain {1,2,3} U {3} U {3,4,5} U {5,…,10} Boundary Values (extremes of the P-Domain’s subsets) {1,3,5,10}

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test generation from an Abstract Model Example (cont) Traces that represent interesting test cases are then generated as follows : –Calculate the preamble trace to the boundary state; –Calculate the “body invocation” step; –Calculate the identification traces. Initial State Boundary State 1 Boundary State 2 Boundary State 3 Final state of body 1.1 Final state of identification Final state of body 1.2 Final state of body 1.3 Final state of identification Final state of identification Preamble traces Body invocation traces Identification traces An instantiation phase of the concatenated traces is necessary to create the “real” tests; Until then only the path condition exists.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test generation from an Abstract Model Example 2 – AUTOFOCUS AUTOFOCUS is a CASE tool inspired from UML-RT (real time) and directed towards embedded systems; In this paradigm a system is defined as a hierarchic network of components, represented by state machines: a.1 a.2 a.3 a b.1 b.2 b c System Highest level component Lowest level component

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test generation from an Abstract Model Example 2 – AUTOFOCUS (cont) Framework from Pretschner et al considers three possible test coverage classes: –Functional: covers the specification’s execution scenarios; –Structural: e.g. test critical components of the system; –Stochastic: generate random state space traces. The coverage heuristics are annotated in the specification;

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test generation from an Abstract Model Example 2 – AUTOFOCUS (cont) AUTOFOCUS specification is translated into a CLP language for animation. Each transition of a bottom level component K is modeled into a formula of type: Interesting traces (according to coverage heuristics) are generated by symbolic execution over system inputs. Instantiation of symbolic traces is the last step… step K (  src  dst )  guard( ,  src ) and assgmt(o,  dst ) A transition of a non-bottom level component is a composition of the transitions of it’s sub-components.

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Code based test case generation Why take a detour from model based test case generation (title of the section)? In the text we present a framework from Khurshid et al that generates test cases from Java code. It uses: –A model checker (Java PathFinder) to overcome some difficulties in symbolic execution; –The symbolic execution technique to overcome some difficulties in model checking. We think an insight on the framework is enriching for the discussion…

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test generation from code Example Symbolic execution helps dealing with state space explosion by dealing with inputs as classes of values; Model checking deals automatically with loops, recursion or method invocation… Model Checker Logic Formulas State Space Witness Trace Counter-example Trace Formulas holdFormulas don’t hold

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Test generation from code Example (cont) The code is instrumented to deal with symbolic values and accumulate path conditions (via Java libraries): Java Code Instrumented Java code Test case traces Java Symbolic Execution libraries Model checking The algorithm that performs symbolic execution knows how to deal with complex dynamic structures (objects)! A phase of test case instantiation is required…

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Overview Introduction Model Checking Symbolic Execution Theorem Proving Conclusions

H. S. Hong, L. Lúcio, M. Samer: Technology of Test Case Generation Overview Introduction Model Checking Symbolic Execution Theorem Proving Conclusions