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
081d779c
Commit
081d779c
authored
3 years ago
by
Andre Maroneze
Browse files
Options
Downloads
Patches
Plain Diff
[tests] refactor compliance checks for Frama-C libc
parent
cb063bdd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/libc/check_compliance.ml
+45
-45
45 additions, 45 deletions
tests/libc/check_compliance.ml
with
45 additions
and
45 deletions
tests/libc/check_compliance.ml
+
45
−
45
View file @
081d779c
...
@@ -81,6 +81,49 @@ struct
...
@@ -81,6 +81,49 @@ struct
table
table
end
end
let
ident_to_be_ignored
id
headers
=
Extlib
.
string_prefix
"__"
id
||
Extlib
.
string_prefix
"Frama_C"
id
||
List
.
filter
(
fun
h
->
not
(
Extlib
.
string_prefix
"__fc"
h
))
headers
=
[]
let
check_ident
c11
posix
glibc
nonstandard
c11_headers
id
headers
=
if
ident_to_be_ignored
id
headers
then
(* nothing to check *)
()
else
begin
if
Hashtbl
.
mem
c11
id
then
begin
(* Check that the header is the expected one.
Note that some symbols may appear in more than one header,
possibly due to collisions
e.g. 'flock' as type and function). *)
let
h
=
Hashtbl
.
find
c11
id
in
if
not
(
StringSet
.
mem
h
c11_headers
)
then
Kernel
.
warning
"<%a>:%s : C11 says %s"
(
Pretty_utils
.
pp_list
~
sep
:
","
Format
.
pp_print_string
)
headers
id
h
end
else
if
Hashtbl
.
mem
posix
id
then
begin
(* check that the header is the expected one *)
let
(
h
,
_
)
=
Hashtbl
.
find
posix
id
in
(* arpa/inet.h and netinet/in.h are special cases: due to mutual
inclusion, there are always issues with their symbols;
also, timezone is a special case, since it is a type in
sys/time.h, but a variable in time.h in POSIX. However, its
declaration as extern is erased by rmtmps, since it is
unused. *)
if
not
(
List
.
mem
h
headers
)
&&
not
(
List
.
mem
"arpa/inet.h"
headers
&&
h
=
"netinet/in.h"
||
List
.
mem
"netinet/in.h"
headers
&&
h
=
"arpa/inet.h"
)
&&
id
<>
"timezone"
then
Kernel
.
warning
"<%a>:%s : POSIX says %s"
(
Pretty_utils
.
pp_list
~
sep
:
","
Format
.
pp_print_string
)
headers
id
h
end
else
if
not
(
StringSet
.(
mem
id
glibc
||
mem
id
nonstandard
))
then
Kernel
.
warning
"<%a>:%s : unknown identifier"
(
Pretty_utils
.
pp_list
~
sep
:
","
Format
.
pp_print_string
)
headers
id
end
let
()
=
let
()
=
Db
.
Main
.
extend
(
fun
()
->
Db
.
Main
.
extend
(
fun
()
->
if
not
!
run_once
then
begin
if
not
!
run_once
then
begin
...
@@ -94,49 +137,6 @@ let () =
...
@@ -94,49 +137,6 @@ let () =
and
glibc_idents
=
Json
.(
to_set
(
parse
dir
"glibc_functions.json"
))
and
glibc_idents
=
Json
.(
to_set
(
parse
dir
"glibc_functions.json"
))
and
posix_idents
=
Json
.(
to_table
HeadersAndExtensions
(
parse
dir
"posix_identifiers.json"
))
and
posix_idents
=
Json
.(
to_table
HeadersAndExtensions
(
parse
dir
"posix_identifiers.json"
))
and
nonstandard_idents
=
Json
.(
keys
(
parse
dir
"nonstandard_identifiers.json"
))
in
and
nonstandard_idents
=
Json
.(
keys
(
parse
dir
"nonstandard_identifiers.json"
))
in
Hashtbl
.
iter
(
fun
id
headers
->
let
check_ident_fun
=
check_ident
c11_idents
posix_idents
glibc_idents
nonstandard_idents
c11_headers
in
if
not
(
Extlib
.
string_prefix
"__"
id
)
&&
Hashtbl
.
iter
check_ident_fun
fc_stdlib_idents
not
(
Extlib
.
string_prefix
"Frama_C"
id
)
&&
List
.
filter
(
fun
h
->
not
(
Extlib
.
string_prefix
"__fc"
h
))
headers
<>
[]
then
let
id_in_c11
=
Hashtbl
.
mem
c11_idents
id
in
let
id_in_posix
=
Hashtbl
.
mem
posix_idents
id
in
let
id_in_glibc
=
StringSet
.
mem
id
glibc_idents
in
let
id_in_nonstd
=
StringSet
.
mem
id
nonstandard_idents
in
let
header_in_c11
h
=
StringSet
.
mem
h
c11_headers
in
if
id_in_c11
then
begin
(* Check that the header is the expected one.
Note that some symbols may appear in more than one header,
possibly due to collisions
(e.g. 'flock' as type and function). *)
let
h
=
Hashtbl
.
find
c11_idents
id
in
if
not
(
header_in_c11
h
)
then
Kernel
.
warning
"<%a>:%s : C11 says %s"
(
Pretty_utils
.
pp_list
~
sep
:
","
Format
.
pp_print_string
)
headers
id
h
end
else
if
id_in_posix
then
begin
(* check the header is the expected one *)
let
(
h
,
_
)
=
Hashtbl
.
find
posix_idents
id
in
(* arpa/inet.h and netinet/in.h are special cases: due to mutual
inclusion, there are always issues with their symbols;
also, timezone is a special case, since it is a type in
sys/time.h, but a variable in time.h in POSIX. However, its
declaration as extern is erased by rmtmps, since it is
unused. *)
if
not
(
List
.
mem
h
headers
)
&&
not
(
List
.
mem
"arpa/inet.h"
headers
&&
h
=
"netinet/in.h"
||
List
.
mem
"netinet/in.h"
headers
&&
h
=
"arpa/inet.h"
)
&&
id
<>
"timezone"
then
Kernel
.
warning
"<%a>:%s : POSIX says %s"
(
Pretty_utils
.
pp_list
~
sep
:
","
Format
.
pp_print_string
)
headers
id
h
end
else
if
not
(
id_in_glibc
||
id_in_nonstd
)
then
Kernel
.
warning
"<%a>:%s : unknown identifier"
(
Pretty_utils
.
pp_list
~
sep
:
","
Format
.
pp_print_string
)
headers
id
)
fc_stdlib_idents
;
end
)
end
)
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