Does tes'ng help to reduce the number of poten'ally faulty - - PowerPoint PPT Presentation

does tes ng help to reduce the number of poten ally faulty
SMART_READER_LITE
LIVE PREVIEW

Does tes'ng help to reduce the number of poten'ally faulty - - PowerPoint PPT Presentation

Does tes'ng help to reduce the number of poten'ally faulty statements in debugging? Mihai Nica, Simona Nica, and Franz Wotawa Technische Universitt


slide-1
SLIDE 1

Does ¡tes'ng ¡help ¡to ¡reduce ¡the ¡ number ¡of ¡poten'ally ¡faulty ¡ statements ¡in ¡debugging? ¡ ¡

Mihai ¡Nica, ¡Simona ¡Nica, ¡and ¡Franz ¡Wotawa ¡

Technische ¡Universität ¡Graz ¡ Ins9tute ¡for ¡So<ware ¡Technology ¡ {mnica,snica,wotawa}@ist.tugraz.at

The ¡research ¡herein ¡is ¡par9ally ¡conducted ¡within ¡the ¡competence ¡network ¡So<net ¡Austria ¡ (www.so<-­‑net.at) ¡and ¡funded ¡by ¡the ¡Austrian ¡FederalMinistry ¡of ¡Economics ¡(bm:wa), ¡the ¡ province ¡of ¡Styria, ¡the ¡Steirische ¡Wirtscha<sf¨orderungsgesellscha< ¡mbH. ¡(SFG), ¡and ¡the ¡ city ¡of ¡Vienna ¡in ¡terms ¡of ¡the ¡center ¡for ¡innova9on ¡and ¡technology ¡(ZIT) ¡and ¡the ¡Austrian ¡ Science ¡Fund ¡(FWF) ¡under ¡contract ¡number ¡P20199-­‑N15 ¡

slide-2
SLIDE 2

Mo'va'on ¡

  • A ¡lot ¡of ¡research ¡in ¡automated ¡debugging ¡(but ¡

maybe ¡not ¡enough), ¡e.g., ¡

– ¡Vidroha ¡Debroy ¡and ¡W. ¡Eric ¡Wong. ¡Using ¡ muta8on ¡to ¡automa8cally ¡suggest ¡fixes ¡for ¡faulty ¡ programs, ¡ICST ¡2010 ¡introducing ¡possible ¡fixes. ¡

  • Using ¡muta9ons ¡or ¡gene9c ¡programming ¡
  • There ¡are ¡too ¡many ¡possible ¡fixes! ¡
  • Reducing ¡the ¡number ¡of ¡possible ¡fixes ¡via ¡

tes9ng ¡

2 ¡ TAIC-­‑PART ¡2010 ¡

slide-3
SLIDE 3

Mo'va'on ¡

  • 1. begin
  • 2. i = 2 * x;
  • 3. j = 2 * y;
  • 4. o1 = i + j;
  • 5. o2 = i * i;
  • 6. end;

x = 1, y = 2, o1 = 8, o2 = 4

Debugger ¡ Diagnoses? ¡

3 ¡ TAIC-­‑PART ¡2010 ¡

slide-4
SLIDE 4

Debugging ¡using ¡constraints ¡

  • 1. begin
  • 2. i = 2 * x;
  • 3. j = 2 * y;
  • 4. o1 = i + j;
  • 5. o2 = i * i;
  • 6. end;

Ab(2) ¡∨ ¡ ¡i ¡= ¡2 ¡* ¡x; ¡ Ab(3) ¡∨ ¡ ¡j ¡= ¡2 ¡* ¡y; ¡ Ab(4) ¡∨ ¡ ¡o1 ¡= ¡i ¡+ ¡j; ¡ Ab(5) ¡∨ ¡ ¡o2 ¡= ¡i ¡* ¡i; ¡

x = 1, y = 2, o1 = 8, o2 = 4

x ¡= ¡1 ¡ y ¡= ¡2 ¡

  • 1 ¡= ¡8 ¡
  • 2 ¡= ¡4 ¡

Programm ¡execu'on ¡ Constraint ¡solving ¡/ ¡ equa'on ¡solving ¡

4 ¡ TAIC-­‑PART ¡2010 ¡

slide-5
SLIDE 5

Finding ¡bugs ¡using ¡constraints ¡

Ab(2) ¡∨ ¡ ¡i ¡= ¡2 ¡* ¡x; ¡ Ab(3) ¡∨ ¡ ¡j ¡= ¡2 ¡* ¡y; ¡ Ab(4) ¡∨ ¡ ¡o1 ¡= ¡i ¡+ ¡j; ¡ Ab(5) ¡∨ ¡ ¡o2 ¡= ¡i ¡* ¡i; ¡ x ¡= ¡1 ¡ y ¡= ¡2 ¡

  • 1 ¡= ¡8 ¡
  • 2 ¡= ¡4 ¡

¬Ab(2) ¡∧ ¡Ab(3) ¡∧ ¡¬Ab(4) ¡∧ ¡¬Ab(5) ¡ ¡ ¡ ¡

i ¡= ¡2 ¡* ¡1 ¡= ¡2 ¡

  • 1 ¡= ¡8 ¡= ¡2 ¡+ ¡j ¡→ ¡ ¡j ¡= ¡6 ¡
  • 2 ¡= ¡4 ¡= ¡i ¡* ¡i ¡= ¡2 ¡* ¡2 ¡ ¡

Ab(2) ¡∧ ¡¬Ab(3) ¡∧ ¡¬Ab(4) ¡∧ ¡¬Ab(5) ¡ ¡ ¡ ¡

j ¡= ¡2 ¡* ¡2 ¡= ¡4 ¡

  • 1 ¡= ¡i ¡+ ¡j ¡= ¡8 ¡= ¡i ¡+ ¡4 ¡→ ¡ ¡i ¡= ¡4 ¡
  • 2 ¡= ¡4 ¡= ¡i ¡* ¡i ¡= ¡4 ¡* ¡4 ¡→ ¡FAIL!!!! ¡ ¡ ¡

And ¡so ¡on ¡... ¡finally ¡leading ¡to ¡2 ¡ possible ¡diagnoses ¡statement ¡3 ¡and ¡ statement ¡4 ¡ ¡

5 ¡ TAIC-­‑PART ¡2010 ¡

slide-6
SLIDE 6

What ¡we ¡have ¡reached... ¡

  • Automated ¡debugging ¡using ¡constraints ¡and ¡

the ¡Ab ¡predicates ¡

  • But: ¡How ¡to ¡handle ¡recursions, ¡loops, ¡

condi9onals, ¡mul9ple ¡defini9ons ¡of ¡the ¡same ¡ variable,...??? ¡ ¡

6 ¡ TAIC-­‑PART ¡2010 ¡

slide-7
SLIDE 7

Handling ¡loops ¡

  • Execu9on ¡of ¡ ¡

¡ ¡ ¡ ¡ ¡ ¡ ¡while (e > 0) { ... }
 leads ¡to:
 if (e > 0) { ...
 if (e > 0) { ...
 if (e > 0) { ... }}}

7 ¡ TAIC-­‑PART ¡2010 ¡

slide-8
SLIDE 8

Loop ¡unrolling ¡

8 ¡ TAIC-­‑PART ¡2010 ¡

slide-9
SLIDE 9

Sta'c ¡single ¡assignment ¡form ¡(SSA ¡ form) ¡

  • In ¡order ¡to ¡convert ¡programs ¡to ¡constraints ¡

every ¡variable ¡is ¡only ¡allowed ¡to ¡be ¡defined ¡

  • nce! ¡
  • Solu'on: ¡convert ¡the ¡loop-­‑free ¡program ¡

into ¡its ¡SSA ¡form ¡

9 ¡ TAIC-­‑PART ¡2010 ¡

slide-10
SLIDE 10

SSA ¡form ¡

  • Property: ¡No ¡two ¡le<-­‑side ¡(=defined) ¡variables ¡

have ¡the ¡same ¡name ¡

  • Assign ¡each ¡defined ¡variable ¡an ¡unique ¡index. ¡
  • If ¡a ¡variable ¡is ¡used ¡a<erwards ¡in ¡the ¡program, ¡

refer ¡to ¡the ¡last ¡given ¡index. ¡

10 ¡ TAIC-­‑PART ¡2010 ¡

slide-11
SLIDE 11

Condi'onal ¡statements ¡

  • Statement ¡of ¡the ¡form ¡

if C ¡then B1 else B2 end if;

  • Convert ¡B1 ¡and ¡B2 ¡separately ¡using ¡a ¡

dis9nguished ¡set ¡of ¡indices ¡

11 ¡ TAIC-­‑PART ¡2010 ¡

slide-12
SLIDE 12

Condi'onal ¡statements ¡

  • Introduce ¡a ¡new ¡func9on ¡Φ. ¡ ¡
  • Add ¡a ¡new ¡statement ¡

¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡x_C = C;


  • For ¡each ¡defined ¡variable ¡x ¡in ¡either ¡B1 ¡or ¡B2 ¡add ¡the ¡

following ¡assignment: ¡ x_i = Φ(x_index(B1),x_index(B2),x_C);

12 ¡ TAIC-­‑PART ¡2010 ¡

slide-13
SLIDE 13

Seman'cs ¡of ¡Φ ¡ ¡

13 ¡ TAIC-­‑PART ¡2010 ¡

slide-14
SLIDE 14

So ¡debugging ¡using ¡constraints ¡is ¡ possible ¡for ¡general ¡programs... ¡

  • But ¡there ¡are ¡some ¡challenges ¡remaining: ¡

– OO ¡constructs ¡ – Reducing ¡the ¡number ¡of ¡bug ¡candidates ¡ – Providing ¡informa9on ¡about ¡how ¡to ¡correct ¡ programs ¡ – ... ¡

14 ¡ TAIC-­‑PART ¡2010 ¡

slide-15
SLIDE 15

Correc'ng ¡programs ¡... ¡ ¡ ... ¡using ¡muta'ons ¡

  • 1. begin
  • 2. i = 2 * x;
  • 3. j = 2 * y;
  • 4. o1 = i + j;
  • 5. o2 = i * i;
  • 6. end;

x = 1, y = 2, o1 = 8, o2 = 4 j = 3 * y; ...

  • 1 = i + j + 2;

15 ¡ TAIC-­‑PART ¡2010 ¡

slide-16
SLIDE 16

Possible ¡fixes ¡can ¡be ¡used ¡to ¡reduce ¡ the ¡number ¡of ¡possible ¡diagnoses! ¡

  • Given: ¡

– Program ¡ – Test ¡suite ¡ – Muta9ons ¡of ¡the ¡program ¡wrt. ¡given ¡diagnoses ¡

  • If ¡there ¡is ¡no ¡muta9on ¡of ¡a ¡diagnosis ¡that ¡

passes ¡the ¡test ¡suite, ¡remove ¡the ¡diagnosis ¡ from ¡the ¡list ¡of ¡possible ¡diagnoses! ¡

16 ¡ TAIC-­‑PART ¡2010 ¡

slide-17
SLIDE 17

Other ¡possiblity ¡for ¡removing ¡ diagnoses ¡is ¡to ¡use ¡dis'nguishing ¡test ¡ cases ¡

  • Use ¡new ¡(dis9nguishing) ¡test ¡cases ¡for ¡removing ¡diagnosis ¡

candidates! ¡

  • Note: ¡

– A ¡diagnosis ¡candidate ¡can ¡be ¡eliminated ¡if ¡the ¡new ¡test ¡ case ¡is ¡in ¡contradic9on ¡with ¡its ¡behavior. ¡ ¡ – Hence, ¡we ¡compute ¡dis9nguishing ¡test ¡cases ¡for ¡each ¡pair ¡

  • f ¡candidates ¡and ¡ask ¡the ¡user ¡(or ¡another ¡oracle) ¡for ¡the ¡

expected ¡output ¡values. ¡ – The ¡problem ¡of ¡dis9nguishing ¡diagnosis ¡candidates ¡is ¡ reduced ¡to ¡the ¡problem ¡of ¡compu9ng ¡dis9nguishing ¡test ¡ cases! ¡

17 ¡ TAIC-­‑PART ¡2010 ¡

slide-18
SLIDE 18

Some ¡defini'ons ¡

18 ¡ TAIC-­‑PART ¡2010 ¡

slide-19
SLIDE 19
  • Def. ¡dis'nguishing ¡test ¡case ¡

19 ¡ TAIC-­‑PART ¡2010 ¡

slide-20
SLIDE 20

Example ¡(cont.) ¡

  • 1. begin
  • 2. i = 2 * x;
  • 3. j = 3 * y;
  • 4. o1 = i + j;
  • 5. o2 = i * i;
  • 6. end;

x = 1, y = 2, o1 = 8, o2 = 4

  • 1. begin
  • 2. i = 2 * x;
  • 3. j = 2 * y;
  • 4. o1 = i + j + 2;
  • 5. o2 = i * i;
  • 6. end;

x = 1, y = 1

  • 1 = 5, o2 = 4
  • 1 = 6, o2 = 4

Original ¡test ¡case ¡ Dis'nguishing ¡test ¡case ¡ Mutant ¡1 ¡ Mutant ¡2 ¡

20 ¡ TAIC-­‑PART ¡2010 ¡

slide-21
SLIDE 21

Compu'ng ¡dis'nguishing ¡test ¡cases ¡

  • Given ¡two ¡programs. ¡
  • 1. Convert ¡programs ¡into ¡their ¡constraint ¡

representa9on ¡

  • 2. Add ¡constraints ¡sta9ng ¡that ¡the ¡inputs ¡have ¡to ¡be ¡

equivalent ¡

  • 3. Add ¡constraints ¡sta9ng ¡that ¡at ¡least ¡one ¡output ¡has ¡

to ¡be ¡different ¡

  • 4. Use ¡the ¡constraint ¡solver ¡to ¡compute ¡the ¡

dis9nguishing ¡test ¡case ¡

21 ¡ TAIC-­‑PART ¡2010 ¡

slide-22
SLIDE 22

Bringing ¡it ¡all ¡together... ¡ ¡

1. Convert ¡the ¡program ¡into ¡its ¡constraint ¡representa9on ¡ 2. Compute ¡all ¡possible ¡diagnoses ¡using ¡the ¡given ¡test ¡suite ¡ 3. Compute ¡the ¡muta9ons ¡for ¡the ¡obtained ¡diagnosis ¡and ¡remove ¡ those ¡mutants ¡that ¡are ¡in ¡contradic9on ¡with ¡at ¡least ¡one ¡test ¡case. ¡ ¡ 4. Filter ¡the ¡obtained ¡diagnoses ¡using ¡the ¡remaining ¡muta9ons. ¡ 5. Select ¡two ¡muta9ons ¡and ¡compute ¡the ¡dis9nguishing ¡test ¡case. ¡ 6. Ask ¡the ¡user ¡about ¡the ¡expected ¡output ¡values. ¡ 7. Add ¡the ¡dis9nguishing ¡test ¡cases ¡including ¡the ¡expected ¡outputs ¡to ¡ the ¡test ¡suite ¡ 8. Remove ¡all ¡mutants ¡that ¡do ¡not ¡pass ¡the ¡new ¡test. ¡If ¡the ¡number ¡of ¡ remaining ¡diagnoses ¡is ¡sufficently ¡small ¡stop. ¡Otherwise, ¡go ¡to ¡5. ¡ ¡ ¡

22 ¡ TAIC-­‑PART ¡2010 ¡

slide-23
SLIDE 23

Empirical ¡results ¡

23 ¡ TAIC-­‑PART ¡2010 ¡

slide-24
SLIDE 24

Conclusion ¡

  • Does ¡tes'ng ¡help ¡to ¡reduce ¡the ¡number ¡of ¡

poten'ally ¡faulty ¡statements ¡in ¡debugging? ¡ ¡

  • Answer: ¡YES! ¡
  • Debugging ¡= ¡Constraint ¡solving ¡
  • Muta9ons ¡for ¡obtaining ¡correc9ons ¡
  • Dis9nguishing ¡test ¡cases ¡for ¡reducing ¡

diagnoses ¡

24 ¡ TAIC-­‑PART ¡2010 ¡

slide-25
SLIDE 25

Related ¡Literature ¡

  • Wotawa, ¡F., ¡Nica, ¡M., ¡Aichernig, ¡B.K.: ¡Genera9ng ¡

dis9nguishing ¡tests ¡using ¡the ¡minion ¡constraint ¡solver. ¡In: ¡ CSTVA ¡2010: ¡Proceedings ¡of ¡the ¡2nd ¡Workshop ¡on ¡ Constraints ¡for ¡Tes9ng, ¡Verifica9on ¡and ¡Analysis, ¡IEEE ¡ (2010). ¡

  • Ceballos, ¡R., ¡Nica, ¡M., ¡Weber, ¡J., ¡Wotawa, ¡F.: ¡On ¡the ¡

complexity ¡of ¡program ¡debugging ¡using ¡constraints ¡for ¡ modeling ¡the ¡program’s ¡syntax ¡and ¡seman9cs. ¡In: ¡In ¡Proc. ¡ Conference ¡of ¡the ¡Spanish ¡Associa8on ¡for ¡Ar8ficial ¡ Intelligence ¡(CAEPIA), ¡Seville, ¡Spain ¡(2009). ¡

  • Wotawa, ¡F., ¡Nica, ¡M., ¡Moraru, ¡I., ¡Automated ¡Debugging ¡

based ¡on ¡a ¡Constraint ¡Model ¡of ¡the ¡Program ¡and ¡a ¡Test ¡ Case, ¡Currently ¡under ¡Review. ¡

TAIC-­‑PART ¡2010 ¡ 25 ¡

slide-26
SLIDE 26

Thank ¡you ¡for ¡your ¡aWen'on! ¡

TAIC-­‑PART ¡2010 ¡ 26 ¡