Dataflow Testing. Dataflow Testing. Dataflow Analysis. Definitions. Definitions 2. Definitions 3

Similar documents
Dataflow Testing. Definitions 2

Dataflow Testing. Chapter 9!

Dataflow Testing. Chapter 10!

CSCE 747 Software Testing and Quality Assurance

Topics in Data-Flow Testing

What is Structural Testing?

Testing Theory. Agenda - What will you learn today? A Software Life-cycle Model Which part will we talk about today? Theory Lecture Plan

Testing Methods: White Box Testing II

Software Testing. 1. Testing is the process of demonstrating that errors are not present.

Software Verification and Validation. Prof. Lionel Briand Ph.D., IEEE Fellow

Data Flow Coverage 1. Stuart Anderson. Stuart Anderson Data Flow Coverage 1 c 2011

CMPSCI 521/621 Homework 2 Solutions

Data Flow Testing. Mohammad Mousavi. Testing and Verification, February 2 nd, University of Leicester, UK and GU/Chalmers, Sweden

Dataflow-based Coverage Criteria

Path Testing + Coverage. Chapter 8

Name: Per: Date: Intermediate Computers - Standard 5 Programming Checklist. again" if they got it wrong. Pay attention to the IF/THEN

A Walkthrough of the Learning Aids

White Box Testing III

INTRODUCTION TO SOFTWARE ENGINEERING

White-Box Testing Techniques II

White-Box Testing Techniques

Data Flow Testing. CSCE Lecture 10-02/09/2017

(See related materials in textbook.) CSE 435: Software Engineering (slides adapted from Ghezzi et al & Stirewalt

Live Variable Analysis. Work List Iterative Algorithm Rehashed

MTAT : Software Testing

MTAT : Software Testing

Question Bank. Unit 1: Perspective on Testing, Examples. Chapter 1 & 2 from Dr. Paul C. Jorgensen

CS 4387/5387 SOFTWARE V&V LECTURE 4 BLACK-BOX TESTING

SOQUA Automated Generation and Evaluation of Dataflow-based Test Data for Object-Oriented Software. Norbert Oster

Verification Overview Testing Theory and Principles Testing in Practice. Verification. Miaoqing Huang University of Arkansas 1 / 80

MTAT : Software Testing

Program Structure. Simple Statements. Program consists of blocks Block. Can be represented by a flow graph. Sequence of statements

Program Structure. Simple Statements. Program consists of blocks Block. Can be represented by a flow graph. Sequence of statements

Introduction to Dynamic Analysis

A Comparison of Some Structural Testing Strategies

ISO26262 This Changes Everything!

Enhanced Representation Of Data Flow Anomaly Detection For Teaching Evaluation

MTAT : Software Testing

MSc Software Testing MSc Prófun hugbúnaðar

FOR INTERNAL SCRUTINY (date of this version: 17/2/2016) UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS

Lecture 17: Testing Strategies. Developer Testing

Dataflow testing of Java programs with DFC

Register allocation. Register allocation: ffl have value in a register when used. ffl limited resources. ffl changes instruction choices

MTAT : Software Testing

6. Test-Adequacy. Assessment Using Control Flow and Data Flow. Andrea Polini

What s Next INF 117 Project in Software Engineering

Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn. 4. Testing

Maximum Contiguous Subsequence Sum. Check out from SVN: MCSSRaces

Data Flow Testing of UML State Machine Using Ant Colony Algorithm (ACO)

Identify skills and personality traits of successful problem solving. Apply standard problem-solving techniques to aid in problem solving.

Program Analysis. Program Analysis

Lecture 18: Structure-based Testing

BSc (Hons) Computer Science with Network Security/ BSc (Hons) Software Engineering/ BSc (Hons) Web Technologies. Examinations for 2016 Semester 1

MTAT : Software Testing

Using the code to measure test adequacy (and derive test cases) Structural Testing

Data Flow Analysis. Daqing Hou

Software Testing. Software Testing

6.0 ECTS/4.5h VU Programm- und Systemverifikation ( ) June 22, 2016

1. What does the following code fragment write to the monitor?

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Class-Component Testability Analysis

ECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam Solutions 14 December 2016

Data Flow Analysis. CSCE Lecture 9-02/15/2018

More Dataflow Analysis

A main goal is to achieve a better performance. Code Optimization. Chapter 9

Control and Data Flow Testing on Function Block Diagrams

CS 520 Theory and Practice of Software Engineering Fall 2018

Overview Graph Coverage Criteria

Test Path Selection Based on Effective Domains*

CSci 1113 Midterm 1. Name: Student ID:

Part I: Preliminaries 24

Chapter 1: Review of Number Systems

Grades. Notes (by question) Score Num Students Approx Grade A 90s 7 A 80s 20 B 70s 9 C 60s 9 C

Automatic Generation of Data Flow Test Paths using a Genetic Algorithm

EECS 481 Software Engineering Exam #1. You have 1 hour and 20 minutes to work on the exam.

Static Analysis methods and tools An industrial study. Pär Emanuelsson Ericsson AB and LiU Prof Ulf Nilsson LiU

Testing: (A Little) Logic Coverage

Better Histograms Using Excel. Michael R. Middleton School of Business and Management, University of San Francisco

Multi-Criteria Decision Making 1-AHP

CSE 307: Principles of Programming Languages

Software Engineering

Three General Principles of QA. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Program Testing and Analysis: Manual Testing Prof. Dr. Michael Pradel Software Lab, TU Darmstadt

Cisc320 Homework 3 Solutions. Question 1: Original. Insert 170. Insert 34. TA: Matt Saponaro

Darshan Institute of Engineering & Technology for Diploma Studies

Testing Role in Unified Approach Coverage: Structural/Coverage Model Based Test Generation from Model Checking (project) Interaction of

Software Engineering Theory. Lena Buffoni (slides by Kristian Sandahl/Mariam Kamkar) Department of Computer and Information Science

The Big Picture. Chapter 3

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Properties of Criteria. 1. Applicability Property. Criteria

[Page 177 (continued)] a. if ( age >= 65 ); cout << "Age is greater than or equal to 65" << endl; else cout << "Age is less than 65 << endl";

Software Testing: Introduction

Introduction to Software Testing Chapter 5.1 Syntax-based Testing

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

Software Quality Assurance Dynamic Test

SFWR ENG 3S03: Software Testing

EXAMINING THE CODE. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist:

PESIT Bangalore South Campus SOLUTION

Lecture 3 Local Optimizations, Intro to SSA

CSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

Transcription:

Dataflow Testing Dataflow Testing Testing All-Nodes and All-Edges in a control flow graph may miss significant test cases Testing All-Paths in a control flow graph is often too timeconsuming Chapter 9 Can we select a subset of these paths that will reveal the most faults? Dataflow Testing focuses on the points at which variables receive values and the points at which these values are used DFT 2 Dataflow Analysis Definitions Can reveal interesting bugs A variable that is defined but never used A variable that is used but never defined A variable that is defined twice before it is used Sending a modifier message to an object more than once between accesses Deallocating a variable before it is used Container problem Deallocating container loses references to items in the container, memory leak A node n in the program graph is a defining node for variable v DEF(v, n) if the value of v is defined at the statement fragment in that node Input, assignment, procedure calls A node in the program graph is a usage node for variable v USE(v, n) if the value of v is used at the statement fragment in that node Output, assignment, conditionals DFT 3 DFT 4 Definitions 2 Definitions 3 A usage node is a predicate use, P-use, if variable v appears in a predicate expression Always in nodes with outdegree 2 A usage node is a computation use, C-use, if variable v appears in a computation A node in the program is a kill node for a variable v KILL(v, n) if the variable is deallocated at the statement fragment in that node Always in nodes with outdegree 1 DFT 5 DFT 6 1

Example 2 Billing program Definition-Use path calculatebill (usage : INTEGER) : INTEGER double bill = 0; if usage > 0 then bill = 40 fi if usage > 100 then if usage 200 then bill = bill + (usage 100) *0.5 else bill = bill + 50 + (usage 200) * 0.1 if bill 100 then bill = bill * 0.9 fi fi fi return bill end Kill node for bill What is a du-path? DFT 7 DFT 8 Definition-Use path 2 Definition clear path What is a du-path? What is a dc-path? A definition-use path, du-path, with respect to a variable v is a path whose first node is a defining node for v, and its last node is a usage node for v DFT 9 DFT 10 Definition clear path 2 Example 1 Max program What is a dc-path? A du-path with no other defining node for v is a definition-clear path A definition of j 1 int max = 0; 2 int j = s.nextint(); Definitions 3 while (j > 0) P-uses of j & max of max 4 if (j > max) { A C-use of j 5 max = j; 6 } 7 j = s.nextint(); A C-use of max 8 } A definition of j 9 System.out.println(max); DFT 11 DFT 12 2

Max program analysis Dataflow Coverage Metrics A Legend A..F Segment name d defining node for j u use node for j int max = 0; int j = s.nextint(); B u while (j > 0) F C u if (j > max) D u max = j; E d j = s.nextint(); System.out.println(max); d dc-paths j A B A B C A B C D E B E B C E B C D dc-paths max A B F A B C D E B C D E B F Based on these definitions we can define a set of coverage metrics for a set of test cases We have already seen All-Nodes All-Edges All-Paths Data flow has additional test metrics for a set T of paths in a program graph All assume that all paths in T are feasible DFT 13 DFT 14 All-Defs Criterion All-Uses Criterion The set T satisfies the All-Uses criterion iff The set T satisfies the All-Def criterion For every variable v, T contains a dc-path from every defining node for v to at least one usage node for v Not all use nodes need to be reached v V (P),nd prog_ graph(p) DEF(v,nd) nu prog_ graph(p) USE(v,nu) dc _ path(nd,nu) T For every variable v, T contains dc-paths that start at every defining node for v, and terminate at every usage node for v Not DEF(v, n) USE(v, n) not possible to have a dcpath from every defining node to every usage node ( v V (P),nu prog_ graph(p) USE(v,nu) nd prog_ graph(p) DEF(v,nd) dc _ path(nd,nu) T) all _ defs_ criterion DFT 15 DFT 16 All-P-uses / Some-C-uses All-C-uses / Some-P-uses The set T satisfies the All-P-uses/Some-C-uses criterion iff For every variable v in the program P, T contains a dcpath from every defining node of v to every P-use node for v If a definition of v has no P-uses, a dc-path leads to at least one C-use node for v The test set T satisfies the All-C-uses/Some-P-uses criterion iff For every variable v in the program P, T contains a dcpath from every defining node of v to every C-use of v If a definition of v has no C-uses, a dc-path leads to at least one P-use ( v V (P),nu prog_ graph(p) P _ use(v,nu) nd prog_ graph(p) DEF(v,nd) dc _ path(nd,nu) T) all _ defs_ criterion ( v V (P),nu prog_ graph(p) C _ use(v,nu) nd prog_ graph(p) DEF(v,nd) dc _ path(nd,nu) T) all _ defs_ criterion DFT 17 DFT 18 3

Miles-per-gallon Program Miles-per-gallon Program 2 miles_per_gallon ( miles, gallons, price : INTEGER ) if gallons = 0 then // Watch for division by zero Print( You have + gallons + gallons of gas ) else if miles/gallons > 25 fi end then print( Excellent car. Your mpg is + miles/gallon) else print( You must be going broke. Your mpg is + miles/gallon + cost + gallons * price) We want du- and dc-paths What do you do next? DFT 19 DFT 20 Mile-per-gallon Program Segmented Miles-per-gallon Program 3 gasguzzler (miles, gallons, price : INTEGER) A if gallons = 0 then B // Watch for division by zero C Print( You have + gallons + gallons of gas ) else if miles/gallons > 25 D then print( Excellent car. Your mpg is E + miles/gallon) else print( You must be going broke. Your mpg is F + miles/gallon + cost + gallons * price) fi G end We want du- and dc-paths What do you do next? DFT 21 DFT 22 MPG program graph MPG program graph Def miles, gallons What do you do now? P-use gallons C-use gallons C-use miles, gallons P-use miles, gallons Possible C-use miles, gallons But not common practice C-use miles, gallons, price DFT 23 DFT 24 4

Miles-per-gallon Program 4 Example du-paths For each variable in the miles_per_gallon program create the test paths for the following dataflow path sets We want du- and dc-paths All-Defs (AD) All-C-uses (ACU) What do you do next? All-P-uses (APU) All-C-uses/Some-P-uses (ACU+P) All-P-uses/Some-C-uses (APU+C) All-uses DFT 25 DFT 26 MPG DU-Paths for Miles MPG DU-Paths for Miles 2 All-Defs All-P-uses Each definition of each variable for at least one use of the definition At last one path of each variable to each p-use of the definition A B D A B D All-C-uses All-C-uses/Some-P-uses At least one path of each variable to each c-use of the definition A B D E A B D F A B D At least one path of each variable definition to each c- covered use p-use A B D E A B D F A B D DFT 27 DFT 28 MPG DU-Paths for Miles 3 MPG DU-Paths for Gallons All-Defs All-P-uses/Some-C-uses Each definition of each variable for at least one use of the definition A B At least one path of each variable definition to each p- covered by p-use, then use c-use A B D All-C-uses At least one path of each variable to each c-use of the definition A B C A B D E A B D F A B D All-uses At least one path of each variable definition to each p- use and each c-use of the definition A B D A B D E A B D F DFT 29 DFT 30 5

MPG DU-Paths for Gallons 2 MPG DU-Paths for Gallons 3 All-P-uses All-P-uses/Some-C-uses At least one path of each variable definition to each p- use of the definition A B A B D At least one path of each variable definition to each p- covered use c-use A B A B D All-C-uses/Some-P-uses At least one path of each variable definition to each c- covered by c-use, then use p-use A B C A B D E A B D F A B D All-uses At least one path of each variable definition to each p- use and each c-use of the definition A B A B C A B D A B D E A B D F DFT 31 DFT 32 MPG DU-Paths for Price MPG DU-Paths for Price 2 All-Defs All-P-uses Each definition of each variable for at least one use of the definition A B D F At least one path of each variable definition to each p- use of the definition None All-C-uses All-C-uses/Some-P-uses At least one path of each variable to each c-use of the definition A B D F At least one path of each variable definition to each c- covered use p-use A B D F DFT 33 DFT 34 MPG DU-Paths for Price 2 Rapps-Weyuker data flow hierarchy All-Paths All-P-uses/Some-C-uses At least one path of each variable definition to each p- covered use c-use A B D F All-C-uses Some-P-uses All-DU-Paths All-Uses All-P-uses Some-C-uses All-uses At least one path of each variable definition to each p- use and each c-use of the definition A B D F All-Defs All-P-uses All-Edges All-Nodes DFT 35 DFT 36 6

Potential Anomalies static analysis Potential Anomalies static analysis 2 Data flow node combinations for a variable Allowed? Potential Bug? Serious defect? Anomalies ~ d first define??? du define-use??? dk define-kill??? ~ u first use??? ud use-define??? uk use-kill??? ~ k first kill??? ku kill-use??? Explanation DFT 37 Data flow node combinations for a variable Allowed? Potential Bug? Serious defect? Anomalies kd kill-define??? dd define-define??? uu use-use??? kk kill-kill??? d ~ define last??? u ~ use last??? k ~ kill last??? Explanation DFT 38 Potential Anomalies static analysis 3 Potential Anomalies static analysis 4 Anomalies Explanation ~ d first define Allowed normal case du define-use Allowed normal case dk define-kill Potential bug ~ u first use Potential bug ud use-define Allowed redefine uk use-kill Allowed normal case ~ k first kill Serious defect ku kill-use Serious defect Anomalies Explanation kd kill-define Allowed - redefined dd define-define Potential bug uu use-use Allowed - normal case kk kill-kill Serious defect d ~ define last Potential bug u ~ use last Allowed- normal case k ~ kill last Allowed - normal case DFT 39 DFT 40 Data flow guidelines Data flow guidelines 2 When is dataflow analysis good to use? When is dataflow analysis good to use? Data flow testing is good for computationally/control intensive programs If P-use of variables are computed, then P-use data flow testing is good Define/use testing provides a rigorous, systematic way to examine points at which faults may occur. DFT 41 DFT 42 7

Data flow guidelines 3 Aliasing of variables causes serious problems Working things out by hand for anything but small methods is hopeless Compiler-based tools help in determining coverage values DFT 43 8