Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
0ff8ec7c
Commit
0ff8ec7c
authored
9 years ago
by
Kostyantyn Vorobyov
Browse files
Options
Downloads
Patches
Plain Diff
[tests] Added test case for \block_length predicate
parent
7e18fff6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/e-acsl/tests/e-acsl-runtime/block_length.c
+62
-0
62 additions, 0 deletions
src/plugins/e-acsl/tests/e-acsl-runtime/block_length.c
with
62 additions
and
0 deletions
src/plugins/e-acsl/tests/e-acsl-runtime/block_length.c
0 → 100644
+
62
−
0
View file @
0ff8ec7c
/* run.config
COMMENT: Behaviours of the \block_length E-ACSL predicate
*/
#include
<stdlib.h>
int
A
[]
=
{
1
,
2
,
3
,
4
};
int
*
PA
;
struct
Zero
{
}
ZERO
;
int
main
(
void
)
{
/* Global memory */
PA
=
(
int
*
)
&
A
;
/*@ assert \block_length(A) == sizeof(A); */
/*@ assert \block_length(A+3) == sizeof(A); */
/*@ assert \block_length(PA) == sizeof(A); */
PA
++
;
/*@ assert \block_length(PA+1) == \block_length(A+1); */
/* Stack memory [long blocks] */
int
a
[]
=
{
1
,
2
,
3
,
4
};
int
*
pa
=
(
int
*
)
&
a
;
/*@ assert \block_length(a) == sizeof(a); */
/*@ assert \block_length(a+3) == sizeof(a); */
/*@ assert \block_length(pa) == sizeof(a); */
pa
++
;
/*@ assert \block_length(pa+1) == \block_length(a+1); */
/* Stack memory [Short blocks] */
long
l
=
4
;
char
*
pl
=
(
char
*
)
&
l
;
/*@ assert \block_length(&l) == sizeof(long); */
/*@ assert \block_length(pl) == sizeof(long); */
/*@ assert \block_length(pl+7) == sizeof(long); */
int
*
pi
=
(
int
*
)
&
l
;
/*@ assert \block_length(pi) == \block_length(&l); */
pi
++
;
/*@ assert \block_length(pi) == \block_length(&l); */
/* Heap memory [single segment] */
size_t
size
=
12
;
char
*
p
=
malloc
(
size
);
/*@ assert \block_length(p) == size; */
/*@ assert \block_length(p+11) == size; */
p
+=
5
;
/*@ assert \block_length(p+5) == \block_length(p-5); */
/* Heap memory [multiple segments] */
size
=
30
*
sizeof
(
long
);
long
*
q
=
malloc
(
size
);
/*@ assert \block_length(q) == size; */
q
+=
4
;
/*@ assert \block_length(q) == size; */
/* Zero-sized blocks */
struct
Zero
zero
;
/*@ assert \block_length(&ZERO) == 0; */
/*@ assert \block_length(&zero) == 0; */
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment