Skip to content

Commit 79ea945

Browse files
authored
Merge pull request #4181 from NlightNFotis/non-det-struct-new
Non-deterministic initialisation of structs, pointers and globals in function call harness
2 parents a5944a7 + 550e6ab commit 79ea945

File tree

19 files changed

+609
-50
lines changed

19 files changed

+609
-50
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int a_global;
2+
3+
void entry_function(void)
4+
{
5+
assert(a_global == 0);
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--harness-type call-function --function entry_function
4+
^\[entry_function.assertion.1\] line \d+ assertion a_global == 0: SUCCESS$
5+
^VERIFICATION SUCCESSFUL$
6+
^EXIT=0$
7+
^SIGNAL=0$
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int a_global;
2+
3+
void entry_function(void)
4+
{
5+
assert(a_global == 0);
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--harness-type call-function --function entry_function --nondet-globals
4+
^\[entry_function.assertion.1\] line \d+ assertion a_global == 0: FAILURE$
5+
^VERIFICATION FAILED$
6+
^EXIT=10$
7+
^SIGNAL=0$
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
assert(p != NULL);
22+
assert(p->to_st2 != NULL);
23+
assert(p->to_st2->to_st1 != NULL);
24+
assert(p->to_st2->to_st1->to_st2 == NULL);
25+
26+
assert(p != &dummy1);
27+
assert(p->to_st2 != &dummy2);
28+
assert(p->to_st2->to_st1 != &dummy1);
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--function func --min-null-tree-depth 10 --max-nondet-tree-depth 3 --harness-type call-function
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
typedef struct st
5+
{
6+
int data;
7+
} st_t;
8+
9+
st_t dummy;
10+
11+
void func(st_t *p)
12+
{
13+
assert(p != NULL);
14+
assert(p != &dummy);
15+
assert(p->data >= 4854549);
16+
assert(p->data < 4854549);
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--function func --min-null-tree-depth 10 --harness-type call-function
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[func.assertion.1\] line [0-9]+ assertion p != .*((NULL)|0).*: SUCCESS
7+
\[func.assertion.2\] line [0-9]+ assertion p != &dummy: SUCCESS
8+
\[func.assertion.3\] line [0-9]+ assertion p->data >= 4854549: FAILURE
9+
\[func.assertion.4\] line [0-9]+ assertion p->data < 4854549: FAILURE
10+
--
11+
^warning: ignoring
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
assert(p != NULL);
16+
assert(p != &dummy);
17+
18+
assert(p->prev != NULL);
19+
assert(p->prev != &dummy);
20+
21+
assert(p->next != NULL);
22+
assert(p->next != &dummy);
23+
24+
assert(p->prev->prev == NULL);
25+
assert(p->prev->next == NULL);
26+
assert(p->next->prev == NULL);
27+
assert(p->next->next == NULL);
28+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--function func --min-null-tree-depth 10 --max-nondet-tree-depth 2 --harness-type call-function
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
assert(p != NULL);
15+
assert(p->next != NULL);
16+
assert(p->next->next != NULL);
17+
assert(p->next->next->next == NULL);
18+
19+
assert(p != &dummy);
20+
assert(p->next != &dummy);
21+
assert(p->next->next != &dummy);
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--function func --min-null-tree-depth 10 --max-nondet-tree-depth 3 --harness-type call-function
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
typedef struct A A;
5+
typedef struct B B;
6+
typedef struct C C;
7+
typedef struct D D;
8+
9+
struct A
10+
{
11+
B *b;
12+
};
13+
14+
struct B
15+
{
16+
C *c;
17+
};
18+
19+
struct C
20+
{
21+
D *d;
22+
};
23+
24+
struct D
25+
{
26+
A *a;
27+
};
28+
29+
void func(A *a)
30+
{
31+
assert(a != NULL);
32+
assert(a->b != NULL);
33+
assert(a->b->c != NULL);
34+
assert(a->b->c->d != NULL);
35+
assert(a->b->c->d->a == NULL);
36+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--function func --min-null-tree-depth 10 --max-nondet-tree-depth 1 --harness-type call-function
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring

src/goto-harness/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SRC = \
44
goto_harness_generator_factory.cpp \
55
goto_harness_main.cpp \
66
goto_harness_parse_options.cpp \
7+
recursive_initialization.cpp \
78
# Empty last line
89

910
OBJ += \

0 commit comments

Comments
 (0)