Skip to content

Commit 3ebd7f0

Browse files
martinmartin-cs
authored andcommitted
Add a test for the value set analysis in goto-instrument
Previously there were no direct checks for this functionality, only for users such as the memory model functionality.
1 parent 5abebd6 commit 3ebd7f0

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <stdlib.h>
2+
3+
#define BIG 4096
4+
5+
int main()
6+
{
7+
// Uninitialized pointer
8+
int *u;
9+
10+
// Basic assignment
11+
u = NULL;
12+
int a;
13+
u = &a;
14+
15+
// Test merging and the loss of correlation
16+
int *p;
17+
int *q;
18+
int b;
19+
int c;
20+
int nondet;
21+
if(nondet)
22+
{
23+
p = &b;
24+
q = &c;
25+
}
26+
else
27+
{
28+
p = &c;
29+
q = &b;
30+
}
31+
32+
// Test widening
33+
int array[BIG];
34+
int *s = &(array[0]);
35+
for(int i = 0; i < BIG; ++i)
36+
{
37+
s = &array[i];
38+
}
39+
40+
return 0;
41+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CORE
2+
main.c
3+
--show-value-sets
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
main::1::u = \{ <main::1::u\$object, 0, signedbv\[32\]> \}
7+
main::1::u = \{ <NULL-object, 0, signedbv\[32\]> \}
8+
main::1::u = \{ <main::1::a, 0, signedbv\[32\]> \}
9+
main::1::p = \{ <main::1::b, 0, signedbv\[32\]> \}
10+
main::1::p = \{ <main::1::c, 0, signedbv\[32\]> \}
11+
main::1::q = \{ <main::1::b, 0, signedbv\[32\]>, <main::1::c, 0, signedbv\[32\]> \}
12+
main::1::p = \{ <main::1::b, 0, signedbv\[32\]>, <main::1::c, 0, signedbv\[32\]> \}
13+
main::1::s = \{ <main::1::array\[0\], \*, signedbv\[32\]> \}
14+
--
15+
--
16+
A few basic tests to check if value sets are being handled correctly.
17+
18+
It would be reasonable to ask about the checks for:
19+
20+
main::1::q = \{ <main::1::b, 0, signedbv\[32\]> \}
21+
main::1::q = \{ <main::1::c, 0, signedbv\[32\]> \}
22+
23+
but as domains are stored at the start of instructions the following merge will
24+
over-write it on one branch or the other. To keep the test portable it is best
25+
avoided.
26+
27+

0 commit comments

Comments
 (0)