1 paste’07 discovering accurate interclass test dependence weilei zhang, barbara ryder department...

22
PASTE’07 1 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

Post on 22-Dec-2015

218 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 1

Discovering Accurate Interclass Test Dependence

Weilei Zhang, Barbara RyderDepartment of Computer Science

Rutgers University

Page 2: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 2

Motivation

● Class testing is very important for OO testing

It corresponds with the classic definition of unit testing by exercising a relatively small software component via a driver

● Most classes in the system are interdependent, and there is test dependence between classes

● An accurate knowledge of ICTD (InterClass Test Dependence) is desired

Important in deciding class integration test order

● Dependence cycles/SCCs causes complication Helpful to parallelize integration test activities

Can be useful for program understanding and software visualization

Page 3: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 3

Existing works on ICTD

● Briand, et al (TSE 2003)● Milanova, et al (ICSM 2002)● Hanh, et al (ECOOP 2001)● Labiche, et al (ICSE 2000)● Tai and Daniels (JOOP 1999)● Kung, et al (JOOP 1995)

ORD-based

Page 4: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 4

ORD-Based Definition For ICTD

● Causes for ICTD: Inheritance Aggregation Association Polymorphism

A B

C D

As

IAg

● B is test dependent on A, C and D

● Transitive closure of the above

Page 5: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 5

Contributions

● To propose and formalize a new definition for ICTD in order to prune out the spurious dependences Semantics-based definition

● To give a practical algorithm to approximate the definition Method-level dependence analysis

● To implement the algorithm and evaluate the results

Page 6: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 6

Motivating Examples

● specjbb benchmark

class DeliveryHandler{public void handleDelivery(DeliveryTransaction deliveryTransaction){ deliveryTransaction.process(); deliveryTransaction.display(outFile);}

}

DeliveryHandler DeliveryTransaction

As

As

● Cases when ICTD does not exist though there is association No reference during run-time (Milanova et al ICSM 2002) No method calls (Stack & its containees) Only calls to inherited methods (HashMap & its containees) Methods called but no impact on the caller (the above in specjbb)

The spurious ICTD causes a fake dependence cycle.

Page 7: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 7

Semantics-based Definition of ICTD

● There is test dependence from class A to class B, if there is a statement s in a method callable on an A object and a statement t in a method declared in B, such that: s may have visible side effects (i.e., s may either write

to the external memory or return a value), and s is semantically dependent on t while testing class A

Page 8: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 8

Approximation Algorithm

● Turing-incomputable -> dependence analysis● Statement-level granularity dependence analysis is too

costly Approximate at method-level granularity dependence

● Three causes for method dependence: Caller uses return value of callee Callee is control-dependent on caller Side effect: one method writes to the same memory region

that another method reads

● Propagate dependences on the call graph

w=x.foo()

Page 9: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 9

Side Effect

writeread

class

Method

Other calls

Call and return “useful” value

Heap Data

CUT

Algorithm Illustration

Page 10: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 10

Side Effect

writeread

Methods Callable on CUT

class

Method

Heap Data

CUT

Other calls

Call and return “useful” value

Algorithm Illustration

Page 11: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 11

Side Effect

writeread

Methods Callable on CUT

class

Method

Heap Data

CUT

Other calls

Call and return “useful” value

Algorithm Illustration

Page 12: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 12

Side Effect

writeread

Methods Callable on CUT

class

Method

Heap Data

CUT

Other calls

Call and return “useful” value

Algorithm Illustration

Page 13: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 13

Side Effect

writeread

Methods Callable on CUT

class

Method

Heap Data

CUT

Other calls

Call and return “useful” value

Algorithm Illustration

Page 14: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 14

Side Effect

writeread

Methods Callable on CUT

class

Method

Heap Data

CUT

Other calls

Call and return “useful” value

Algorithm Illustration

Page 15: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 15

Side Effect

writeread

Methods Callable on CUT

class

Method

Heap Data

CUT

Other calls

Call and return “useful” value

Algorithm Illustration

Page 16: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 16

Analysis Configurations

● The proposed algorithm is parameterized by the choice of program analyses to calculate the call graph and side effect information

● For analysis configuration applied: VTA: variable type analysis (call graph not constructed on the

fly) 0CFA: 0-CFA (call graph constructed on the fly) OB: 1-object-sensitive points-to analysis OBR: OB+R (a data reachability algorithm to resolve library

call-backs and construct accurate application call graphs)

Page 17: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 17

ICTD Reduction Rate wrt. ORD-based Definition

0%

20%

40%

60%

80%

100% VTA 0CFA OB OBR

V T A 41. 28% 62. 42% 18. 62% 50. 83% 23. 03% 24. 51% 18. 62% 82. 34% 68. 08% 43. 30%

0C FA 64. 53% 83. 59% 63. 24% 65. 00% 23. 03% 68. 89% 63. 24% 83. 53% 95. 38% 67. 83%

OB 64. 53% 84. 73% 73. 19% 80. 00% 34. 58% 76. 98% 72. 87% 90. 55% 96. 75% 74. 91%

OB R 64. 53% 85. 11% 73. 19% 80. 00% 37. 26% 79. 51% 72. 87% 90. 55% 96. 83% 75. 54%

c ompr es s j es s r aytr ac e db j avac mpegaudi o mtr t j ac k j bb A ver age

Page 18: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 18

Size of Dependence Cycles

ORD VTA 0CFA OB OBR

compress(128) 6,4,4 5,3 3 3 3

jess(163) 147,4 139 96 94 90

raytrace(41) 18,4,2 16 8,4 7 7

db(20) 10 6 5 0 0

Javac(184) 169 161 161 142 134

mpegaudio(60) 44 37 6,3,2 0 0

mtrt(41) 18,4,2 16 8,4 7 7

jack(69) 44 7,6,2,2 7,4,2,2 7 7

jbb(104) 79 49 3,3,2 2,2 2

Page 19: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 19

Objective-Sensitive Analysis

Metrics: output_properly(){…this.wrap()…}

AsciiMetrics overrides Method wrap().

Metrics

AsciiMetricsI

Metrics: output_properly()

Metrics: wrap() AsciiMetrics: wrap()

Methods reachable from Metrics

Methods reachable from AsciiMetrics

Context-insensitive CG

Page 20: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 20

Objective-Sensitive Analysis

Metrics: output_properly(){…this.wrap()…}

AsciiMetrics overrides Method wrap().

Metrics

AsciiMetricsI

[m, Metrics: output_properly()]

[m,Metrics: wrap()] [am,AsciiMetrics: wrap()]

Methods reachable from MetricsMethods reachable from AsciiMetrics

Object-sensitive CG

[am, Metrics: output_properly()]

PLDI’07 Sridharan, Fink, Bodik: context-sensitive dependence analysis is too costly and “did not provide much realistic usage” for thin slicing.

Method-level dependence calculation makes context-sensitive dependence analysis more practical and it is very useful in our study in ICTD.

Page 21: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 21

Conclusions

● A new semantics-based accurate definition for interclass test dependence

● An approximate algorithm and implementation A great number of spurious dependences are removed Dependence cycles are determined accurately in 6 out of 7

benchmarks amenable to code inspection. Method-level dependence propagation makes object-sensitive

dependence analysis more practical Object-sensitive analysis is key to achieve accurate results for

dependence cycles

Page 22: 1 PASTE’07 Discovering Accurate Interclass Test Dependence Weilei Zhang, Barbara Ryder Department of Computer Science Rutgers University

PASTE’07 22

Thanks!

Questions?