Skip to content

Commit fc57d6f

Browse files
Add tests for boolean constant propagation in C
Check that symex can resolve what value a boolean takes after a condition which means that it can only take one value
1 parent 65293be commit fc57d6f

11 files changed

+182
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function disequals_false
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function disequals_true
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function equals_false
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function equals_true
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function no_comparison
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function not_disequals_false
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function not_disequals_false
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function not_equals_false
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function not_equals_true
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--function not_no_comparison
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include <assert.h>
2+
#include <stdbool.h>
3+
4+
void no_comparison(bool my_bool)
5+
{
6+
if(my_bool)
7+
assert(my_bool == true);
8+
}
9+
10+
void not_no_comparison(bool my_bool)
11+
{
12+
if(!my_bool)
13+
assert(my_bool == false);
14+
}
15+
16+
void equals_true(bool my_bool)
17+
{
18+
if(my_bool == true)
19+
assert(my_bool == true);
20+
}
21+
22+
void equals_false(bool my_bool)
23+
{
24+
if(my_bool == false)
25+
assert(my_bool == false);
26+
}
27+
28+
void not_equals_true(bool my_bool)
29+
{
30+
if(!(my_bool == true))
31+
assert(my_bool == false);
32+
}
33+
34+
void not_equals_false(bool my_bool)
35+
{
36+
if(!(my_bool == false))
37+
assert(my_bool == true);
38+
}
39+
40+
void disequals_true(bool my_bool)
41+
{
42+
if(my_bool != true)
43+
assert(my_bool == false);
44+
}
45+
46+
void disequals_false(bool my_bool)
47+
{
48+
if(my_bool != false)
49+
assert(my_bool == true);
50+
}
51+
52+
void not_disequals_true(bool my_bool)
53+
{
54+
if(!(my_bool != true))
55+
assert(my_bool == true);
56+
}
57+
58+
void not_disequals_false(bool my_bool)
59+
{
60+
if(!(my_bool != false))
61+
assert(my_bool == false);
62+
}

0 commit comments

Comments
 (0)