Skip to content

Non-deterministic initialisation of structs, pointers and globals in function call harness #4181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
int a_global;

void entry_function(void)
{
assert(a_global == 0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
main.c
--harness-type call-function --function entry_function
^\[entry_function.assertion.1\] line \d+ assertion a_global == 0: SUCCESS$
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
6 changes: 6 additions & 0 deletions regression/goto-harness/non_det_globals_option/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
int a_global;

void entry_function(void)
{
assert(a_global == 0);
}
7 changes: 7 additions & 0 deletions regression/goto-harness/non_det_globals_option/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
main.c
--harness-type call-function --function entry_function --nondet-globals
^\[entry_function.assertion.1\] line \d+ assertion a_global == 0: FAILURE$
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <assert.h>
#include <stdlib.h>

typedef struct st1
{
struct st2 *to_st2;
int data;
} st1_t;

typedef struct st2
{
struct st1 *to_st1;
int data;
} st2_t;

st1_t dummy1;
st2_t dummy2;

void func(st1_t *p)
{
assert(p != NULL);
assert(p->to_st2 != NULL);
assert(p->to_st2->to_st1 != NULL);
assert(p->to_st2->to_st1->to_st2 == NULL);

assert(p != &dummy1);
assert(p->to_st2 != &dummy2);
assert(p->to_st2->to_st1 != &dummy1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--function func --min-null-tree-depth 10 --max-nondet-tree-depth 3 --harness-type call-function
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <assert.h>
#include <stdlib.h>

typedef struct st
{
int data;
} st_t;

st_t dummy;

void func(st_t *p)
{
assert(p != NULL);
assert(p != &dummy);
assert(p->data >= 4854549);
assert(p->data < 4854549);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--function func --min-null-tree-depth 10 --harness-type call-function
^EXIT=10$
^SIGNAL=0$
\[func.assertion.1\] line [0-9]+ assertion p != .*((NULL)|0).*: SUCCESS
\[func.assertion.2\] line [0-9]+ assertion p != &dummy: SUCCESS
\[func.assertion.3\] line [0-9]+ assertion p->data >= 4854549: FAILURE
\[func.assertion.4\] line [0-9]+ assertion p->data < 4854549: FAILURE
--
^warning: ignoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <assert.h>
#include <stdlib.h>

typedef struct st
{
struct st *next;
struct st *prev;
int data;
} st_t;

st_t dummy;

void func(st_t *p)
{
assert(p != NULL);
assert(p != &dummy);

assert(p->prev != NULL);
assert(p->prev != &dummy);

assert(p->next != NULL);
assert(p->next != &dummy);

assert(p->prev->prev == NULL);
assert(p->prev->next == NULL);
assert(p->next->prev == NULL);
assert(p->next->next == NULL);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--function func --min-null-tree-depth 10 --max-nondet-tree-depth 2 --harness-type call-function
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <assert.h>
#include <stdlib.h>

typedef struct st
{
struct st *next;
int data;
} st_t;

st_t dummy;

void func(st_t *p)
{
assert(p != NULL);
assert(p->next != NULL);
assert(p->next->next != NULL);
assert(p->next->next->next == NULL);

assert(p != &dummy);
assert(p->next != &dummy);
assert(p->next->next != &dummy);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--function func --min-null-tree-depth 10 --max-nondet-tree-depth 3 --harness-type call-function
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <assert.h>
#include <stdlib.h>

typedef struct A A;
typedef struct B B;
typedef struct C C;
typedef struct D D;

struct A
{
B *b;
};

struct B
{
C *c;
};

struct C
{
D *d;
};

struct D
{
A *a;
};

void func(A *a)
{
assert(a != NULL);
assert(a->b != NULL);
assert(a->b->c != NULL);
assert(a->b->c->d != NULL);
assert(a->b->c->d->a == NULL);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--function func --min-null-tree-depth 10 --max-nondet-tree-depth 1 --harness-type call-function
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
1 change: 1 addition & 0 deletions src/goto-harness/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SRC = \
goto_harness_generator_factory.cpp \
goto_harness_main.cpp \
goto_harness_parse_options.cpp \
recursive_initialization.cpp \
# Empty last line

OBJ += \
Expand Down
Loading