Test strerror_r on Android and Linux

This commit is contained in:
gnzlbg 2019-05-23 11:28:15 +02:00
parent 46c60fb726
commit d52732581a
12 changed files with 63 additions and 6 deletions

View File

@ -1337,6 +1337,9 @@ fn test_android(target: &str) {
t if t.ends_with("_t") => t.to_string(),
// sigval is a struct in Rust, but a union in C:
"sigval" => format!("union sigval"),
// put `struct` in front of all structs:.
t if is_struct => format!("struct {}", t),
@ -1400,6 +1403,23 @@ fn test_android(target: &str) {
"execvpe" |
"fexecve" => true,
// There are two versions of the sterror_r function, see
//
// https://linux.die.net/man/3/strerror_r
//
// An XSI-compliant version provided if:
//
// (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
//
// and a GNU specific version provided if _GNU_SOURCE is defined.
//
// libc provides bindings for the XSI-compliant version, which is
// preferred for portable applications.
//
// We skip the test here since here _GNU_SOURCE is defined, and
// test the XSI version below.
"strerror_r" => true,
// not declared in newer android toolchains
// FIXME: still necessary?
"getdtablesize" => true,
@ -1459,6 +1479,8 @@ fn test_android(target: &str) {
// On Android also generate another script for testing linux/fcntl
// declarations. These cannot be tested normally because including both
// `linux/fcntl.h` and `fcntl.h` fails.
//
// This also tests strerror_r.
test_linux_termios2();
}
@ -2701,7 +2723,10 @@ fn test_linux(target: &str) {
fn test_linux_termios2() {
let mut cfg = ctest::TestGenerator::new();
cfg.skip_type(|_| true)
.skip_fn(|_| true)
.skip_fn(|f| match f {
"strerror_r" => false,
_ => true,
})
.skip_static(|_| true);
headers! {
cfg:
@ -2709,7 +2734,8 @@ fn test_linux_termios2() {
"net/if.h",
"linux/if.h",
"linux/quota.h",
"asm/termbits.h"
"asm/termbits.h",
"string.h"
}
cfg.skip_const(move |name| match name {
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false,

View File

@ -488,6 +488,8 @@ f! {
}
extern {
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn abs(i: ::c_int) -> ::c_int;
pub fn atof(s: *const ::c_char) -> ::c_double;
pub fn labs(i: ::c_long) -> ::c_long;

View File

@ -1209,6 +1209,9 @@ f! {
}
extern {
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn abs(i: ::c_int) -> ::c_int;
pub fn atof(s: *const ::c_char) -> ::c_double;
pub fn labs(i: ::c_long) -> ::c_long;

View File

@ -964,6 +964,9 @@ f! {
}
extern {
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
pub fn sem_init(sem: *mut sem_t,
pshared: ::c_int,

View File

@ -931,10 +931,6 @@ extern {
pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int;
pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t)
-> ::c_int;
#[cfg_attr(all(target_os = "linux", not(target_env = "musl")),
link_name = "__xpg_strerror_r")]
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
#[cfg_attr(target_os = "illumos", link_name = "__xnet_getsockopt")]
pub fn getsockopt(sockfd: ::c_int,

View File

@ -598,6 +598,11 @@ f! {
}
extern {
#[cfg_attr(target_os = "linux",
link_name = "__xpg_strerror_r")]
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
pub fn sem_init(sem: *mut sem_t,
pshared: ::c_int,

View File

@ -1931,6 +1931,9 @@ extern {
}
extern {
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::timezone) -> ::c_int;
pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)

View File

@ -1687,6 +1687,9 @@ f! {
}
extern {
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn abs(i: ::c_int) -> ::c_int;
pub fn atof(s: *const ::c_char) -> ::c_double;
pub fn labs(i: ::c_long) -> ::c_long;

View File

@ -1972,6 +1972,11 @@ f! {
}
extern {
#[cfg_attr(not(target_env = "musl"),
link_name = "__xpg_strerror_r")]
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn abs(i: ::c_int) -> ::c_int;
pub fn atof(s: *const ::c_char) -> ::c_double;
pub fn labs(i: ::c_long) -> ::c_long;

View File

@ -534,6 +534,9 @@ cfg_if! {
}
extern {
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
// malloc.h
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;

View File

@ -1786,6 +1786,9 @@ f! {
}
extern {
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
pub fn sem_init(sem: *mut sem_t,
pshared: ::c_int,

View File

@ -1487,6 +1487,11 @@ f! {
}
extern {
#[cfg_attr(target_os = "linux",
link_name = "__xpg_strerror_r")]
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
buflen: ::size_t) -> ::c_int;
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
pub fn sem_init(sem: *mut sem_t,
pshared: ::c_int,