Skip to content

Commit 15cf198

Browse files
author
thk123
committed
Updated array test to test exactly what we want
1 parent 423ae3c commit 15cf198

File tree

2 files changed

+15
-52
lines changed
  • regression/goto-analyzer/variable-sensitivity-assign-aware-merge-array

2 files changed

+15
-52
lines changed
Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,27 @@
1-
int a[10];
2-
3-
int c[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
4-
5-
void param_test(int array[])
6-
{
7-
array[1] = 5;
8-
// TODO: This is marked as "unknown" when running analysis of param_test and global_test. Doesn't seem correct
9-
// as array[1] is being assigned one line above?
10-
__CPROVER_assert(array[1]==5, "array[1]==5");
11-
}
12-
131
void param_test_val(int array[], int x)
142
{
153
array[1] = x;
16-
// TODO: This is marked as "unknown" when running analysis of param_test and global_test. Doesn't seem correct
17-
// as array[1] is being assigned one line above?
18-
//__CPROVER_assert(array[1]==5, "array[1]==5");
19-
}
20-
21-
void global_test()
22-
{
23-
a[2] = 6;
24-
__CPROVER_assert(a[2]==6, "a[2]==6");
25-
c[8] = 15;
26-
__CPROVER_assert(c[8]==15, "c[8]==15");
27-
// TODO: This is marked as "unknown" when running analysis of global_test. CORRECT?
28-
__CPROVER_assert(c[9]==9, "c[9]==9");
294
}
305

316
void pass_param()
327
{
338
int b[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
34-
35-
__CPROVER_assert(b[0]==0, "b[0]==0");
36-
__CPROVER_assert(b[4]==4, "b[4]==4");
37-
__CPROVER_assert(b[8]==8, "b[8]==8");
38-
// TODO: This is marked as "unknown" when running analysis of pass_param. CORRECT?
39-
// The theme here is that global array initialisation assertions are marked as "unknown". Why?
40-
__CPROVER_assert(c[8]==8, "c[8]==8");
41-
42-
param_test_val(b, 5);
439

44-
__CPROVER_assert(b[1]==5, "b[1]==5");
10+
param_test_val(b, 5);
4511

12+
// This assertion should be true since b[0] is unmodified
4613
__CPROVER_assert(b[0]==0, "b[0]==0");
47-
__CPROVER_assert(b[4]==4, "b[4]==4");
48-
__CPROVER_assert(b[8]==8, "b[8]==8");
4914

50-
__CPROVER_assert(b[1]==1, "b[1]==1");
15+
// This assertion should be true since b[1] can only have one value
16+
__CPROVER_assert(b[1]==5, "b[1]==5");
17+
5118
param_test_val(b, 6);
19+
20+
// Both these assertions shoul be unknown since the domain for
21+
// param_test_val, x is TOP so we don't know what is written
5222
__CPROVER_assert(b[1]==5, "b[1]==5");
5323
__CPROVER_assert(b[1]==6, "b[1]==6");
24+
25+
// b[0] is still not modified so this assertion should still be true
5426
__CPROVER_assert(b[0]==0, "b[0]==0");
55-
__CPROVER_assert(b[8]==8, "b[8]==8");
5627
}

regression/goto-analyzer/variable-sensitivity-assign-aware-merge-array/test.desc

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,9 @@ main.c
33
--function pass_param --variable --pointers --arrays --structs --verify
44
^EXIT=0$
55
^SIGNAL=0$
6-
^\[pass_param.assertion.1\] file main.c line 35 function pass_param, b\[0\]==0: Success$
7-
^\[pass_param.assertion.2\] file main.c line 36 function pass_param, b\[4\]==4: Success$
8-
^\[pass_param.assertion.3\] file main.c line 37 function pass_param, b\[8\]==8: Success$
9-
^\[pass_param.assertion.4\] file main.c line 40 function pass_param, c\[8\]==8: Unknown$
10-
^\[pass_param.assertion.5\] file main.c line 44 function pass_param, b\[1\]==5: Success$
11-
^\[pass_param.assertion.6\] file main.c line 46 function pass_param, b\[0\]==0: Success$
12-
^\[pass_param.assertion.7\] file main.c line 47 function pass_param, b\[4\]==4: Success$
13-
^\[pass_param.assertion.8\] file main.c line 48 function pass_param, b\[8\]==8: Success$
14-
^\[pass_param.assertion.9\] file main.c line 50 function pass_param, b\[1\]==1: Failure \(if reachable\)$
15-
^\[pass_param.assertion.10\] file main.c line 52 function pass_param, b\[1\]==5: Unknown$
16-
^\[pass_param.assertion.11\] file main.c line 53 function pass_param, b\[1\]==6: Unknown$
17-
^\[pass_param.assertion.12\] file main.c line 54 function pass_param, b\[0\]==0: Success$
18-
^\[pass_param.assertion.13\] file main.c line 55 function pass_param, b\[8\]==8: Success$
6+
\[pass_param\.assertion\.1\] .* b\[0\]==0: Success
7+
\[pass_param\.assertion\.2\] .* b\[1\]==5: Success
8+
\[pass_param\.assertion\.3\] .* b\[1\]==5: Unknown
9+
\[pass_param\.assertion\.4\] .* b\[1\]==6: Unknown
10+
\[pass_param\.assertion\.5\] .* b\[0\]==0: Success
1911
--

0 commit comments

Comments
 (0)