Moonzoo Kim Provable Software Laboratory CS Dept. KAIST

Slides:



Advertisements
Similar presentations
Masahiro Fujita Yoshihisa Kojima University of Tokyo May 2, 2008
Advertisements

PLDI’2005Page 1June 2005 Example (C code) int double(int x) { return 2 * x; } void test_me(int x, int y) { int z = double(x); if (z==y) { if (y == x+10)
Necessity of Systematic & Automated Testing Techniques Moonzoo Kim CS Dept, KAIST.
A b c p q r. Goal 1: How to identify congruent triangles. Goal 2: How to identify different types of triangles. Definition of Congruent Triangles If 
CREST Examples -Basic Examples -Function Examples -Limitation Examples.
CSE503: SOFTWARE ENGINEERING SYMBOLIC TESTING, AUTOMATED TEST GENERATION … AND MORE! David Notkin Spring 2011.
Chapter 7Louden, Programming Languages1 Chapter 7 - Control I: Expressions and Statements "Control" is the general study of the semantics of execution.
CREST Tutorial Moonzoo Kim Provable Software Laboratory CS Dept. KAIST.
EXAMPLE 1 Classify triangles by sides and by angles SOLUTION The triangle has a pair of congruent sides, so it is isosceles. By measuring, the angles are.
 T RIANGLE : A figure formed by three noncollinear points, connected by segments  Since two of the segments create a vertex, a triangle has three vertices.
CREST Internal Yunho Kim Provable Software Laboratory CS Dept. KAIST.
Provable Software Laboratory Moonzoo Kim
Software Testing (Part 2)
Control Structures – Selection Chapter 4 2 Chapter Topics  Control Structures  Relational Operators  Logical (Boolean) Operators  Logical Expressions.
Software Testing. 2 CMSC 345, Version 4/12 Topics The testing process  unit testing  integration and system testing  acceptance testing Test case planning.
Intro. to Logic CS402 1 HW #5: Due June 6th 23:59 HW #5: Due June 6th 23:59.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Summarizing “Structural” Testing Now that we have learned to create test cases through both: – a) Functional (blackbox)and – b) Structural (whitebox) testing.
Software Testing. Software testing is the execution of software with test data from the problem domain. Software testing is the execution of software.
HW6: Due Dec 8th 23:59 1.Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
Chapter 6.  Control Structures are statements that are used to perform repetitive tasks and to make decisions within a program. Loop repeats a sequence.
EXAMPLE 1 Standardized Test Practice SOLUTION Let ( x 1, y 1 ) = ( –3, 5) and ( x 2, y 2 ) = ( 4, – 1 ). = (4 – (–3)) 2 + (– 1 – 5) 2 = = 85 (
A13. Testing Intro Data Structures & SE Computer Science Dept Va Tech Aug., 2001 © Barnette ND, McQuain WD 1 Levels of Verification The Unreachable.
HW4: Due Nov 24th 23:59 1.Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
1 CS 177 Week 6 Recitation Slides Review for Midterm Exam.
Lazy Annotation for Program Testing and Verification (Supplementary Materials) Speaker: Chen-Hsuan Adonis Lin Advisor: Jie-Hong Roland Jiang December 3,
HW7: Due Dec 5th 23:59 1.Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION SYMBOLIC TESTING Autumn 2011.
Digitaalsüsteemide verifitseerimise kursus1 Exercises Binary decision diagrams ROBDD generation. Shannon expansion Finding an optimal ordering Dynamic.
1841f06detprob4 Testing Basics Detection probability.
SOFTWARE TESTING. SOFTWARE Software is not the collection of programs but also all associated documentation and configuration data which is need to make.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
Software Dynamic White-box Testing Lecture 6 Part 1: Control-flow Testing.
White Box Testing. Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A.
Digital Logic Design. Truth Table  Logic Circuit 1. Start with truth table 2. When your output is a 1, figure out the combination of inputs, ANDs, and.
Lab 7 Control-Flow Testing
Software Testing Structural testing 540f07testing17oct25 1.
Software Testing Structural testing 1.
Boundaries and C0,C1 Pressman pp
Properties of Triangles
White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, Ghezzi, C. et al., Fundamentals of Software Engineering.
Moonzoo Kim CS Dept. KAIST
Path testing Path testing is a “design structural testing” in that it is based on detailed design & the source code of the program to be tested. The.
Moonzoo Kim CS Dept. KAIST
Automated Software Analysis Techniques For High Reliability: A Concolic Testing Approach Moonzoo Kim.
Detection probability
4 Main Steps of Concolic Testing
Basic Examples Function Examples Limitation Examples
Automatic Test Generation SymCrete
4 Main Steps of Concolic Testing
Basic Examples Function Examples Limitation Examples
Graph Coverage for Source Code
Automated Software Analysis Techniques For High Reliability: A Concolic Testing Approach Moonzoo Kim.
Moonzoo Kim SWTV Group CS Dept. KAIST
Graph Coverage Criteria
Example (C code) int double(int x) { return 2 * x; }
Logic Coverage from Source Code
Graph Coverage Criteria
How to Seed an Initial Test Case to CREST
Triangles.
Intro to Triangles.
TRIANGLE CONGRUENCE p q r a b c LESSON 17.
4-1 Classifying Triangles
CSCE 206 Lab Structured Programming in C
Testing grep.c (200 pts) For grep.c, generate 10,000 test cases through the (reverse) DFS search strategy. You are requested to modify grep.c to create.
HW4: Concolic testing Busybox expr (due Nov 30 23:59)
Examples of First Order Theories
HW4: Due Nov 22nd 23:59 Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also,
HW7: Due Dec 5th 23:59 Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
HW#7 Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw the complete execution.
Presentation transcript:

Moonzoo Kim Provable Software Laboratory CS Dept. KAIST CREST Tutorial Moonzoo Kim Provable Software Laboratory CS Dept. KAIST

Moonzoo Kim Provable SW Lab “Software Testing a craftsman’s approach” 2nd ed by P.C.Jorgensen (no check for positive inputs) 1 #include <crest.h> 2 main() { 3 int a,b,c, match=0; 4 CREST_int(a); CREST_int(b); CREST_int(c); // filtering out invalid inputs 5 if(a <= 0 || b<= 0 || c<= 0) exit(); 6 printf("a,b,c = %d,%d,%d:",a,b,c); 7 8 //0: Equilateral, 1:Isosceles, // 2: Not a traiangle, 3:Scalene 9 int result=-1; 10 if(a==b) match=match+1; 11 if(a==c) match=match+2; 12 if(b==c) match=match+3; 13 if(match==0) { 14 if( a+b <= c) result=2; 15 else if( b+c <= a) result=2; 16 else if(a+c <= b) result =2; 17 else result=3; 18 } else { 19 if(match == 1) { 20 if(a+b <= c) result =2; 21 else result=1; 22 } else { 23 if(match ==2) { 24 if(a+c <=b) result = 2; 25 else result=1; 26 } else { 27 if(match==3) { 28 if(b+c <= a) result=2; 29 else result=1; 30 } else result = 0; 31 } }} 32 printf("result=%d\n",result); 33 } Moonzoo Kim Provable SW Lab

Concolic Testing the Triangle Program Testcase Input (a,b,c) Executed path conditions (PC) Next PC Solution for the next PC 1 1,1,1 a=b Æ a=c Æ b=c a=b Æ a=c Æ bc Unsat a=b Æ ac 1,1,2 2 a=b Æ ac Æ bc Æ a+b ≤c a=b Æ ac Æ bc Æ a+b > c 2,2,3 3 a=b Æ ac Æ bc Æ a+b >c a=b Æ ac Æ b=c ab 2,1,2 4 ab Æ a=c Æ bc Æ a+c>b abÆ a=c Æ bc Æ a+c ≤b 2,5,2 a=b a=c b=c TC1 ab a=c a+c >b bc TC4 ac bc a+b ≤c TC2 b=c bc a+b >c TC3 Moonzoo Kim Provable SW Lab

Moonzoo Kim Provable SW Lab CREST Commands crestc <filename>.c Output <filename>.cil.c // instrumented C file branches // lists of paired branches <filename> // executable file run_crest ./filename <n> -[dfs|cfg|random|random_input|hybrid] <n>: # of iterations/testings dfs: depth first search (but in reverse order) cfg: uncovered branch first random: negated branch is randomly selected random_input: pure random input hybrid: combination of dfs and random Moonzoo Kim Provable SW Lab

Moonzoo Kim Provable SW Lab Instrumented C Code #line 10 { /* Creates symbolic expression a==b */ __CrestLoad(36, (unsigned long )(& a), (long long )a); __CrestLoad(35, (unsigned long )(& b), (long long )b); __CrestApply2(34, 12, (long long )(a == b)); if (a == b) { __CrestBranch(37, 11, 1); //extern void __CrestBranch(int id , int bid , unsigned char b ) __CrestLoad(41, (unsigned long )(& match), (long long )match); __CrestLoad(40, (unsigned long )0, (long long )1); __CrestApply2(39, 0, (long long )(match + 1)); __CrestStore(42, (unsigned long )(& match)); match ++; } else { __CrestBranch(38, 12, 0); } } Moonzoo Kim Provable SW Lab

Moonzoo Kim Provable SW Lab Execution Snapshot [moonzoo@verifier crest]$ run_crest ./triangle 10000 -dfs Iteration 0 (0s): covered 0 branches [0 reach funs, 0 reach branches]. Iteration 1 (0s): covered 1 branches [1 reach funs, 32 reach branches]. Iteration 2 (0s): covered 3 branches [1 reach funs, 32 reach branches]. Iteration 3 (0s): covered 5 branches [1 reach funs, 32 reach branches]. a,b,c = 1,1,1:result=0 Iteration 4 (0s): covered 13 branches [1 reach funs, 32 reach branches]. a,b,c = 2,1,1:result=2 Iteration 5 (0s): covered 17 branches [1 reach funs, 32 reach branches]. a,b,c = 2,1,2:result=1 Iteration 6 (0s): covered 20 branches [1 reach funs, 32 reach branches]. a,b,c = 1,2,1:result=2 Iteration 7 (0s): covered 21 branches [1 reach funs, 32 reach branches]. a,b,c = 3,2,1:result=2 Iteration 8 (0s): covered 24 branches [1 reach funs, 32 reach branches]. a,b,c = 2,1,3:result=2 Iteration 9 (0s): covered 25 branches [1 reach funs, 32 reach branches]. a,b,c = 4,3,2:result=3 Iteration 10 (0s): covered 27 branches [1 reach funs, 32 reach branches]. a,b,c = 2,3,1:result=2 Iteration 11 (0s): covered 28 branches [1 reach funs, 32 reach branches]. a,b,c = 3,2,2:result=1 Iteration 12 (0s): covered 29 branches [1 reach funs, 32 reach branches]. a,b,c = 2,2,1:result=1 Iteration 13 (0s): covered 31 branches [1 reach funs, 32 reach branches]. a,b,c = 1,1,2:result=2 Iteration 14 (0s): covered 32 branches [1 reach funs, 32 reach branches]. elapsed time = 0.0015093 [moonzoo@verifier crest]$ cat coverage 3 /* covered branch ids*/ 4 5 6 7 8 11 12 14 15 17 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 Moonzoo Kim Provable SW Lab

Supported Symbolic Datatypes #define CREST_unsigned_char(x) __CrestUChar(&x) #define CREST_unsigned_short(x) __CrestUShort(&x) #define CREST_unsigned_int(x) __CrestUInt(&x) #define CREST_char(x) __CrestChar(&x) #define CREST_short(x) __CrestShort(&x) #define CREST_int(x) __CrestInt(&x) Moonzoo Kim Provable SW Lab

Decision/Condition Coverage Analysis by CREST 1 int main(){ 2 int A, B, C, D; 3 if (A && B || C && D){ 4 printf("Yes\n"); 5 }else{ 6 printf("No\n"); 7 } 8 } 1 if (A != 0) { 2 __CrestBranch(5, 2, 1); 3 if (B != 0) { 4 __CrestBranch(10, 3, 1); 5 printf("Yes\n"); 6 } else { 7 __CrestBranch(11, 4, 0); 8 goto _L; 9 } 10 } else { 11 __CrestBranch(6, 5, 0); 12 _L: /* CIL Label */ 13 if (C != 0) { 14 __CrestBranch(16, 6, 1); 15 if (D != 0) { 16 __CrestBranch(21, 7, 1); 17 printf("Yes\n"); 18 } else { 19 __CrestBranch(22, 8, 0); 20 printf("No\n"); 21 } 22 } else { 23 __CrestBranch(17, 9, 0); 24 printf("No\n"); 25 } 26 } A == T A == T && B == T A == T && B != T CREST consider all possible cases with short-circuit Thus, coverage reported by CREST might be lower than actual branch coverage A != TRUE (A != T || A == T && B != T) && C == T (A != T || A == T && B != T) && C == T && D == T (A != T || A == T && B != T) && C == T && D != T (A != T || A == T && B != T) && C != T