Skip to content

Commit cc46483

Browse files
committed
Add regression tests for --nondet-volatile-model
1 parent d08257e commit cc46483

File tree

6 files changed

+104
-0
lines changed

6 files changed

+104
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <assert.h>
2+
3+
volatile int a;
4+
volatile int b;
5+
6+
int model()
7+
{
8+
int value;
9+
__CPROVER_assume(value >= 0);
10+
return value;
11+
}
12+
13+
void main()
14+
{
15+
assert(a == 0);
16+
17+
assert(b >= 0);
18+
assert(b == 0);
19+
assert(b != 0);
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.c
3+
--nondet-volatile-model b:model
4+
\[main.assertion.1\] line \d+ assertion a == 0: SUCCESS
5+
\[main.assertion.2\] line \d+ assertion b >= 0: SUCCESS
6+
\[main.assertion.3\] line \d+ assertion b == 0: FAILURE
7+
\[main.assertion.4\] line \d+ assertion b != 0: FAILURE
8+
^EXIT=10$
9+
^SIGNAL=0$
10+
--
11+
--
12+
Checks that the read from b is modelled via the given model
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <assert.h>
2+
3+
volatile int a;
4+
volatile int b;
5+
volatile int c;
6+
7+
int model()
8+
{
9+
int value;
10+
__CPROVER_assume(value >= 0);
11+
return value;
12+
}
13+
14+
void main()
15+
{
16+
assert(a == 0);
17+
18+
assert(b >= 0);
19+
assert(b == 0);
20+
assert(b != 0);
21+
22+
assert(c >= 0);
23+
assert(c == 0);
24+
assert(c != 0);
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
test.c
3+
--nondet-volatile-variable b --nondet-volatile-model c:model
4+
\[main.assertion.1\] line \d+ assertion a == 0: SUCCESS
5+
\[main.assertion.2\] line \d+ assertion b >= 0: FAILURE
6+
\[main.assertion.3\] line \d+ assertion b == 0: FAILURE
7+
\[main.assertion.4\] line \d+ assertion b != 0: FAILURE
8+
\[main.assertion.5\] line \d+ assertion c >= 0: SUCCESS
9+
\[main.assertion.6\] line \d+ assertion c == 0: FAILURE
10+
\[main.assertion.7\] line \d+ assertion c != 0: FAILURE
11+
^EXIT=10$
12+
^SIGNAL=0$
13+
--
14+
--
15+
Checks that both options for selectively havocking/modelling volatile reads can
16+
be used together
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <assert.h>
2+
3+
volatile int a;
4+
volatile int b;
5+
6+
int model_a()
7+
{
8+
return 1;
9+
}
10+
11+
int model_b()
12+
{
13+
return 2;
14+
}
15+
16+
void main()
17+
{
18+
int result = a + b;
19+
assert(result == 3);
20+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
test.c
3+
--nondet-volatile-model a:model_a --nondet-volatile-model b:model_b
4+
\[main.assertion.1\] line \d+ assertion result == 3: SUCCESS
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
VERIFICATION SUCCESSFUL
8+
--
9+
--
10+
Checks that two volatile reads in the same expression can both be modelled by
11+
given functions

0 commit comments

Comments
 (0)