Skip to content

Commit 70882b7

Browse files
Add workaround for alpine regression test failure
CBMC doesn't handle assert on alpine-linux correctly. This works around this issue by using __CPROVER_assert directly in the tests that were previously failing. This appears to be fixed already on the develop branch
1 parent 3bdabf2 commit 70882b7

File tree

6 files changed

+31
-25
lines changed
  • regression/goto-analyzer
    • sensitivity-function-call-array
    • sensitivity-function-call-opaque
    • sensitivity-function-call-pointer
    • sensitivity-function-call-primitive
    • sensitivity-function-call-recursive
    • sensitivity-function-call-varargs

6 files changed

+31
-25
lines changed

regression/goto-analyzer/sensitivity-function-call-array/main.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <assert.h>
2+
#define ASSERT(x) __CPROVER_assert((x), "assertion " #x)
23

34
int *bar(int *arr_unmodified, int *arr_modified);
45

@@ -9,23 +10,23 @@ int main(int argc, char *argv[])
910
int *p2arr = arr_x;
1011

1112
p2arr = bar(arr_x, arr_y);
12-
assert(*arr_y==2);
13-
// assert(arr_y[1]==3);
13+
ASSERT(*arr_y==2);
14+
// ASSERT(arr_y[1]==3);
1415

15-
assert(p2arr==arr_y);
16-
assert(*p2arr==2);
17-
// assert(p2arr[1]==3);
16+
ASSERT(p2arr==arr_y);
17+
ASSERT(*p2arr==2);
18+
// ASSERT(p2arr[1]==3);
1819
}
1920

2021
int *bar(int *arr_unmodified, int *arr_modified)
2122
{
22-
assert(*arr_unmodified==1);
23-
// assert(arr_unmodified[1]==2);
23+
ASSERT(*arr_unmodified==1);
24+
// ASSERT(arr_unmodified[1]==2);
2425

2526
(*arr_modified) += 1;
2627
// arr_modified[1] = 3;
2728

28-
assert(*arr_modified==2);
29+
ASSERT(*arr_modified==2);
2930
// assert(arr_modified[1]==3);
3031

3132
return arr_modified;

regression/goto-analyzer/sensitivity-function-call-opaque/main.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <assert.h>
2+
#define ASSERT(x) __CPROVER_assert((x), "assertion " #x)
23

34
int global_value;
45

@@ -13,10 +14,10 @@ int main(int argc, char *argv[])
1314

1415
int z=bar(x+1, &y);
1516

16-
assert(x==3); // Success
17-
assert(y==4); // Unknown - the opaque function could have modified it
18-
assert(z==0); // Unknown - the opaque function could have returned anything
19-
assert(global_value==4); // Unknown - the opaque function could have modified this
17+
ASSERT(x==3); // Success
18+
ASSERT(y==4); // Unknown - the opaque function could have modified it
19+
ASSERT(z==0); // Unknown - the opaque function could have returned anything
20+
ASSERT(global_value==4); // Unknown - the opaque function could have modified this
2021

2122
return 0;
2223
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <assert.h>
2+
#define ASSERT(x) __CPROVER_assert((x), "assertion " #x)
23

34
int *bar(int *unmodified, int *modifed);
45

@@ -8,18 +9,18 @@ int main(int argc, char *argv[])
89
int y=4;
910
int *p2x=&x;
1011
p2x = bar(&x, &y);
11-
assert(y==5);
12-
assert(p2x==&y);
13-
assert(*p2x==5);
12+
ASSERT(y==5);
13+
ASSERT(p2x==&y);
14+
ASSERT(*p2x==5);
1415
}
1516

1617
int *bar(int *unmodified, int *modifed)
1718
{
18-
assert(*unmodified==3);
19+
ASSERT(*unmodified==3);
1920

2021
(*modifed) += 1;
2122

22-
assert(*modifed==5);
23+
ASSERT(*modifed==5);
2324

2425
return modifed;
2526
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#include <assert.h>
2+
#define ASSERT(x) __CPROVER_assert((x), "assertion " #x)
23

34
int bar(int other)
45
{
5-
assert(other==4);
6+
ASSERT(other==4);
67
return other + 1;
78
}
89

910
int main(int argc, char *argv[])
1011
{
1112
int x=3;
1213
int y=bar(x+1);
13-
assert(y==5);
14+
ASSERT(y==5);
1415
}

regression/goto-analyzer/sensitivity-function-call-recursive/main.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <assert.h>
2+
#define ASSERT(x) __CPROVER_assert((x), "assertion " #x)
23

34
int bar(int other)
45
{
@@ -43,14 +44,14 @@ int main(int argc, char *argv[])
4344
{
4445
int x=3;
4546
int y=bar(x+1);
46-
assert(y==4); // Unknown in the constants domain
47+
ASSERT(y==4); // Unknown in the constants domain
4748

4849
int y2 = bar(0);
49-
assert(y2==0); // Unknown since we are not sensitive to call domain
50+
ASSERT(y2==0); // Unknown since we are not sensitive to call domain
5051

5152
int z = bar_clean(0);
52-
assert(z==0); // Unknown as the function has parameter as top
53+
ASSERT(z==0); // Unknown as the function has parameter as top
5354

5455
int w = fun(5, 18);
55-
assert(w==18);
56+
ASSERT(w==18);
5657
}

regression/goto-analyzer/sensitivity-function-call-varargs/main.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <assert.h>
22
#include <stdarg.h>
3+
#define ASSERT(x) __CPROVER_assert((x), "assertion " #x)
34

45
int bar(int size, ...)
56
{
@@ -19,8 +20,8 @@ int bar(int size, ...)
1920
int main(int argc, char *argv[])
2021
{
2122
int y=bar(4, 1, 2, 2, 1);
22-
assert(y==6);
23+
ASSERT(y==6);
2324

2425
int z=bar(0);
25-
assert(z==0);
26+
ASSERT(z==0);
2627
}

0 commit comments

Comments
 (0)