Skip to content

Commit 970b994

Browse files
author
Daniel Kroening
authored
Merge pull request #194 from theyoucheng/unwind
Unwinding operation of goto-instrument
2 parents 2a977f6 + 2da8926 commit 970b994

File tree

25 files changed

+504
-1
lines changed

25 files changed

+504
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
default: tests.log
2+
3+
testalpha:
4+
@../test.pl -c ../unwind-chain.sh -C
5+
6+
testbeta:
7+
@../test.pl -c ../unwind-chain.sh -T
8+
9+
testimpr:
10+
@../test.pl -c ../unwind-chain.sh -K
11+
12+
testnew:
13+
@../test.pl -c ../unwind-chain.sh -F
14+
15+
test:
16+
@../test.pl -c ../unwind-chain.sh
17+
18+
tests.log: ../test.pl
19+
@../test.pl -c ../unwind-chain.sh
20+
21+
clean:
22+
@for dir in *; do \
23+
if [ -d "$$dir" ]; then \
24+
rm $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \
25+
fi; \
26+
done;
27+
28+
show:
29+
@for dir in *; do \
30+
if [ -d "$$dir" ]; then \
31+
vim -o "$$dir/*.c" "$$dir/*.out"; \
32+
fi; \
33+
done;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
void f() {}
3+
4+
int main()
5+
{
6+
/**
7+
* This is a test case for the unwind operation of goto-instrument;
8+
* every loop will be unwound K times
9+
**/
10+
const unsigned K=10;
11+
12+
const unsigned n=100;
13+
unsigned c=0, i;
14+
unsigned tres=K/2;;
15+
16+
for(i=1; i<=n; i++)
17+
{
18+
f();
19+
c++;
20+
if(i==tres)
21+
break;
22+
}
23+
24+
unsigned eva=n;
25+
if(K<eva) eva=K;
26+
if(tres<eva) eva=tres;
27+
28+
__CPROVER_assert(c==eva, "break a loop unwind (1)");
29+
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
10
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
void f() {}
3+
4+
int main()
5+
{
6+
/**
7+
* This is a test case for the unwind operation of goto-instrument;
8+
* every loop will be unwound K times
9+
**/
10+
const unsigned K=100;
11+
12+
const unsigned n=10;
13+
unsigned c=0, i;
14+
unsigned tres=K/2;;
15+
16+
for(i=1; i<=n; i++)
17+
{
18+
f();
19+
c++;
20+
if(i==tres)
21+
break;
22+
}
23+
24+
unsigned eva=n;
25+
if(K<eva) eva=K;
26+
if(tres<eva) eva=tres;
27+
28+
__CPROVER_assert(c==eva, "break a loop unwind (2)");
29+
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
100
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
void f() {}
3+
4+
int main()
5+
{
6+
/**
7+
* This is a test case for the unwind operation of goto-instrument;
8+
* every loop will be unwound K times
9+
**/
10+
const unsigned K=10;
11+
12+
const unsigned n=100;
13+
unsigned c=0, i;
14+
unsigned tres=K/2;;
15+
16+
for(i=1; i<=n; i++)
17+
{
18+
f();
19+
if(i>tres)
20+
continue;
21+
c++;
22+
}
23+
24+
unsigned eva=n;
25+
if(K<eva) eva=K;
26+
if(tres<eva) eva=tres;
27+
28+
__CPROVER_assert(c==eva, "continue in a loop unwind (1)");
29+
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
10
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
void f() {}
3+
4+
int main()
5+
{
6+
/**
7+
* This is a test case for the unwind operation of goto-instrument;
8+
* every loop will be unwound K times
9+
**/
10+
const unsigned K=100;
11+
12+
const unsigned n=10;
13+
unsigned c=0, i;
14+
unsigned tres=n/2;;
15+
16+
for(i=1; i<=n; i++)
17+
{
18+
f();
19+
if(i>tres)
20+
continue;
21+
c++;
22+
}
23+
24+
unsigned eva=n;
25+
if(K<eva) eva=K;
26+
if(tres<eva) eva=tres;
27+
28+
__CPROVER_assert(c==eva, "continue in a loop unwind (2)");
29+
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
100
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
int main()
3+
{
4+
/**
5+
* This is a test case for the unwind operation of goto-instrument;
6+
* every loop will be unwound K times
7+
**/
8+
const unsigned K=10;
9+
10+
const unsigned n=100;
11+
unsigned i=0;
12+
13+
while(++i<n)
14+
{
15+
}
16+
17+
unsigned eva=n;
18+
if(K<eva) eva=K;
19+
20+
__CPROVER_assert(i==eva, "Empty loop unwind (1)");
21+
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
10
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
int main()
3+
{
4+
/**
5+
* This is a test case for the unwind operation of goto-instrument;
6+
* every loop will be unwound K times
7+
**/
8+
const unsigned K=100;
9+
10+
const unsigned n=10;
11+
unsigned i=0;
12+
13+
while(++i<n)
14+
{
15+
}
16+
17+
unsigned eva=n;
18+
if(K<eva) eva=K;
19+
20+
__CPROVER_assert(i==eva, "Empty loop unwind (1)");
21+
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
100
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
void f() {}
3+
void f2() {}
4+
5+
int main()
6+
{
7+
/**
8+
* This is a test case for the unwind operation of goto-instrument;
9+
* every loop will be unwound K times
10+
**/
11+
const unsigned K=10;
12+
13+
const unsigned n=100;
14+
unsigned c=0, i;
15+
16+
for(i=1; i<=n; i++)
17+
{
18+
f();
19+
c++;
20+
21+
// the nested loop
22+
unsigned j, c2=0;
23+
for(j=1; j<=i; j++)
24+
{
25+
f2();
26+
c2++;
27+
}
28+
unsigned eva2=i;
29+
if(K<eva2) eva2=K;
30+
31+
__CPROVER_assert(c2==eva2, "Nested loops unwind (1): the inner one");
32+
33+
}
34+
35+
unsigned eva=n;
36+
if(K<eva) eva=K;
37+
38+
__CPROVER_assert(c==eva, "Nested loops unwind (1)");
39+
40+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
10
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
void f() {}
3+
void f2() {}
4+
5+
int main()
6+
{
7+
/**
8+
* This is a test case for the unwind operation of goto-instrument;
9+
* every loop will be unwound K times
10+
**/
11+
const unsigned K=10;
12+
13+
const unsigned n=6;
14+
unsigned c=0, i;
15+
16+
for(i=1; i<=n; i++)
17+
{
18+
f();
19+
c++;
20+
21+
// the nested loop
22+
unsigned j, c2=0;
23+
for(j=1; j<=i; j++)
24+
{
25+
f2();
26+
c2++;
27+
}
28+
unsigned eva2=i;
29+
if(K<eva2) eva2=K;
30+
31+
__CPROVER_assert(c2==eva2, "Nested loops unwind (2): the inner one");
32+
33+
}
34+
35+
unsigned eva=n;
36+
if(K<eva) eva=K;
37+
38+
__CPROVER_assert(c==eva, "Nested loops unwind (2)");
39+
40+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
10
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
void f() {}
3+
4+
int main()
5+
{
6+
/**
7+
* This is a test case for the unwind operation of goto-instrument;
8+
* every loop will be unwound K times
9+
**/
10+
const unsigned K=10;
11+
12+
const unsigned n=100;
13+
unsigned c=0, i;
14+
15+
for(i=1; i<=n; i++)
16+
{
17+
f();
18+
c++;
19+
}
20+
21+
unsigned eva=n;
22+
if(K<eva) eva=K;
23+
24+
__CPROVER_assert(c==eva, "Simple loop unwind (1)");
25+
26+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
10
4+
^SIGNAL=0$
5+
^VERIFICATION SUCCESSFUL$
6+
--
7+
^warning: ignoring

0 commit comments

Comments
 (0)