Skip to content

Commit 2aed98a

Browse files
committed
Add regression tests for havoc-ing of function arguments
1 parent 4c17764 commit 2aed98a

File tree

12 files changed

+180
-0
lines changed

12 files changed

+180
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void func(int *p);
5+
6+
void main()
7+
{
8+
int *p;
9+
p = NULL;
10+
11+
func(p);
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--generate-function-body func --generate-function-body-options havoc,params:p --pointer-check
4+
^SIGNAL=0$
5+
^EXIT=0$
6+
--
7+
^warning: ignoring
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void func(int *p);
5+
6+
void main()
7+
{
8+
int i;
9+
i = 0;
10+
11+
func(&i);
12+
13+
assert(i == 0);
14+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--generate-function-body func --generate-function-body-options havoc,params:p
4+
^SIGNAL=0$
5+
\[main.assertion.1\] line \d+ assertion i == 0: FAILURE
6+
--
7+
^warning: ignoring
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
typedef struct st1
5+
{
6+
struct st2 *to_st2;
7+
int data;
8+
} st1_t;
9+
10+
typedef struct st2
11+
{
12+
struct st1 *to_st1;
13+
int data;
14+
} st2_t;
15+
16+
st1_t dummy1;
17+
st2_t dummy2;
18+
19+
void func(st1_t *p);
20+
21+
void main()
22+
{
23+
st1_t st;
24+
25+
func(&st);
26+
27+
assert(st.to_st2 != NULL);
28+
assert(st.to_st2->to_st1 != NULL);
29+
assert(st.to_st2->to_st1->to_st2 == NULL);
30+
31+
assert(st.to_st2 != &dummy2);
32+
assert(st.to_st2->to_st1 != &dummy1);
33+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--generate-function-body func --generate-function-body-options 'havoc,params:p' --min-null-tree-depth 10 --max-nondet-tree-depth 3 --pointer-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
typedef struct st
5+
{
6+
int data;
7+
} st_t;
8+
9+
void func(st_t *p);
10+
11+
void main()
12+
{
13+
st_t st;
14+
st.data = 0;
15+
16+
func(&st);
17+
18+
assert(st.data == 0);
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--generate-function-body func --generate-function-body-options havoc,params:p
4+
^SIGNAL=0$
5+
\[main.assertion.1\] line \d+ assertion st.data == 0: FAILURE
6+
--
7+
^warning: ignoring
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
typedef struct st
5+
{
6+
struct st *next;
7+
struct st *prev;
8+
int data;
9+
} st_t;
10+
11+
st_t dummy;
12+
13+
void func(st_t *p);
14+
15+
void main()
16+
{
17+
st_t st;
18+
19+
func(&st);
20+
21+
assert(st.prev != NULL);
22+
assert(st.prev != &dummy);
23+
24+
assert(st.next != NULL);
25+
assert(st.next != &dummy);
26+
27+
assert(st.prev->prev == NULL);
28+
assert(st.prev->next == NULL);
29+
assert(st.next->prev == NULL);
30+
assert(st.next->next == NULL);
31+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--generate-function-body func --generate-function-body-options havoc,params:p --min-null-tree-depth 10 --max-nondet-tree-depth 2 --pointer-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
typedef struct st
5+
{
6+
struct st *next;
7+
int data;
8+
} st_t;
9+
10+
st_t dummy;
11+
12+
void func(st_t *p);
13+
14+
void main()
15+
{
16+
st_t st;
17+
18+
func(&st);
19+
20+
assert(st.next != NULL);
21+
assert(st.next->next != NULL);
22+
assert(st.next->next->next == NULL);
23+
24+
assert(st.next != &dummy);
25+
assert(st.next->next != &dummy);
26+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--generate-function-body func --generate-function-body-options havoc,params:p --min-null-tree-depth 10 --max-nondet-tree-depth 3
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)