Title: OMEN: A Strategy for Testing Object-Oriented Software
1OMEN A Strategy for Testing Object-Oriented
Software
- Amie L. Souter
-
- Lori L. Pollock
- ISSTA 2000
Dept. of Computer and Information Sciences
2Object-Oriented Programming
- Features
- Classes, Objects, and Inheritance
- Polymorphism and Dynamic Binding
- Programming Style
- Modularity many small methods
- Objects
- Code reuse through inheritance
- Complex class interactions
- Heavy use of libraries
3Illustrating Kinds of DEF-USE Pairs
Class Stack int myStack int
top 1 public Stack(int s) myStack new
ints 2 top 0
3 public void push(int obj)
myStacktop obj 4 public int pop()
5 if(size() 0) return
error 6 int temp
myStacktop-1 7 top-- 8
return temp
9 public int size() return top
10 public int top() return
myStacktop-1 11 public boolean isEmpty()
return top 0 12 public void example()
push(10)
if(size() 5)
do_something
intra-method
traditional du analysis Weyuker85
4Illustrating Kinds of DEF-USE Pairs
Class Stack int myStack int
top 1 public Stack(int s) myStack new
ints 2 top 0
3 public void push(int obj)
myStacktop obj 4 public int pop()
5 if(size() 0) return
error 6 int temp
myStacktop-1 7 top-- 8
return temp
9 public int size() return top
10 public int top() return
myStacktop-1 11 public boolean isEmpty()
return top 0 12 public void example()
push(10)
if(size() 5)
do_something
intra-method
traditional du analysis Weyuker85
5Illustrating Kinds of DEF-USE Pairs
Class Stack int myStack int
top 1 public Stack(int s) myStack new
ints 2 top 0
3 public void push(int obj)
myStacktop obj 4 public int pop()
5 if(size() 0) return
error 6 int temp
myStacktop-1 7 top-- 8
return temp
9 public int size() return top
10 public int top() return
myStacktop-1 11 public boolean isEmpty()
return top 0 12 public void example()
push(10)
if(size() 5)
do_something
inter-method
interprocedural du analysis Harrold89
6Illustrating Kinds of DEF-USE Pairs
Class Stack int myStack int
top 1 public Stack(int s) myStack new
ints 2 top 0
3 public void push(int obj)
myStacktop obj 4 public int pop()
5 if(size() 0) return
error 6 int temp
myStacktop-1 7 top-- 8
return temp
9 public int size() return top
10 public int top() return
myStacktop-1 11 public boolean isEmpty()
return top 0 12 public void example()
push(10)
if(size() 5)
do_something
inter-method
interprocedural du analysis Harrold89
7Illustrating Kinds of DEF-USE Pairs
Class Stack int myStack int
top 1 public Stack(int s) myStack new
ints 2 top 0
3 public void push(int obj)
myStacktop obj 4 public int pop()
5 if(size() 0) return
error 6 int temp
myStacktop-1 7 top-- 8
return temp
9 public int size() return top
10 public int top() return
myStacktop-1 11 public boolean isEmpty()
return top 0 12 public void example()
push(10)
if(size() 5)
do_something
inter-method
interprocedural du analysis Harrold89
8Illustrating Kinds of DEF-USE Pairs
Class Stack int myStack int
top 1 public Stack(int s) myStack new
ints 2 top 0
3 public void push(int obj)
myStacktop obj 4 public int pop()
5 if(size() 0) return
error 6 int temp
myStacktop-1 7 top-- 8
return temp
9 public int size() return top
10 public int top() return
myStacktop-1 11 public boolean isEmpty()
return top 0 12 public void example()
push(10)
if(size() 5)
do_something
intra-class
Intra-class du analysis Harrold Rothermel 94
9Illustrating Kinds of DEF-USE Pairs
Class Stack int myStack int
top 1 public Stack(int s) myStack new
ints 2 top 0
3 public void push(int obj)
myStacktop obj 4 public int pop()
5 if(size() 0) return
error 6 int temp
myStacktop-1 7 top-- 8
return temp
9 public int size() return top
10 public int top() return
myStacktop-1 11 public boolean isEmpty()
return top 0 12 public void example()
push(10)
if(size() 5)
do_something
intra-class
Intra-class du analysis Harrold Rothermel 94
10Illustrating Kinds of DEF-USE Pairs
Class Stack int myStack int
top 1 public Stack(int s) myStack new
ints 2 top 0
3 public void push(int obj)
myStacktop obj 4 public int pop()
5 if(size() 0) return
error 6 int temp
myStacktop-1 7 top-- 8
return temp
9 public int size() return top
10 public int top() return
myStacktop-1 11 public boolean isEmpty()
return top 0 12 public void example()
push(10)
if(size() 5)
do_something
intra-class
Intra-class du analysis Harrold Rothermel 94
11DEF-USE Pairs Involving Inter-Class Interactions
Class genericStack Array myStack 1
public genericStack() myStack new Array()
2 public Object top() return
myStack.back() 3 public void push(Obj o)
myStack.pushBack(o) 4 public Object
pop() return myStack.popBack() 5
public bool isEmpty() return
myStack.isEmpty() 6 public int size()
return myStack.size()
Class Array Object myStorage int
myLength 1 public Array()
myStorage new ObjectSIZE 2
myLength 0 3
public Object back() return
myStoragemyLength-1 4 public Object popBack()
return myStorage--myLength 5 public void
pushBack(Obj o) add(o)
6 public Object front(Obj o) return
myStorage0 7 public bool isEmpty()
return (myLength 0) 8 public int
size() return myLength
9 public void add(Obj o)
myStoragemyLength o //Array has 46
other methods
Inter-class du analysis Souter Pollock99
12DEF-USE Pairs Involving Inter-Class Interactions
Class genericStack Array myStack 1
public genericStack() myStack new Array()
2 public Object top() return
myStack.back() 3 public void push(Obj o)
myStack.pushBack(o) 4 public Object
pop() return myStack.popBack() 5
public bool isEmpty() return
myStack.isEmpty() 6 public int size()
return myStack.size()
Class Array Object myStorage int
myLength 1 public Array()
myStorage new ObjectSIZE 2
myLength 0 3
public Object back() return
myStoragemyLength-1 4 public Object popBack()
return myStorage--myLength 5 public void
pushBack(Obj o) add(o)
6 public Object front(Obj o) return
myStorage0 7 public bool isEmpty()
return (myLength 0) 8 public int
size() return myLength
9 public void add(Obj o)
myStoragemyLength o //Array has 46
other methods
Inter-class du analysis Souter Pollock99
13DEF-USE Pairs Involving Inter-Class Interactions
Class genericStack Array myStack 1
public genericStack() myStack new Array()
2 public Object top() return
myStack.back() 3 public void push(Obj o)
myStack.pushBack(o) 4 public Object
pop() return myStack.popBack() 5
public bool isEmpty() return
myStack.isEmpty() 6 public int size()
return myStack.size()
Class Array Object myStorage int
myLength 1 public Array()
myStorage new ObjectSIZE 2
myLength 0 3
public Object back() return
myStoragemyLength-1 4 public Object popBack()
return myStorage--myLength 5 public void
pushBack(Obj o) add(o)
6 public Object front(Obj o) return
myStorage0 7 public bool isEmpty()
return (myLength 0) 8 public int
size() return myLength
9 public void add(Obj o)
myStoragemyLength o //Array has 46
other methods
Inter-class du analysis Souter Pollock99
14DEF-USE Pairs Involving Inter-Class Interactions
Class genericStack Array myStack 1
public genericStack() myStack new Array()
2 public Object top() return
myStack.back() 3 public void push(Obj o)
myStack.pushBack(o) 4 public Object
pop() return myStack.popBack() 5
public bool isEmpty() return
myStack.isEmpty() 6 public int size()
return myStack.size()
Class Array Object myStorage int
myLength 1 public Array()
myStorage new ObjectSIZE 2
myLength 0 3
public Object back() return
myStoragemyLength-1 4 public Object popBack()
return myStorage--myLength 5 public void
pushBack(Obj o) add(o)
6 public Object front(Obj o) return
myStorage0 7 public bool isEmpty()
return (myLength 0) 8 public int
size() return myLength
9 public void add(Obj o)
myStoragemyLength o //Array has 46
other methods
Inter-class du analysis Souter Pollock99
15DEF-USE Pairs Involving Inter-Class Interactions
Class genericStack Array myStack 1
public genericStack() myStack new Array()
2 public Object top() return
myStack.back() 3 public void push(Obj o)
myStack.pushBack(o) 4 public Object
pop() return myStack.popBack() 5
public bool isEmpty() return
myStack.isEmpty() 6 public int size()
return myStack.size()
Class Array Object myStorage int
myLength 1 public Array()
myStorage new ObjectSIZE 2
myLength 0 3
public Object back() return
myStoragemyLength-1 4 public Object popBack()
return myStorage--myLength 5 public void
pushBack(Obj o) add(o)
6 public Object front(Obj o) return
myStorage0 7 public bool isEmpty()
return (myLength 0) 8 public int
size() return myLength
9 public void add(Obj o)
myStoragemyLength o //Array has 46
other methods
Inter-class du analysis Souter Pollock99
16Research Goals
- To develop a new approach to testing
object-oriented software that - Provides structural testing tailored to OO codes
- association between objects and fields
- include object creation site with def-use pair
- handle complex class interactions
- Program representation scales to large software
systems - Provides feedback to the tester
- Provides information on external influences of
the testing results - Provides the tester with direction in how to test
an incomplete program
17Outline
- Object-Oriented Program Characteristics
- Illustration of Def-Use Pairs
- Research Goals
- Our Solution
- Basic Object Manipulations
- Annotated Points-to Escape Graph
- OMEN Test Tuple Construction Algorithm
- Work in Progress
18Basic Object Manipulations
19Basic Object Manipulations
20Basic Object Manipulations
21Points-to-Escape-Graph
- Terminology
- Nodes
- inside
- outside
- load
- return value
- Edges
- inside
- outside
Node insert(Object e) Node temp new Node
(e,this) return temp
Whaley Rinard OOPSLA99
22Extensions to the Points-to-Escape GraphAPE
Graph
1 public push( Object e) 2 if(top
null) 3 top new Node(e, null) 4 else
5 top top.insert(e) 6 Node (Object
e, Node n ) 7 data e 8 next n
23Extensions to the Points-to-Escape GraphAPE
Graph
1 public push( Object e) 2 if(top
null) 3 top new Node(e, null) 4 else
5 top top.insert(e) 6 Node (Object
e, Node n ) 7 data e 8 next n
24Extensions to the Points-to-Escape GraphAPE
Graph
1 public push( Object e) 2 if(top
null) 3 top new Node(e, null) 4 else
5 top top.insert(e) 6 Node (Object
e, Node n ) 7 data e 8 next n
25OMEN - Test Tuple Construction Algorithm
- Computes a set of testing tuples for the
component under test, - based on object manipulations.
- Input set of call graphs for component under
test - Output set of testing tuples for component under
test - Traverse call graph in topological order
- Process each methods APE graph
- For each store annotation per unmarked APE graph
edge - find the associated loads occurring after the
store - find object creation site associated with the
tuple - depends on the type of source node of the APE
graph - report feedback
- using the escape information of the APE graph
26Traverse the Call Graphin Topological Order
main
push
pop
Stack
isempty
println
get
remove
Node
insert
27Traverse the Call Graphin Topological Order
main 1
push 3
pop7
Stack2
isempty6
println10
get8
remove9
Node4
insert5
28Processing a Methods APE Graph
x,22
Integer 20
20
data9
data8
next7
20-6-29
next5
20-4
top2
next6
next4
s,18
18
top1
top3
29Processing a Methods APE Graph
x,22
Integer 20
20
data9
data8
next7
20-6-29
next5
20-4
top2
next6
next4
s,18
18
top1
top3
30Processing a Methods APE Graph
x,22
Integer 20
20
data9
data8
next7
20-6-29
next5
20-4
top2
next6
next4
s,18
18
top1
top3
31Avoiding Duplicate TuplesThrough Marking
data, 4-10-7, store
data,3-7,store
T
top,3,store
next,3-8,store
next,4-10-8,store
top,2,load
2
Marked edge Non-marked edge
top,4,store
Edges are marked during interprocedural merges of
ape graph construction.
32Processing Incomplete Components
x,22
top1
18
s,18
top2
top4
top3
Feedback value loaded is potentially changed by
method outside CUT.
33Processing Incomplete Components
x,22
top1
s,18
top2
top4
top3
Feedback value loaded is potentially changed by
method outside CUT.
34Processing Incomplete Components
x,22
top1
s,18
top2
top4
top3
Feedback value loaded is potentially changed by
method outside CUT.
35Work in Progress
- APE Graph
- Implementation of the APE graph
- Empirical study of the space and time
requirements - Empirical characterization study of the object
manipulations in real object-oriented codes - Test Tuple Construction Algorithm
- Algorithm extensions to include coverage for
object manipulations based on references only - Algorithm modifications - more sophisticated
techniques to eliminate infeasible paths - Evaluation of the algorithm