Skip to content

Commit 5bc32d7

Browse files
Add tests for shadow memory for memcpy
Check that source and destination buffers have independent shadow memory.
1 parent 63953a0 commit 5bc32d7

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <assert.h>
2+
#include <string.h>
3+
4+
int src[10];
5+
6+
int main()
7+
{
8+
__CPROVER_field_decl_local("field", (_Bool)0);
9+
__CPROVER_field_decl_global("field", (_Bool)0);
10+
11+
assert(src[9] == 0);
12+
assert(__CPROVER_get_field(&(src[9]), "field") == 0);
13+
14+
int dest[10];
15+
dest[9] = 1;
16+
assert(__CPROVER_get_field(&(dest[9]), "field") == 0);
17+
__CPROVER_set_field(&(dest[9]), "field", 1);
18+
assert(__CPROVER_get_field(&(dest[9]), "field") == 1);
19+
20+
memcpy(dest, src, 10 * sizeof(int));
21+
assert(dest[9] == 0);
22+
assert(__CPROVER_get_field(&(src[9]), "field") == 0);
23+
assert(__CPROVER_get_field(&(dest[9]), "field") == 1);
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FUTURE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)