From eea0102308d5676919e8b3b4381eab69498d5fe5 Mon Sep 17 00:00:00 2001 From: gnzlbg <gonzalobg88@gmail.com> Date: Wed, 22 May 2019 10:46:57 +0200 Subject: [PATCH] Enable more tests on Android --- libc-test/build.rs | 182 +++++++++------------------------------------ 1 file changed, 37 insertions(+), 145 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 526c8a82..af198812 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1222,14 +1222,6 @@ fn test_android(target: &str) { let mut cfg = ctest::TestGenerator::new(); cfg.define("_GNU_SOURCE", None); - // FIXME: still necessary? - cfg.flag("-Wno-deprecated-declarations"); - - // Android doesn't actually have in_port_t but it's much easier if we - // provide one for us to test against - // FIXME: still necessary? - cfg.define("in_port_t", Some("uint16_t")); - headers! { cfg: "arpa/inet.h", "asm/mman.h", @@ -1296,6 +1288,7 @@ fn test_android(target: &str) { "sys/personality.h", "sys/prctl.h", "sys/ptrace.h", + "sys/random.h", "sys/reboot.h", "sys/resource.h", "sys/sendfile.h", @@ -1313,6 +1306,7 @@ fn test_android(target: &str) { "sys/un.h", "sys/utsname.h", "sys/vfs.h", + "sys/xattr.h", "sys/wait.h", "syslog.h", "termios.h", @@ -1329,6 +1323,7 @@ fn test_android(target: &str) { // generate the error 'Your time_t is already 64-bit' cfg.header("time64.h"); } + if x86 { cfg.header("sys/reg.h"); } @@ -1336,11 +1331,7 @@ fn test_android(target: &str) { cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - // FIXME: still required ? - "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" - | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" - | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" - | "Elf64_Chdr" => ty.to_string(), + "FILE" | "fd_set" | "Dl_info" => ty.to_string(), t if is_union => format!("union {}", t), @@ -1360,8 +1351,6 @@ fn test_android(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.to_string() } - // FIXME: still necessary? - "u64" if struct_ == "epoll_event" => "data.u64".to_string(), s => s.to_string(), } }); @@ -1377,72 +1366,19 @@ fn test_android(target: &str) { cfg.skip_struct(move |ty| { match ty { - // This is actually a union, not a struct - // FIXME: still necessary - "sigval" => true, - - // These structs have changed since unified headers in NDK r14b. - // `st_atime` and `st_atime_nsec` have changed sign. - // FIXME: unskip it for next major release - "stat" | "stat64" => true, - // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. - // FIXME: still necessary "termios2" => true, _ => false, } }); - cfg.skip_signededness(move |c| { - match c { - // FIXME: still necessary? - "LARGE_INTEGER" | "float" | "double" => true, - // FIXME: still necessary? - n if n.starts_with("pthread") => true, - _ => false, - } - }); - cfg.skip_const(move |name| { match name { - // FIXME: still necessary? - "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME: still necessary? - "SIGUNUSED" => true, // removed in glibc 2.26 - - // weird signed extension or something like that? - // FIXME: still necessary? - "MS_NOUSER" => true, - // FIXME: still necessary? - "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - - // Android uses old kernel headers - // These are constants used in getrandom syscall - // FIXME: still necessary? - "GRND_NONBLOCK" | "GRND_RANDOM" => true, - - // Defined by libattr not libc on linux (hard to test). - // See constant definition for more details. - // FIXME: still necessary? + // FIXME: deprecated: not available in any header + // See: https://github.com/rust-lang/libc/issues/1356 "ENOATTR" => true, - - // FIXME: still necessary? - "BOTHER" => true, - - // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the - // x86_64 and i686 builders it seems to be available for all targets, so at least test - // it there. - // FIXME: still necessary? - "MFD_HUGETLB" => true, - - // These change all the time from release to release of linux - // distros, let's just not bother trying to verify them. They - // shouldn't be used in code anyway... - // FIXME: still necessary? - "AF_MAX" | "PF_MAX" => true, - _ => false, } }); @@ -1461,9 +1397,6 @@ fn test_android(target: &str) { // FIXME: still necessary? "getdtablesize" => true, - // FIXME: still necessary? - "dlerror" => true, // const-ness is added - // Apparently the NDK doesn't have this defined on android, but // it's in a header file? // FIXME: still necessary? @@ -1474,17 +1407,6 @@ fn test_android(target: &str) { // FIXME: still necessary? "res_init" => true, - // Definition of those functions as changed since unified headers from NDK r14b - // These changes imply some API breaking changes but are still ABI compatible. - // We can wait for the next major release to be compliant with the new API. - // FIXME: unskip these for next major release - "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | - "setpriority" | "personality" => true, - // In Android 64 bits, these functions have been fixed since unified headers. - // Ignore these until next major version. - "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" - if target_pointer_width == 64 => true, - _ => false, } }); @@ -1525,40 +1447,12 @@ fn test_android(target: &str) { field == "ssi_arch")) }); - // FIXME: remove - cfg.fn_cname(move |name, _cname| name.to_string()); - cfg.generate("../src/lib.rs", "main.rs"); // 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. - // - // FIXME: is still necessary? - let mut cfg = ctest::TestGenerator::new(); - cfg.skip_type(|_| true) - .skip_fn(|_| true) - .skip_static(|_| true); - cfg.header("linux/fcntl.h"); - cfg.header("net/if.h"); - cfg.header("linux/if.h"); - cfg.header("linux/quota.h"); - cfg.header("asm/termbits.h"); - cfg.skip_const(move |name| match name { - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { - false - } - "BOTHER" => false, - _ => true, - }); - cfg.skip_struct(|s| s != "termios2"); - cfg.type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), - t => t.to_string(), - }); - cfg.generate("../src/lib.rs", "linux_fcntl.rs"); + test_linux_termios2(); } fn test_freebsd(target: &str) { @@ -2774,38 +2668,7 @@ fn test_linux(target: &str) { // On Linux also generate another script for testing linux/fcntl declarations. // These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h` // fails on a lot of platforms. - let mut cfg = ctest::TestGenerator::new(); - cfg.skip_type(|_| true) - .skip_fn(|_| true) - .skip_static(|_| true); - // musl defines these directly in `fcntl.h` - if musl { - cfg.header("fcntl.h"); - } else { - cfg.header("linux/fcntl.h"); - } - if !musl { - cfg.header("net/if.h"); - cfg.header("linux/if.h"); - } - cfg.header("linux/quota.h"); - cfg.header("asm/termbits.h"); - cfg.skip_const(move |name| match name { - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { - false - } - "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" if mips => false, - "BOTHER" => false, - _ => true, - }); - cfg.skip_struct(|s| s != "termios2"); - cfg.type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), - t => t.to_string(), - }); - cfg.generate("../src/lib.rs", "linux_fcntl.rs"); + test_linux_termios2(); // Test Elf64_Phdr and Elf32_Phdr // These types have a field called `p_type`, but including @@ -2827,3 +2690,32 @@ fn test_linux(target: &str) { cfg.header("elf.h"); cfg.generate("../src/lib.rs", "linux_elf.rs"); } + +fn test_linux_termios2() { + let mut cfg = ctest::TestGenerator::new(); + cfg.skip_type(|_| true) + .skip_fn(|_| true) + .skip_static(|_| true); + headers! { + cfg: + "linux/fcntl.h", + "net/if.h", + "linux/if.h", + "linux/quota.h", + "asm/termbits.h" + } + cfg.skip_const(move |name| match name { + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { + false + } + _ => true, + }); + cfg.skip_struct(|s| s != "termios2"); + cfg.type_name(move |ty, is_struct, is_union| match ty { + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), + }); + cfg.generate("../src/lib.rs", "linux_fcntl.rs"); +} -- GitLab