White Box Testing and Symbolic Execution Written by Michael Beder.

Slides:



Advertisements
Similar presentations
Software Testing Technique. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves.
Advertisements

Unit-V testing strategies and tactics.
Chapter 14 Testing Tactics
NP-Hard Nattee Niparnan.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
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.
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
Software Failure: Reasons Incorrect, missing, impossible requirements * Requirement validation. Incorrect specification * Specification verification. Faulty.
1 Static Testing: defect prevention SIM objectives Able to list various type of structured group examinations (manual checking) Able to statically.
White Box Testing and Symbolic Execution Written by Michael Beder.
White Box Testing and Symbolic Execution Written by Michael Beder.
Testing an individual module
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
Testing Dr. Andrew Wallace PhD BEng(hons) EurIng
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
Software Systems Verification and Validation Laboratory Assignment 3
System/Software Testing
CMSC 345 Fall 2000 Unit Testing. The testing process.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
White-Box Testing Eshcar Hillel Michael Beder. White Box Testing 2 Tutorial Outline What is White Box Testing? Flow Graph and Coverage Types Symbolic.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
CSC 480 Software Engineering Lecture 14 Oct 16, 2002.
1 Program Correctness CIS 375 Bruce R. Maxim UM-Dearborn.
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.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Software Testing Input Space Partition Testing. 2 Input Space Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Chapter 3 Part II Describing Syntax and Semantics.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic.
Testing Chapter 23 IB103 Week 12 (part 3). Verify that a complex (any) program works correctly, that the program meets specifications The chapter reviews.
Theory and Practice of Software Testing
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Dynamic Testing.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
White Box Testing by : Andika Bayu H.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
SOFTWARE TESTING SOFTWARE TESTING Presented By, C.Jackulin Sugirtha-10mx15 R.Jeyaramar-10mx17K.Kanagalakshmi-10mx20J.A.Linda-10mx25P.B.Vahedha-10mx53.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
CS223: Software Engineering Lecture 26: Software Testing.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 8: Static Analysis II Roman Manevich Ben-Gurion University.
Software Testing. Software Quality Assurance Overarching term Time consuming (40% to 90% of dev effort) Includes –Verification: Building the product right,
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
A Review of Software Testing - P. David Coward
Software Testing.
Software Testing.
Software Testing.
Software Engineering (CSI 321)
Software Testing and Maintenance 1
Structural testing, Path Testing
Formal Methods in Software Engineering 1
Types of Testing Visit to more Learning Resources.
Software Development Cycle
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
Chapter 10 – Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Institute of Computing Tech.
The Zoo of Software Security Techniques
Software Development Cycle
Whitebox Testing.
CSE 1020:Software Development
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

White Box Testing and Symbolic Execution Written by Michael Beder

White Box Testing and Symbolic Execution 2 Agenda What is White Box Testing? Flow Graph and Coverage Types Symbolic Execution: – Formal Definition –Examples – Questions

White Box Testing and Symbolic Execution 3 What is White Box Testing? Software testing approach that uses inner structural and logical properties of the program for verification and deriving test data Also called: Clear Box Testing, Glass Box Testing and Structural Testing Manual: Inspection, Walkthrough Automatic: Syntax Parser, Symbolic Execution

White Box Testing and Symbolic Execution 4 Pros and Cons Pros: Usage of more information on the tested object (than BlackBox) Inference of real Equivalence Partitioning Structural Coverage Assurance Cons: Expensive Limited Semantic Coverage

White Box Testing and Symbolic Execution 5 Example I Sin(x) { if (|x| < eps) return x; if (|x| < 5*eps) return x – (x^3)/6; … } Black Box Testing: Test 0, Pi/2, -Pi/2 White Box Testing: Test 0.5*eps, eps, 3*eps, 5*eps, 7*eps, … Usage of logical properties makes better coverage

White Box Testing and Symbolic Execution 6 Example II: Unit Testing f(x)g(x) {h(x) { {…… if (x > 0) return g(x);}} return h(x); } Black Box Testing: Test f(x), g(x), h(x) for every x White Box Testing: Test g(x) for x > 0, h(x) for x <= 0 and verify f(x) Usage of structural properties makes fewer, qualitative tests

White Box Testing and Symbolic Execution 7 Flow Graph Abstraction of the program Defines the data and control flow in the program Uniform representation of the program, language independent Simple basic elements: assignment and condition Further analysis is performed using graph algorithms

White Box Testing and Symbolic Execution 8 Flow Graph – cont. G = (V, E) where - V is a set of basic blocks. start, end in V - E is a set of control branches Example: 1 a = Read(b) 2 c = 0 3 while (a > 1) { 4If (a^2 > c) 5c = c + a 6a = a - 2 } 1, 2345endstart T T 6 F F Input: b = 2 Output: a = 0, c = 2

White Box Testing and Symbolic Execution 9 Basic Path Set Let p1, p2 be paths from start to end. Then, p1 < p2 if there exists a vertex v that belongs to p2 and not to p1 A basic path set is a maximal set of paths p1, p2, …, pk such that pi < pj for i < j

White Box Testing and Symbolic Execution 10 White Box Coverage Types Statement Coverage: Every statement is executed Branch Coverage: Every branch option is chosen Path Coverage: Every path is executed Basic Path Coverage: Every basic path is executed Loops?

White Box Testing and Symbolic Execution 11 Basic Path Coverage Basic path set is of size E – N + 2 (Linear Complexity) Each path is called “basic path” Example: p1 = start – 1,2 – 3 – end p2 = start – 1,2 – 3 – 4 – 6 – 3 – end p3 = start – 1,2 – 3 – 4 – 5 – 6 – 3 – end E – N + 2 = 8 – = 3 1, 2345endstart T T 6 F F

White Box Testing and Symbolic Execution 12 Path Function A function, when D is the working domain Represents the current values of the variables as function of their initial values Each variable X is represented by a projection function Function composition: For example:

White Box Testing and Symbolic Execution 13 Path Condition A condition that should be fulfilled for going along the path A constraint on the initial values of the variables For Example: p = start – 1,2 – 3 – end. 1 a = Read(b) 2 c = 0 3 while (a > 1) { 4If (a^2 > c) 5c = c + a 6a = a - 2 } The path condition is B <= 1, when B is b’s value at start 1, end start T T 6 F F

White Box Testing and Symbolic Execution 14 Symbolic Execution A method for deriving test cases which satisfy a given path Performed as a simulation of the computation on the path Initial path function = Identity function, Initial path condition = true Each vertex on the path induce a symbolic composition on the path function and a logical constraint on the path condition: If an assignment was made: If a conditional decision was made: path condition path condition branch condition Output: path function and path condition for the given path

White Box Testing and Symbolic Execution 15 Example: Symbolic Composition x = x + y y = y + x end The final path function represents the values of X, Y, Z after both assignments as a function of their initial value

White Box Testing and Symbolic Execution 16 Concatenation and Associativity If is the path function of path and is the path function of path then is the path function of path The composition is associative: Symbolic Execution is a special case when V1 VnVk

White Box Testing and Symbolic Execution 17 Example: Symbolic Execution 1 a = Read(b) 2 c = 0 3 while (a > 1) { 4If (a^2 > c) 5c = c + a 6a = a - 2 } Find test case for path: p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end 1, end start T T 6 F F input = b output = c

White Box Testing and Symbolic Execution 18 Example: Symbolic Execution 1, 2345endstart T T 6 F F 1 a = Read(b) 2 c = 0 3 while (a > 1) { 4If (a^2 > c) 5c = c + a 6a = a - 2 } p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end vertexpath functionpath condition start: (A, B, C) true 1,2 (A, B, C) true 3 (B, B, 0) true 4 (B, B, 0) (true Λ B>1) ↔ B>1 5 (B, B, 0) (B>1 Λ B^2>0) ↔ B>1 input = b output = c

White Box Testing and Symbolic Execution 19 Example: Symbolic Execution 1, 2345endstart T T 6 F F 1 a = Read(b) 2 c = 0 3 while (a > 1) { 4If (a^2 > c) 5c = c + a 6a = a – 2 } p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end vertex path function path condition 6(B, B, B) B>1 3(B-2, B, B) B>1 4(B-2, B, B)(B>1 Λ B-2>1) ↔ B>3 5(B-2, B, B) (B>3 Λ (B-2)^2>B) ↔ B>4 6(B-2, B, 2B-2) B>4 3(B-4, B, 2B-2) B>4 end (B-4, B, 2B-2) (B>4 Λ B-4<=1) ↔ B=5 input = b output = c

White Box Testing and Symbolic Execution 20 Example: Symbolic Execution 1, end start T T 6 F F 1 a = Read(b) 2 c = 0 3 while (a > 1) { 4if (a^2 > c) 5c = c + a 6a = a – 2 } p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end end (B-4, B, 2B-2) B=5 Hence the test case is B = 5 and the expected result is 2B-2 = 8. Is there a test case for p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end ? input = b output = c

White Box Testing and Symbolic Execution 21 Question (from exam) 1d = b + c; 2if (d > 20) 3a = 3 * a + d; 4if (b < a) { 5 a = 1; 6 if (d < 2 * b) 7 b = 2; 8} 1.Draw program’s Flow Graph 2.Find minimal number of test cases for the following coverage types: a)Statement Coverage b)Path Coverage c)Branch Coverage d)Basic Path Coverage

White Box Testing and Symbolic Execution 22 White Box Testing vs. Black Box Testing Given a function f(X1, X2, …, X10) with the following preconditions: 1.Every parameter is odd 2.Every parameter is less or equal to M 3.Some parameter is equal to M The function should report about every precondition that is not fulfilled f examines each parameter in turn using if statements (without else) and handles differently the following cases: a.Exactly one parameter is higher than M b.Two or more parameters are higher than M Check f’s correctness using White/Black Box Testing methods