Skip to content

Commit 004fd96

Browse files
authored
Merge pull request #5324 from danpoe/tests/cprover-memory-primitives
Add tests to check semantics of pointer primitives
2 parents 90afd47 + 175d74f commit 004fd96

File tree

24 files changed

+296
-0
lines changed

24 files changed

+296
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void main()
5+
{
6+
char *p = malloc(1);
7+
free(p);
8+
9+
assert(__CPROVER_DYNAMIC_OBJECT(p));
10+
assert(!__CPROVER_DYNAMIC_OBJECT(p));
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FUTURE
2+
main.c
3+
--no-simplify --no-propagation
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line \d+ assertion __CPROVER_DYNAMIC_OBJECT\(p\): FAILURE
7+
\[main.assertion.2\] line \d+ assertion !__CPROVER_DYNAMIC_OBJECT\(p\): FAILURE
8+
--
9+
^warning: ignoring
10+
--
11+
Check that the dynamic object property is havoc'd when dynamic objects are
12+
deallocated. We use --no-simplify and --no-propagation to ensure that the case
13+
is not solved by the constant propagation and thus tests the constraint
14+
encoding. Recorded as ADA-526.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FUTURE
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line \d+ assertion __CPROVER_DYNAMIC_OBJECT\(p\): FAILURE
7+
\[main.assertion.2\] line \d+ assertion !__CPROVER_DYNAMIC_OBJECT\(p\): FAILURE
8+
--
9+
^warning: ignoring
10+
--
11+
Check that the dynamic object property is havoc'd when dynamic objects are
12+
deallocated. Recorded as ADA-526.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void main()
5+
{
6+
char *p;
7+
8+
assert(__CPROVER_DYNAMIC_OBJECT(p));
9+
assert(!__CPROVER_DYNAMIC_OBJECT(p));
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FUTURE
2+
main.c
3+
--no-simplify --no-propagation
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line \d+ assertion __CPROVER_DYNAMIC_OBJECT\(p\): FAILURE
7+
\[main.assertion.2\] line \d+ assertion !__CPROVER_DYNAMIC_OBJECT\(p\): FAILURE
8+
--
9+
^warning: ignoring
10+
--
11+
Check that the dynamic object property is nondet for uninitialized pointers. We
12+
use --no-simplify and --no-propagation to ensure that the case is not solved by
13+
the constant propagation and thus tests the constraint encoding. Recorded as
14+
ADA-526.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FUTURE
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line \d+ assertion __CPROVER_DYNAMIC_OBJECT\(p\): FAILURE
7+
\[main.assertion.2\] line \d+ assertion !__CPROVER_DYNAMIC_OBJECT\(p\): FAILURE
8+
--
9+
^warning: ignoring
10+
--
11+
Check that the dynamic object property is nondet for uninitialized pointers.
12+
Recorded as ADA-526.
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+
void main()
5+
{
6+
char *p = malloc(1);
7+
free(p);
8+
9+
assert(__CPROVER_OBJECT_SIZE(p) == 1);
10+
assert(__CPROVER_OBJECT_SIZE(p) != 1);
11+
12+
{
13+
char c;
14+
p = &c;
15+
}
16+
17+
assert(__CPROVER_OBJECT_SIZE(p) == 1);
18+
assert(__CPROVER_OBJECT_SIZE(p) != 1);
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FUTURE
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line \d+ assertion __CPROVER_OBJECT_SIZE\(p\) == 1: FAILURE
7+
\[main.assertion.2\] line \d+ assertion __CPROVER_OBJECT_SIZE\(p\) != 1: FAILURE
8+
\[main.assertion.3\] line \d+ assertion __CPROVER_OBJECT_SIZE\(p\) == 1: FAILURE
9+
\[main.assertion.4\] line \d+ assertion __CPROVER_OBJECT_SIZE\(p\) != 1: FAILURE
10+
--
11+
^warning: ignoring
12+
--
13+
Check that object size is havoc'd when objects are deallocated. We use
14+
--no-simplify and --no-propagation to ensure that the case is not solved by the
15+
constant propagation and thus tests the constraint encoding. Recorded as
16+
ADA-527.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FUTURE
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line \d+ assertion __CPROVER_OBJECT_SIZE\(p\) == 1: FAILURE
7+
\[main.assertion.2\] line \d+ assertion __CPROVER_OBJECT_SIZE\(p\) != 1: FAILURE
8+
\[main.assertion.3\] line \d+ assertion __CPROVER_OBJECT_SIZE\(p\) == 1: FAILURE
9+
\[main.assertion.4\] line \d+ assertion __CPROVER_OBJECT_SIZE\(p\) != 1: FAILURE
10+
--
11+
^warning: ignoring
12+
--
13+
Check that object size is havoc'd when objects are deallocated. Recorded as
14+
ADA-527.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <assert.h>
2+
3+
void main()
4+
{
5+
char *p;
6+
assert(__CPROVER_POINTER_OFFSET(p) >= 0);
7+
assert(__CPROVER_POINTER_OFFSET(p) < 0);
8+
}

0 commit comments

Comments
 (0)