Skip to content

Commit b01d521

Browse files
committed
Regression tests for user-control havoc
Char-arrays don't work for now. Structs and non-char pointers do.
1 parent 9bfb0dd commit b01d521

File tree

10 files changed

+237
-0
lines changed

10 files changed

+237
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
typedef struct st1
5+
{
6+
struct st2 *to_st2;
7+
int data;
8+
} st1_t;
9+
10+
typedef struct st2
11+
{
12+
struct st1 *to_st1;
13+
int data;
14+
} st2_t;
15+
16+
typedef struct st3
17+
{
18+
st1_t *array[3];
19+
} st3_t;
20+
21+
st1_t dummy1;
22+
st2_t dummy2;
23+
24+
st3_t *p;
25+
26+
void initialize()
27+
{
28+
p = malloc(sizeof(st3_t));
29+
}
30+
31+
void checkpoint()
32+
{
33+
}
34+
35+
int main()
36+
{
37+
initialize();
38+
checkpoint();
39+
40+
assert(p != NULL);
41+
for(int index = 0; index < 3; index++)
42+
{
43+
assert(p->array[index]->to_st2 != NULL);
44+
assert(p->array[index]->to_st2->to_st1 != NULL);
45+
assert(p->array[index]->to_st2->to_st1->to_st2 == NULL);
46+
}
47+
48+
assert(p->array[0] != p->array[1]);
49+
assert(p->array[1] != p->array[2]);
50+
assert(p->array[0] != p->array[2]);
51+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
p --harness-type initialise-with-memory-snapshot --initial-location main:4 --min-null-tree-depth 10 --max-nondet-tree-depth 4 --havoc-variables p
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
typedef struct st1
5+
{
6+
struct st2 *to_st2;
7+
int data;
8+
} st1_t;
9+
10+
typedef struct st2
11+
{
12+
struct st1 *to_st1;
13+
int data;
14+
} st2_t;
15+
16+
st1_t dummy1;
17+
st2_t dummy2;
18+
19+
st1_t *p;
20+
21+
void initialize()
22+
{
23+
}
24+
25+
void checkpoint()
26+
{
27+
}
28+
29+
int main()
30+
{
31+
initialize();
32+
checkpoint();
33+
34+
assert(p != NULL);
35+
assert(p->to_st2 != NULL);
36+
assert(p->to_st2->to_st1 != NULL);
37+
assert(p->to_st2->to_st1->to_st2 == NULL);
38+
39+
assert(p != &dummy1);
40+
assert(p->to_st2 != &dummy2);
41+
assert(p->to_st2->to_st1 != &dummy1);
42+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
p --harness-type initialise-with-memory-snapshot --initial-location main:4 --havoc-variables p --min-null-tree-depth 10 --max-nondet-tree-depth 3
4+
^SIGNAL=0$
5+
^EXIT=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
unwinding assertion loop \d+: FAILURE
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <assert.h>
2+
#include <malloc.h>
3+
4+
char *first;
5+
char *second;
6+
int array_size;
7+
8+
void initialize()
9+
{
10+
first = malloc(sizeof(char)*12);
11+
first="1234567890a";
12+
second = first;
13+
array_size = 11;
14+
}
15+
16+
void checkpoint()
17+
{
18+
}
19+
20+
int main()
21+
{
22+
initialize();
23+
checkpoint();
24+
25+
assert(first == second);
26+
assert(second[array_size-1]=='a');
27+
// assert(second[10]=='0');
28+
return 0;
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
KNOWNBUG
2+
main.c
3+
first,second,array_size --harness-type initialise-with-memory-snapshot --initial-location main:4
4+
^SIGNAL=0$
5+
^EXIT=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
unwinding assertion loop \d+: FAILURE
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <assert.h>
2+
3+
char *first = "12345678901";
4+
char *second;
5+
int string_size;
6+
const char *prefix;
7+
int prefix_size;
8+
9+
void initialize()
10+
{
11+
second = first;
12+
string_size = 11;
13+
}
14+
15+
void checkpoint()
16+
{
17+
}
18+
19+
int main()
20+
{
21+
initialize();
22+
checkpoint();
23+
24+
assert(first == second);
25+
if(prefix_size > 0)
26+
assert(second[prefix_size - 1] != 'a');
27+
28+
if(string_size < prefix_size)
29+
{
30+
return 0;
31+
}
32+
33+
for(int ix = 0; ix < prefix_size; ++ix)
34+
{
35+
if(second[ix] != prefix[ix])
36+
{
37+
return 0;
38+
}
39+
}
40+
return 1;
41+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
KNOWNBUG
2+
main.c
3+
first,second,string_size,prefix,prefix_size --harness-type initialise-with-memory-snapshot --initial-location main:4 --havoc-variables prefix,prefix_size --size-of-array prefix:prefix_size --max-array-size 5
4+
^SIGNAL=0$
5+
^EXIT=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
unwinding assertion loop \d+: FAILURE
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <assert.h>
2+
3+
int temp[] = {1, 2, 3, 4, 5};
4+
int *first;
5+
int *second;
6+
int array_size;
7+
const int *prefix;
8+
int prefix_size;
9+
10+
void initialize()
11+
{
12+
first = temp;
13+
second = first;
14+
array_size = 5;
15+
}
16+
17+
void checkpoint()
18+
{
19+
}
20+
21+
int main()
22+
{
23+
initialize();
24+
checkpoint();
25+
26+
assert(first == second);
27+
assert(array_size >= prefix_size);
28+
assert(prefix_size>=0);
29+
assert(second[prefix_size] != 6);
30+
31+
for(int i = 0; i < prefix_size; i++)
32+
assert(second[i] != prefix[i]);
33+
return 0;
34+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
temp,first,second,array_size,prefix,prefix_size --harness-type initialise-with-memory-snapshot --initial-location main:4 --havoc-variables prefix --size-of-array prefix:prefix_size --max-array-size 4
4+
^SIGNAL=0$
5+
^EXIT=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
unwinding assertion loop \d+: FAILURE

0 commit comments

Comments
 (0)