Unit 3 Data Flow Compiled with reference from

  • Slides: 51
Download presentation
Unit 3 – Data Flow Compiled with reference from: Software Testing Techniques: Boris Beizer

Unit 3 – Data Flow Compiled with reference from: Software Testing Techniques: Boris Beizer Craft of Software Testing: Brain Marrick Narasimha Rao. P

Data - Flow Testing - Basics U 2 We will see in this part

Data - Flow Testing - Basics U 2 We will see in this part of Unit 2: • Concepts of Data flows • Data-flow testing strategies ref boris beizer 2

Data - Flow Testing - Basics U 2 Contents • Synopsis • Basics •

Data - Flow Testing - Basics U 2 Contents • Synopsis • Basics • • • Intro to Data flow, data flow graphs Motivation & Assumption Data flow model • Data Flow Testing Strategies • • • General strategy Definitions Strategies: • Slicing, Data flow, Effectiveness • Application of DFT, Tools & Effectiveness ref boris beizer 3

Data - Flow Testing - Basics U 2 Anomaly Unreasonable processing on data •

Data - Flow Testing - Basics U 2 Anomaly Unreasonable processing on data • • Use of data object before it is defined Defined data object is not used • Data Flow Testing (DFT) uses Control Flow Graph (CFG) to explore dataflow anomalies. • DFT Leads to testing strategies between P and P 1 / P 2 4 ref boris beizer

Data - Flow Testing - Basics U 2 Definition: DFT is a family of

Data - Flow Testing - Basics U 2 Definition: DFT is a family of test strategies based on selecting paths through the program’s control flow in order to explore the sequence of events related to the status of data objects. Example: Pick enough paths to assure that every data item has been initialized prior to its use, or that all objects have been used for something. 5 ref boris beizer

Data - Flow Testing - Basics U 2 Motivation • Confidence in the program

Data - Flow Testing - Basics U 2 Motivation • Confidence in the program • Data dominated design. Code migrates to data. . • Source Code for Data Declarations • Data flow Machines vs Von Neumann’s • Abstract M I M D • Language & compiler take care of parallel computations 6 ref boris beizer

Data - Flow Testing - Basics - Motivation U 2 Program Control flow with

Data - Flow Testing - Basics - Motivation U 2 Program Control flow with Von Neumann’s paradigm Given m, n, p, q, find e. e = (m+n+p+q) * (m+n-p-q) a = n+m a : = m + n b : = p + q c : = a + b d : = a - b b=p+q c=a+b e : = c * d d=a-b e=c*d 7 Multiple representations of control flow graphs possible. ref boris beizer

Data - Flow Testing - Basics - Motivation U 2 Program Flow using Data

Data - Flow Testing - Basics - Motivation U 2 Program Flow using Data Flow Machines paradigm BEGIN PAR DO READ m, n, n, p, q END PAR DO a : = m+n b : = p+q END PAR DO c : = a+b d : = a-b END PAR DO e : = c * d END PAR END n p m a : = m+n q b : = p+q c : = a+b d : = a-b e : = c * d The interrelations among the data items remain same. 8 ref boris beizer

Data - Flow Testing - Basics - Motivation U 2 • Control flow graph

Data - Flow Testing - Basics - Motivation U 2 • Control flow graph • Multiple representations • Data Flow Graph A spec. for relations among the data objects. Covering DFG => Explore all relations under some test. 9 ref boris beizer

Data - Flow Testing - Basics U 2 Assumptions • Problems in a control

Data - Flow Testing - Basics U 2 Assumptions • Problems in a control flow • Problems with data objects 10 ref boris beizer

Data - Flow Testing - Basics Data Flow Graphs U 2 (DFG) • It

Data - Flow Testing - Basics Data Flow Graphs U 2 (DFG) • It is a graph with nodes & directed links • Test the Von Neumann way Convert to a CFG Annotate : program actions (weights) 11 ref boris beizer

Data - Flow Testing - Basics U 2 Data Object State & Usage Program

Data - Flow Testing - Basics U 2 Data Object State & Usage Program Actions (d, k, u): 12 Defined (created) - explicitly or implicitly (d) Killed (released) - directly or indirectly (k) Used - (u) • In a calculation - (c) • In a predicate - directly or indirectly ref boris beizer (p)

Data - Flow Testing - Basics U 2 Data Flow Anomalies A Two letter

Data - Flow Testing - Basics U 2 Data Flow Anomalies A Two letter sequence of Actions (d, k, u) 13 dd : harmless, suspicious dk : probably a bug. du : normal kd : normal kk : harmless, but probably a bug ku : a bug ud : normal. uk : normal uu : normal A Action Redefinition. ref boris beizer

Data - Flow Testing - Basics - Motivation U 2 Program Flow using Data

Data - Flow Testing - Basics - Motivation U 2 Program Flow using Data Flow Machines paradigm BEGIN PAR DO READ m, n, n, p, q END PAR DO a : = m+n b : = p+q END PAR DO c : = a+b d : = a-b END PAR DO e : = c * d END PAR END n p m a : = m+n q b : = p+q c : = a+b d : = a-b e : = c * d The interrelations among the data items remain same. 14 ref boris beizer

Data - Flow Testing - Basics – Data Flow Anomalies Actions on data objects

Data - Flow Testing - Basics – Data Flow Anomalies Actions on data objects - 15 no action from START to this point From this point till the EXIT -d normal -u anomaly -k anomaly k- normal u- normal d- possibly anomalous - possibly an anomaly ref boris beizer U 2

Data - Flow Testing - Basics U 2 Data Flow Anomaly State graph •

Data - Flow Testing - Basics U 2 Data Flow Anomaly State graph • Data Object State • K, D, U, A • Processing Step • k, d, u 16 ref boris beizer

Data - Flow Testing - Basics U 2 Data Flow Anomaly State graph •

Data - Flow Testing - Basics U 2 Data Flow Anomaly State graph • Object state • Unforgiving Data flow state graph Undefined K k, u d u u U d Used 17 D Defined d, k A Anomalous d, k, u ref boris beizer

Data - Flow Testing - Basics U 2 Data Flow Anomaly State graph Forgiving

Data - Flow Testing - Basics U 2 Data Flow Anomaly State graph Forgiving Data flow state graph k u u K A DD, DK, KU KU k u k DK d k d u u U D k d d DD u 18 d ref boris beizer

Data - Flow Testing - Basics U 2 Data Flow State Graphs • Differ

Data - Flow Testing - Basics U 2 Data Flow State Graphs • Differ in processing of anomalies • Choice depends on Application, language, context 19 ref boris beizer

Data - Flow Testing - Basics U 2 Static vs Dynamic Anomaly Detection •

Data - Flow Testing - Basics U 2 Static vs Dynamic Anomaly Detection • Static analysis of data flows • Dynamic analysis Intermediate data values 20 ref boris beizer

Data - Flow Testing - Basics U 2 Insufficiency of Static Analysis (for Data

Data - Flow Testing - Basics U 2 Insufficiency of Static Analysis (for Data flow) 1. Validation of Dead Variables 2. Validation of pointers in Arrays 3. Validation of pointers for Records & pointers 1. Dynamic addresses for dynamic subroutine calls 2. Identifying False anomaly on an unachievable path 1. Recoverable anomalies & Alternate state graph 2. Concurrency, Interrupts, System Issues 21 ref boris beizer

Data - Flow Testing - Basics U 2 Data Flow Model • Based on

Data - Flow Testing - Basics U 2 Data Flow Model • Based on CFG • CFG annotated with program actions • link weights : dk, dp, du etc. . • Not same as DFG • For each variable and data object 22 ref boris beizer

Data - Flow Testing - Basics : Data Flow Model Procedure to Build: 1.

Data - Flow Testing - Basics : Data Flow Model Procedure to Build: 1. Entry & Exit nodes 1. Unique node identification 1. Weights on out link 2. Predicated nodes 3. Sequence of links 1. Join 2. Concatenate weights 3. The converse 23 ref boris beizer U 2

Data - Flow Testing - Basics : Data Flow Model Example: an – 1

Data - Flow Testing - Basics : Data Flow Model Example: an – 1 Z = b + ----a - 1 START INPUT a, b, n Z : = 0 IF a = 1 THEN Z : = 1 GOTO DONE 1 r : = 1 c : = 1 POWER: c : = c * a r : = r + 1 IF r <= n THEN GO TO POWER Z : = (c – 1) / (a – 1) DONE 1: Z : = b + Z END 24 ref boris beizer U 2

Data - Flow Testing - Basics – Data Flow model U 2 CFG for

Data - Flow Testing - Basics – Data Flow model U 2 CFG for the Example Read a, b, n Z : = 0 1 Z : = 1 2 Z : = b + Z 5 a = 1? P 1 Y r : = 1 c: =1 6 Z : = (c-1)/(a-1) 3 P 2 r : = r+1, c: = c*a 4 r<n? Y 25 ref boris beizer

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated – Data Flow Model for Z 1 d or kd d 2 P 1 cd or ckd 5 a = 1? 6 Y d or kd 3 P 2 4 r<n? Y 26 ref boris beizer

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated – Data Flow Model for c 1 2 5 a = 1? P 1 6 Y c- -d 3 ckd or kd P 2 4 r<n? Y 27 ref boris beizer

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated – Data Flow Model for r 1 2 5 a = 1? P 1 6 Y p- -d 3 ckd or kd P 2 4 r<n? Y 28 ref boris beizer

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated – Data Flow Model for b 1 d 2 P 1 c 5 a = 1? 6 Y 3 P 2 4 r<n? Y 29 ref boris beizer

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated – Data Flow Model for n 1 d 2 P 1 5 a = 1? 6 Y p- 3 P 2 4 r<n? Y 30 ref boris beizer

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated

Data - Flow Testing - Basics – Data Flow model U 2 CFG annotated – Data Flow Model for a 1 d 2 P 1 5 a = 1? 6 p c- 3 c P 2 4 r<n? Y 31 ref boris beizer

Data - Flow Testing - Basics – Data Flow model A DFM for each

Data - Flow Testing - Basics – Data Flow model A DFM for each variable Single DFM for multiple variables Use weights subscripted with variables 32 ref boris beizer U 2

Data - Flow Testing – Data Flow Testing Strategies • A structural testing strategy

Data - Flow Testing – Data Flow Testing Strategies • A structural testing strategy (path testing) • Add, data flow strategies with link weights • Test path segments to have a ‘d’ (or u, k, du, dk) 33 ref boris beizer U 2

Data - Flow Testing – Data Flow Testing Strategies DEFINITIONS • w. r. t.

Data - Flow Testing – Data Flow Testing Strategies DEFINITIONS • w. r. t. a variable or data object ‘v’ • Assume all DF paths are achievable 1. Definition-clear path segment no k, kd 2. Loop-free path segment 2. Simple path segment 3. du path from node i to k • definition-clear & simple • definition-clear & loop-free 34 c p ref boris beizer U 2

Data - Flow Testing – Data Flow Testing Strategies DFT Strategies 1. All-du paths

Data - Flow Testing – Data Flow Testing Strategies DFT Strategies 1. All-du paths (ADUP) 2. All uses (AU) strategy 3. All p-uses/some c-uses and All c-uses/some p-uses 1. All Definitions Strategy 1. All p-uses, All c-uses Strategy Purpose: 35 Test Design, Develop Test Cases ref boris beizer U 2

Data - Flow Testing – Data Flow Testing Strategies U 2 1. All-du paths

Data - Flow Testing – Data Flow Testing Strategies U 2 1. All-du paths (ADUP) • Strongest DFT • Every du path for every variable for every definition to every use 2. All uses (AU) strategy • At least one definition clear path segment from every definition of every variable to every use of that definition be exercised under some test. • At least one path segment from every definition to every use that can be reached from that definition. 36 ref boris beizer

Data - Flow Testing – Data Flow Testing Strategies U 2 3. All p-uses/some

Data - Flow Testing – Data Flow Testing Strategies U 2 3. All p-uses/some c-uses and All c-uses/some p-uses • APU + c • Stronger than P 2 • ACU + p • Weaker than P 2 37 ref boris beizer

Data - Flow Testing – Data Flow Testing Strategies 4. All Definitions Strategy (AD)

Data - Flow Testing – Data Flow Testing Strategies 4. All Definitions Strategy (AD) • Cover every definition by at least one • Weaker than ACU + p 38 and p or c APU + c ref boris beizer U 2

Data - Flow Testing – Data Flow Testing Strategies 5. All-Predicate Uses, Strategy U

Data - Flow Testing – Data Flow Testing Strategies 5. All-Predicate Uses, Strategy U 2 All-Computational Uses • APU : • Include definition-free path for every definition of every variable from the definition to predicate use. • ACU : • Include for every definition of every variable include at least one definition-free path from the definition to every computational use. 39 ref boris beizer

Data - Flow Testing – Data Flow Testing Strategies U 2 Ordering the strategies

Data - Flow Testing – Data Flow Testing Strategies U 2 Ordering the strategies All Paths All du Paths All-uses Paths (AU) All-c / some-p (ACU+p) All c uses (ACU) All-p / some-c APU+c All Defs AD All P-uses APU All Branches P 2 All Stmts P 1 40 ref boris beizer

Data - Flow Testing – Data Flow Testing Strategies U 2 Testing, Maintenance &

Data - Flow Testing – Data Flow Testing Strategies U 2 Testing, Maintenance & Debugging in the Data Flow context Slicing: • A static program slice is a part of a program defined wrt a variable ‘v’ and a statement ‘s’; It is the set of all statements that could affect the value of ‘v’ at stmt ‘s’. 41 Stmt 1 stmt 2 Stmt 3 Stmt 4 var v Stmt s var v ref boris beizer

Data - Flow Testing – Data Flow Testing Strategies U 2 Testing, Maintenance &

Data - Flow Testing – Data Flow Testing Strategies U 2 Testing, Maintenance & Debugging in the Data Flow context Dicing: • A program dice is a part of slice in which all stmts. which are known to be correct have been removed. • Obtained from ‘slice’ by incorporating correctness information from testing / debugging. 42 ref boris beizer

Data - Flow Testing – Data Flow Testing Strategies U 2 Testing, Maintenance &

Data - Flow Testing – Data Flow Testing Strategies U 2 Testing, Maintenance & Debugging in the Data Flow context Debugging: • Select a slice. • Narrow it to a dice. • Refine the dice till it’s one faulty stmt. 43 ref boris beizer

Data - Flow Testing – Data Flow Testing Strategies U 2 Testing, Maintenance &

Data - Flow Testing – Data Flow Testing Strategies U 2 Testing, Maintenance & Debugging in the Data Flow context Dynamic Slicing: • Refinement of static slicing • Only achievable paths to the stmt ‘s’ in question are included. Slicing methods bring together testing, maintenance & debugging. 44 ref boris beizer

Data - Flow Testing - – Data Flow Testing Strategies Application of DFT •

Data - Flow Testing - – Data Flow Testing Strategies Application of DFT • Comparison Random Testing, P 2, AU - by Ntafos • AU detects more bugs than • P 2 with more test cases • RT with less # of test cases • Comparison of P 2, AU - by Sneed • AU detects more bugs with 90% Data Coverage Requirement. 45 ref boris beizer U 2

Data - Flow Testing - – Data Flow Testing Strategies U 2 Application of

Data - Flow Testing - – Data Flow Testing Strategies U 2 Application of DFT • Comparison of # test cases for ACU, APU, AU & ADUP • by Weyuker using ASSET testing system • Test Cases Normalized. t=a+b*d • At most d+1 Test Cases for P 2 d = # binary decisions loop-free • # Test Cases / Decision ADUP > AU 46 > APU > ACU > revised-APU ref boris beizer

Data - Flow Testing - – Data Flow Testing Strategies U 2 Application of

Data - Flow Testing - – Data Flow Testing Strategies U 2 Application of DFT Comparison of # test cases for ACU, APU, AU & ADUP by Shimeall & Levenson Test Cases Normalized. t=a+b*d At most d+1 Test Cases for P 2 (d = # binary decisions) loop-free # Test Cases / Decision ADUP 47 ~ ½ APU* AP ~ AC ref boris beizer

Data - Flow Testing - – Data Flow Testing Strategies Application of DFT vs

Data - Flow Testing - – Data Flow Testing Strategies Application of DFT vs P 1, P 2 • DFT is Effective • Effort for Covering Path Set ~ Same • DFT Tracks the Coverage of Variables • Test Design is similar 48 ref boris beizer U 2

Data - Flow Testing - – Data Flow Testing Strategies DFT - TOOLS •

Data - Flow Testing - – Data Flow Testing Strategies DFT - TOOLS • Cost-effective development • Commercial tools : • Can possibly do Better than Commercial Tools • Easier Integration into a Compiler • Efficient Testing 49 ref boris beizer U 2

Data - Flow Testing – Questions from the previous year’s exams 1. How is

Data - Flow Testing – Questions from the previous year’s exams 1. How is data flow testing (DFT) helpful in fulfilling gaps in path testing? 2. Explain the data flow Graphs (DFG). 3. How can anomaly be detected? Explain different types of data flow anomalies and Data flow Anomaly State Graphs. 4. Write applications of Data Flow Testing. 5. Name and explain Data flow testing strategies. 50 ref boris beizer U 2

Data - Flow Testing U-2 C To Unit 4 … Domain Testing 51 ref

Data - Flow Testing U-2 C To Unit 4 … Domain Testing 51 ref boris beizer