tracing regression bugs

57
1 Tracing regression bugs Presented by Dor Nir

Upload: leighton-ace

Post on 04-Jan-2016

9 views

Category:

Documents


0 download

DESCRIPTION

Tracing regression bugs. Presented by Dor Nir. Outline. Problem introduction. Regression bug – definition. Industry tools. Proposed solution. Experimental results. Future work. Micronose corp. A big company founded by Nataly noseman 1998 – Version 1 of nosepad. (great success). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Tracing regression bugs

1

Tracing regression bugsPresented by Dor Nir

Page 2: Tracing regression bugs

2

Outline Problem introduction. Regression bug – definition. Industry tools. Proposed solution. Experimental results. Future work.

Page 3: Tracing regression bugs

3

Micronose corp. A big company founded by Nataly

noseman 1998 – Version 1 of nosepad. (great

success)Application

Page 4: Tracing regression bugs

4

Nosepad version 1

void Save(){

...

bDirty = false;

}

void Exit(){

if(IsDirty()) {

if(MsgBox(“Save your

noses?"))

Save();

}

CloseWindow();

}

}

class Nosepad

{

bool bDirty;

void AddNose(){

...

bDirty = true;

}

void DeleteNose(){

...

bDirty = true;

}

bool IsDirty(){

return bDirty;

}

Page 5: Tracing regression bugs

5

Nosepad version 2 New features requires

… … Undo/Redo mechanism. …

Micronose expanding Promotions. New recruitments.

Page 6: Tracing regression bugs

6

Undo/Redo Design Undo stack – Each operation will be added to the

undo stack. Redo stack - When undo operation this operation

will move to the redo stack.

Key “a”

Undo Redo

Key “b”

Page 7: Tracing regression bugs

7

Nosepad version 2class Nosepad

{ …

Stack undoStack;

Stack redoStack;

void Undo(){

undoStack.Top().Operate(false);

redoStack.Push(undoStack.Pop()); }

void Redo(){

redoStack.Top().Operate(true);

undoStack.Push(redoStack.Pop());

}

Application

void AddNose(){ ...

undoStack.Add(AddNoseOp);

redoStack.Clear();

}

void DeleteNose() {

...

undoStack.Add(DelNoseOp);

redoStack.Clear();

}

.

.

.

}

Page 8: Tracing regression bugs

8

Zelda from QA

Page 9: Tracing regression bugs

9

Nosepad version 2 correctionclass Nosepad

{…

Stack undoStack;

Stack redoStack;

void Undo(){

undoStack.Top().Operate(false);

redoStack.Push(undoStack.Pop());

}

void Redo(){

redoStack.Top().Operate(true);

undoStack.Push(redoStack.Pop());

}

void AddNose(){

...

undoStack.Add(AddNoseOp);

redoStack.Clear();

}

void DeleteNose() {

undoStack.Add(DelNoseOp);

redoStack.Clear();

}

bool IsDirty(){

return bDirty &

!undoStack.IsEmpty();

}

Page 10: Tracing regression bugs

10

Zelda from QA

Page 11: Tracing regression bugs

11

Regression bug observations The second bug is a regression bug. The same test will succeeded on version 1 and

fail on version 2. The specifications for version 1 haven't

change for version 2 (only addition)

Page 12: Tracing regression bugs

12

Version 1

Specifications1. X2. Y3. Z

Version 2

Specifications1. X2. Y3. Z4. A5. B

Changes in code

Regression bug

Bug…But no

regression

Page 13: Tracing regression bugs

13

Regression bug definition Regression bug – Changes in existing code

that change the behavior of the application so it does not meet a specification that was previously met.

Page 14: Tracing regression bugs

14

How to avoid regression bugs? Prevent inserting regression bug to the code:

Simple design. Programming language. Good programming. Methodology.

Test driven development. Code review. Communication.

Find regression bugs before release of the product. Extensive testing. White box \ Black box testing.

Page 15: Tracing regression bugs

15

Automatic tools Find whether a regression bug exist. Quick Test Professional.

Page 16: Tracing regression bugs

16

Where is it? What was the cause for the regression bug?

What was the change that caused the regression bug?

Page 17: Tracing regression bugs

17

What is a change? Change existing code lines Adding new code lines. Delete code lines.

Page 18: Tracing regression bugs

18

Problem definition When getting a check point C that failed, and

source code S of the AUT. We want to find the places (changes) in the code S that causes C to fail. We want to do it independently of the source

code language or technology. We know that at time T (previous to the failure)

the checkpoint passed.

nppp ..., 21

Page 19: Tracing regression bugs

19

Solution 1QA

TestsTests

Programmer

Source code

Cooperation

Page 20: Tracing regression bugs

20

Solution 1 - map

Windows.cpp

errorMessages.cpp

File.cpp

IO.cs

C:\code\files

DB project

Tests Source code

“SELECT NAMES from Table1” is not empty

File t.xml was Created successfully

Check text in message box

Page 21: Tracing regression bugs

21

Solution 1 Much work has to be done for each new test. Maintenance is hard. We end up with a lot of code to be analyzed. Could use automatic tools (profilers).

Page 22: Tracing regression bugs

22

Solution 2

Windows.cpp

errorMessages.cpp

File.cpp

IO.cs

C:\code\files

DB project

Check text in message box

Only

changes

“SELECT NAMES from Table1” is not empty

File t.xml was Created successfully

Page 23: Tracing regression bugs

23

Source Control Version control tool. Data base of source code. Check-in \ Check-out operation. History of versions. Differences between versions. Very common in software development. Currently in market:VSS, starTeam, clear

case, cvs and many more.

Page 24: Tracing regression bugs

24

Check point to code tool

Finding regression bug

Second phase

Source Control ToolChange AChange B…

Heuristics

Failed check point

First phase

Check point

Source code

Out put:Relevant changes: 1. Change X 2. Change Y 3. Change Z …

Input

Page 25: Tracing regression bugs

252

Heuristics (second phase) Rank changes. Each heuristic will get different weight. Two kinds of heuristics:

Technology dependence. Non technology dependence.

13

Page 26: Tracing regression bugs

26

Non-technology heuristics Do not depend on the technology of the code. Textual driven. No semantics.

Page 27: Tracing regression bugs

27

Code lines affinity

Check point

Select "clerk 1" from the clerk tree (clerk number 2). Go to the next clerk.The next clerk is "clerk 3"

Page 28: Tracing regression bugs

28

Check in comment affinity

Check point

Select "clerk 1" from the clerk tree (clerk number 2). Go to the next clerk.The next clerk is "clerk 3"

Check-in comment

Go to the next waiter when next item event is raise

Page 29: Tracing regression bugs

29

File affinity

Check point

Select "clerk 1" from the clerk tree (clerk number 2). Go to the next clerk.The next clerk is "clerk 3"

Words histogram in file Clerk.cpp

Waiter 186

Waiters 15

Next 26

Number 174

…..

…..

Page 30: Tracing regression bugs

30

File Name affinity

Check point

Select "clerk 1" from the clerk tree (clerk number 2). Go to the next clerk.The next clerk is "clerk 3"

ClerkDlg.cpp

Page 31: Tracing regression bugs

31

More possible non technology heuristics Programmers history.

Reliable vs. “Prone to error” programmers. Experience in the specific module.

Time of change. Late at night. Close to release dead line.

Page 32: Tracing regression bugs

32

Technology heuristics Depend on the source code language. Take advantage of known keywords. Use the semantics.

Page 33: Tracing regression bugs

33

Function\Class\Namespace affinity

Check point

Select "clerk 1" from the clerk tree (clerk number 2). Go to the next clerk.The next clerk is "clerk 3"

Page 34: Tracing regression bugs

34

Code complexity Deepness, number of branching.

if(b1 && b2)

{

if(c2 && d1)

c1 = true;

else

{

if((c2 && d2) || e1)

c1 = false;

}

}

if(b1 && b2 && c2 && d1)

c1 = true;

>

Page 35: Tracing regression bugs

35

Words affinity problem

red, flower, white, black,

cloud

rain, green, red, coat

Page 36: Tracing regression bugs

36

Words affinity problem (cont.)

red, flower, white, black,

cloud

rain, green, red, coat

>red, flower,

white, black, cloud

train, table, love

Page 37: Tracing regression bugs

37

Word affinity

red

flower

red

blue

red

red

< <

Page 38: Tracing regression bugs

38

How can we measure affinity? Vector space model of information retrieval .-

Wong S.K.M , raghavan Similarity of documents.

Improving web search results using affinity graph - benyu Zhang, Hau Li, Lei Ji, Wensi Xi, Weiguo Fan.

Similarity of documents. Diversity vs. Information richness of documents.

Page 39: Tracing regression bugs

39

Affinity definition Synonym (a) - Group of words that are

synonyms of a or similar in the meaning to a.

Synonym (choose)

chosen, picked out; choice, superior, prime; discriminating, choosy, picky , select, selection

=

Page 40: Tracing regression bugs

40

Words affinity definition (cont) 1 if a == b

ShallowAffinity (a,b) = 0 else 1 if a == b

Affinity (a,b) = else ShallowAffinity (synonym (a), synonym (b))

Page 41: Tracing regression bugs

Affinity of groups of words

||||

),(

),( ..1 ..1

BA

bainityShallowAff

BAinityShallowAff ni mjji

2

),(),(),(

||

)},(),...,,(max{),( ..1

1

ABffinityAsymetricABAffinityAsymetricABAAffinity

A

baAffinitybaAffinityBAffinityAsymetricA ni

mii

}...,,{

}...,,{

321

321

m

n

bbbbB

aaaaA

Page 42: Tracing regression bugs

42

Using affinity in the tool

))(),((),( PWordsCWordsAffinityPCRank

Words (C) = the group of words in the description of the checkpoint C.

Words (P) = Group of words in the source code/checkin/file etc…

Page 43: Tracing regression bugs

43

Using affinity in heuristics Code line affinity:

Words (P, L) = Group of words in the source code located L lines from the

change P. β – coefficient that gives different weight for lines inside the change.

Check-in comment affinity:))((),((),(2 PcheckinWordsCWordsAffinityPCRank

Page 44: Tracing regression bugs

44

Using affinity in heuristics (cont.) File affinity: P is a change in file F with histogram

map.

),(),(3 FCFileRankPCRank

))(),(),((),( FHstgrmFWordsCWordsnityHstgrmAffiFCFileRank

nii

niimii

amap

amapbaAffinitybaAffinitymapBAnityHstgrmAffi

..1

..11

][

][)},(),...,,(max{),,(

Page 45: Tracing regression bugs

45

Using affinity in heuristics (cont.) File name affinity:

Code elements affinity:

))((),((),(4 PFileNameWordsCWordsAffinityPCRank

))((),((8

1

))((),((8

3

))((),((2

1

),(5

PNamespaceWordsCWordsAffinity

PClassNameWordsCWordsAffinity

PmeFunctionNaWordsCWordsAffinity

PCRank

Page 46: Tracing regression bugs

46

AlgorithmInput: C – Checkpoint. T – The last time checkpoint C passed.1. Get the latest version of the source code for C from

the source control tool.2. Get files versions from the source control tool one

by one until the version check-in time is smaller then T. For each file version:

1. Get the change between the two sequential versions.2. Analyze and rank the change in respect to the checkpoint C (Rank(C,P))3. Add the rank to DB.

Page 47: Tracing regression bugs

47

Observations and i ≠ j

Better affinity Better results The project is not always in a valid state.

),(),( 21 PCRankPCRank ji

21 PP

Page 48: Tracing regression bugs

48

Implementation Visual source safe

Arexis merge – Diff tool.

MS Word

WordNet

MS Access – DB.

Page 49: Tracing regression bugs

49

WordNet Developed at the University of Princtoen. Large lexical database of English. English nouns, verbs, adjectives, and adverbs

are organized into synonym sets, each representing one underlying lexicalized concept.

Different relations link the synonym sets.

Page 50: Tracing regression bugs

50

Additional views Group by file. Group by time of change.

Page 51: Tracing regression bugs

51

The tool

Page 52: Tracing regression bugs

52

The tool

Page 53: Tracing regression bugs

53

Experimental Results Source code:

C++ MFC framework 891 files in 29 folders 3 millions lines of code 3984 check-ins

Page 54: Tracing regression bugs

54

Experimental results (cont.)Checkpoint No Grouping Group by file

1 1 1

2 2 7

3 2 2

4 - -

5 - 1

Page 55: Tracing regression bugs

55

Challenges Time.

Cache. Filtering by one heuristic.

Words equality. Source code vocabulary.

Example - m_CountItemInTable. Additional synonyms.

Clerk ≈ Waiter.

Page 56: Tracing regression bugs

56

Future work Add more heuristics. Learning mechanism – Automatic tuning of

heuristics. Why? Finding more about source of regression bugs.

Bad Programmer. Dead line. Technology. Design.

Page 57: Tracing regression bugs

57