Skip to content

Commit f5cbdbc

Browse files
committed
Clean libc-test for apple targets
This cleans up the build.rs of `libc-test` for apple targets. I wanted to update the docker containers of some targets so that we can start testing newer currently-skipped APIs properly, but it is impossible to figure out which headers and APIs are skipped for each target. This PR separates the testing of apple targets into its own self-contained function. This allows seeing exactly which headers are included, and which items are skipped. A lot of work will be required to separate the testing of all major platforms and make the script reasonable. During the clean up, I discovered that, at least for apple targets, deprecated but not removed APIs are not tested. I re-enabled testing for those, and fixed `daemon`, which was not properly linking its symbol. I also added the `#[deprecated]` attribute to the `#[deprecated]` APIs of the apple targets. The attribute is available since Rust 1.9.0 and the min. Rust version we support is Rust 1.13.0. Many other APIs are also currently not tested "because they are weird" which I interpret as "the test failed for an unknown reason", as a consequence: * the signatures of execv, execve, and execvp are incorrect (see #1272) * the `sig_t` type is called `sighandler_t` in libc for some reason: #1273 This probably explains why some other things, like the `sa_handler`/`sa_sigaction` fields of `sigaction` were skipped. The field is actually a union, which can be either a `sig_t` for the `sa_handler` field, or some other type for the `sa_sigaction` field, but because the distinction was not made, the field was not checked. The latest ctest version can check volatile pointers, so a couple of skipped tests are now tested using this feature.
1 parent 8c571e0 commit f5cbdbc

File tree

14 files changed

+269
-132
lines changed

14 files changed

+269
-132
lines changed

libc-test/build.rs

Lines changed: 197 additions & 123 deletions
Large diffs are not rendered by default.

libc-test/test/linux_fcntl.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
#![allow(bad_style, improper_ctypes, unused)]
1+
#![allow(bad_style, improper_ctypes, unused, deprecated)]
22

33
extern crate libc;
4-
54
use libc::*;
65

6+
#[cfg(any(target_os = "linux", target_os = "android"))]
77
include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs"));
8+
9+
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10+
fn main() {}

libc-test/test/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(bad_style, improper_ctypes)]
1+
#![allow(bad_style, improper_ctypes, deprecated)]
22
extern crate libc;
33

44
use libc::*;

src/unix/bsd/apple/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ s! {
139139
}
140140

141141
pub struct sigaction {
142+
// FIXME: this field is actually a union
142143
pub sa_sigaction: ::sighandler_t,
143144
pub sa_mask: sigset_t,
144145
pub sa_flags: ::c_int,
@@ -2255,12 +2256,14 @@ pub const NOTE_NONE: ::uint32_t = 0x00000080;
22552256
pub const NOTE_EXIT: ::uint32_t = 0x80000000;
22562257
pub const NOTE_FORK: ::uint32_t = 0x40000000;
22572258
pub const NOTE_EXEC: ::uint32_t = 0x20000000;
2259+
#[deprecated(since="0.2.49", note="Deprecated since MacOSX 10.9")]
22582260
pub const NOTE_REAP: ::uint32_t = 0x10000000;
22592261
pub const NOTE_SIGNAL: ::uint32_t = 0x08000000;
22602262
pub const NOTE_EXITSTATUS: ::uint32_t = 0x04000000;
22612263
pub const NOTE_EXIT_DETAIL: ::uint32_t = 0x02000000;
22622264
pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff;
22632265
pub const NOTE_PCTRLMASK: ::uint32_t = 0xfff00000;
2266+
#[deprecated(since="0.2.49", note="Deprecated since MacOSX 10.9")]
22642267
pub const NOTE_EXIT_REPARENTED: ::uint32_t = 0x00080000;
22652268
pub const NOTE_EXIT_DETAIL_MASK: ::uint32_t = 0x00070000;
22662269
pub const NOTE_EXIT_DECRYPTFAIL: ::uint32_t = 0x00010000;
@@ -2466,7 +2469,9 @@ pub const KERN_KDSETRTCDEC: ::c_int = 15;
24662469
pub const KERN_KDGETENTROPY: ::c_int = 16;
24672470
pub const KERN_KDWRITETR: ::c_int = 17;
24682471
pub const KERN_KDWRITEMAP: ::c_int = 18;
2472+
#[deprecated(since = "0.2.49", note ="Removed in MacOSX 10.12")]
24692473
pub const KERN_KDENABLE_BG_TRACE: ::c_int = 19;
2474+
#[deprecated(since = "0.2.49", note ="Removed in MacOSX 10.12")]
24702475
pub const KERN_KDDISABLE_BG_TRACE: ::c_int = 20;
24712476
pub const KERN_KDREADCURTHRMAP: ::c_int = 21;
24722477
pub const KERN_KDSET_TYPEFILTER: ::c_int = 22;
@@ -2846,6 +2851,16 @@ f! {
28462851
}
28472852

28482853
extern {
2854+
#[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.5")]
2855+
#[link_name = "daemon$1050"]
2856+
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
2857+
#[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.10")]
2858+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
2859+
#[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.10")]
2860+
pub fn sem_init(sem: *mut sem_t,
2861+
pshared: ::c_int,
2862+
value: ::c_uint)
2863+
-> ::c_int;
28492864
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
28502865
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
28512866
pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,14 @@ f! {
10501050
}
10511051

10521052
extern {
1053+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
1054+
pub fn sem_init(sem: *mut sem_t,
1055+
pshared: ::c_int,
1056+
value: ::c_uint)
1057+
-> ::c_int;
1058+
1059+
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
1060+
10531061
pub fn accept4(s: ::c_int, addr: *mut ::sockaddr,
10541062
addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int;
10551063
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;

src/unix/bsd/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,6 @@ extern {
623623
pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
624624
pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
625625
pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
626-
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
627626
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
628627
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
629628
pub fn getpwnam_r(name: *const ::c_char,

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,13 @@ pub const TIMER_ABSTIME: ::c_int = 1;
597597

598598
#[link(name = "util")]
599599
extern {
600+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
601+
pub fn sem_init(sem: *mut sem_t,
602+
pshared: ::c_int,
603+
value: ::c_uint)
604+
-> ::c_int;
605+
606+
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
600607
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
601608
vec: *mut ::c_char) -> ::c_int;
602609
#[cfg_attr(target_os = "netbsd", link_name = "__clock_getres50")]

src/unix/haiku/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,12 @@ extern {
11111111

11121112
#[link(name = "bsd")]
11131113
extern {
1114+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
1115+
pub fn sem_init(sem: *mut sem_t,
1116+
pshared: ::c_int,
1117+
value: ::c_uint)
1118+
-> ::c_int;
1119+
11141120
pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
11151121
pub fn clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int;
11161122
pub fn pthread_create(thread: *mut ::pthread_t,

src/unix/hermit/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,12 @@ f! {
705705
}
706706

707707
extern {
708+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
709+
pub fn sem_init(sem: *mut sem_t,
710+
pshared: ::c_int,
711+
value: ::c_uint)
712+
-> ::c_int;
713+
708714
pub fn abs(i: ::c_int) -> ::c_int;
709715
pub fn atof(s: *const ::c_char) -> ::c_double;
710716
pub fn labs(i: ::c_long) -> ::c_long;

src/unix/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,16 +1021,11 @@ extern {
10211021
locale: *const ::c_char) -> *mut ::c_char;
10221022
pub fn localeconv() -> *mut lconv;
10231023

1024-
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
10251024
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
10261025
link_name = "sem_wait$UNIX2003")]
10271026
pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
10281027
pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
10291028
pub fn sem_post(sem: *mut sem_t) -> ::c_int;
1030-
pub fn sem_init(sem: *mut sem_t,
1031-
pshared: ::c_int,
1032-
value: ::c_uint)
1033-
-> ::c_int;
10341029
pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
10351030
pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
10361031

src/unix/newlib/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,12 @@ f! {
568568
}
569569

570570
extern {
571+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
572+
pub fn sem_init(sem: *mut sem_t,
573+
pshared: ::c_int,
574+
value: ::c_uint)
575+
-> ::c_int;
576+
571577
pub fn abs(i: ::c_int) -> ::c_int;
572578
pub fn atof(s: *const ::c_char) -> ::c_double;
573579
pub fn labs(i: ::c_long) -> ::c_long;

src/unix/notbsd/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,12 @@ f! {
12901290
}
12911291

12921292
extern {
1293+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
1294+
pub fn sem_init(sem: *mut sem_t,
1295+
pshared: ::c_int,
1296+
value: ::c_uint)
1297+
-> ::c_int;
1298+
12931299
pub fn fdatasync(fd: ::c_int) -> ::c_int;
12941300
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
12951301
vec: *mut ::c_uchar) -> ::c_int;

src/unix/solarish/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,12 @@ f! {
15571557
}
15581558

15591559
extern {
1560+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
1561+
pub fn sem_init(sem: *mut sem_t,
1562+
pshared: ::c_int,
1563+
value: ::c_uint)
1564+
-> ::c_int;
1565+
15601566
pub fn abs(i: ::c_int) -> ::c_int;
15611567
pub fn acct(filename: *const ::c_char) -> ::c_int;
15621568
pub fn atof(s: *const ::c_char) -> ::c_double;

src/unix/uclibc/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,12 @@ f! {
14811481
}
14821482

14831483
extern {
1484+
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
1485+
pub fn sem_init(sem: *mut sem_t,
1486+
pshared: ::c_int,
1487+
value: ::c_uint)
1488+
-> ::c_int;
1489+
14841490
pub fn abs(i: ::c_int) -> ::c_int;
14851491
pub fn atof(s: *const ::c_char) -> ::c_double;
14861492
pub fn labs(i: ::c_long) -> ::c_long;

0 commit comments

Comments
 (0)