Skip to content

Commit 48594dc

Browse files
committed
Update ctest for illumos and Solaris
1 parent 3d65979 commit 48594dc

File tree

2 files changed

+111
-8
lines changed

2 files changed

+111
-8
lines changed

libc-test/build.rs

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ use std::env;
77

88
fn do_cc() {
99
let target = env::var("TARGET").unwrap();
10-
if cfg!(unix) && !target.contains("wasi") {
11-
cc::Build::new().file("src/cmsg.c").compile("cmsg");
10+
if cfg!(unix) {
11+
let exclude = ["wasi", "solaris", "illumos"];
12+
if !exclude.iter().any(|x| target.contains(x)) {
13+
cc::Build::new().file("src/cmsg.c").compile("cmsg");
14+
}
1215
}
1316
if target.contains("android") || target.contains("linux") {
1417
cc::Build::new().file("src/errqueue.c").compile("errqueue");
@@ -27,7 +30,8 @@ fn do_ctest() {
2730
t if t.contains("netbsd") => return test_netbsd(t),
2831
t if t.contains("openbsd") => return test_openbsd(t),
2932
t if t.contains("redox") => return test_redox(t),
30-
t if t.contains("solaris") => return test_solaris(t),
33+
t if t.contains("solaris") => return test_solarish(t),
34+
t if t.contains("illumos") => return test_solarish(t),
3135
t if t.contains("wasi") => return test_wasi(t),
3236
t if t.contains("windows") => return test_windows(t),
3337
t if t.contains("vxworks") => return test_vxworks(t),
@@ -649,9 +653,13 @@ fn test_cloudabi(target: &str) {
649653
cfg.generate("../src/lib.rs", "main.rs");
650654
}
651655

652-
fn test_solaris(target: &str) {
653-
assert!(target.contains("solaris"));
656+
fn test_solarish(target: &str) {
657+
let is_solaris = target.contains("solaris");
658+
let is_illumos = target.contains("illumos");
659+
assert!(is_solaris || is_illumos);
654660

661+
// ctest generates arguments supported only by clang, so make sure to run with CC=clang.
662+
// While debugging, "CFLAGS=-ferror-limit=<large num>" is useful to get more error output.
655663
let mut cfg = ctest_cfg();
656664
cfg.flag("-Wno-deprecated-declarations");
657665

@@ -664,6 +672,7 @@ fn test_solaris(target: &str) {
664672
"ctype.h",
665673
"dirent.h",
666674
"dlfcn.h",
675+
"door.h",
667676
"errno.h",
668677
"execinfo.h",
669678
"fcntl.h",
@@ -673,6 +682,7 @@ fn test_solaris(target: &str) {
673682
"langinfo.h",
674683
"limits.h",
675684
"locale.h",
685+
"mqueue.h",
676686
"net/if.h",
677687
"net/if_arp.h",
678688
"net/route.h",
@@ -705,6 +715,7 @@ fn test_solaris(target: &str) {
705715
"sys/socket.h",
706716
"sys/stat.h",
707717
"sys/statvfs.h",
718+
"sys/shm.h",
708719
"sys/time.h",
709720
"sys/times.h",
710721
"sys/timex.h",
@@ -723,15 +734,100 @@ fn test_solaris(target: &str) {
723734
"wchar.h",
724735
}
725736

737+
cfg.skip_type(move |ty| {
738+
match ty {
739+
// sighandler_t is not present here
740+
"sighandler_t" => true,
741+
_ => false,
742+
}
743+
});
744+
745+
cfg.type_name(move |ty, is_struct, is_union| {
746+
match ty {
747+
"FILE" => "__FILE".to_string(),
748+
"DIR" | "Dl_info" => ty.to_string(),
749+
t if t.ends_with("_t") => t.to_string(),
750+
t if is_struct => format!("struct {}", t),
751+
t if is_union => format!("union {}", t),
752+
t => t.to_string(),
753+
}
754+
});
755+
756+
cfg.field_name(move |struct_, field| {
757+
match struct_ {
758+
// rust struct uses raw u64, rather than union
759+
"epoll_event" if field == "u64" => "data.u64".to_string(),
760+
// rust struct was committed with typo for Solaris
761+
"door_arg_t" if field == "dec_num" => "desc_num".to_string(),
762+
"stat" if field.ends_with("_nsec") => {
763+
// expose stat.Xtim.tv_nsec fields
764+
field.trim_end_matches("e_nsec").to_string() + ".tv_nsec"
765+
},
766+
_ => field.to_string()
767+
}
768+
});
769+
726770
cfg.skip_const(move |name| match name {
727771
"DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
728772
| "DT_SOCK" | "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => {
729773
true
730774
}
731775

776+
// skip sighandler_t assignments
777+
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true,
778+
779+
"DT_UNKNOWN" => true,
780+
781+
"_UTX_LINESIZE" | "_UTX_USERSIZE" |
782+
"_UTX_PADSIZE" | "_UTX_IDSIZE" | "_UTX_HOSTSIZE" => true,
783+
784+
"EADI" | "EXTPROC" | "IPC_SEAT" => true,
785+
786+
// This evaluates to a sysconf() call rather than a constant
787+
"PTHREAD_STACK_MIN" => true,
788+
732789
_ => false,
733790
});
734791

792+
793+
794+
cfg.skip_struct(move |ty| {
795+
// the union handling is a mess
796+
if ty.contains("door_desc_t_") {
797+
return true
798+
}
799+
match ty {
800+
// union, not a struct
801+
"sigval" => true,
802+
// a bunch of solaris-only fields
803+
"utmpx" if is_illumos => true,
804+
_ => false,
805+
}
806+
});
807+
808+
cfg.skip_field(move |s, field| {
809+
match s {
810+
// C99 sizing on this is tough
811+
"dirent" if field == "d_name" => true,
812+
// the union/macro makes this rough
813+
"sigaction" if field == "sa_sigaction" => true,
814+
// Missing in illumos
815+
"sigevent" if field == "ss_sp" => true,
816+
// Avoid sigval union issues
817+
"sigevent" if field == "sigev_value" => true,
818+
// const issues
819+
"sigevent" if field == "sigev_notify_attributes" => true,
820+
821+
// Avoid const and union issues
822+
"door_arg" if field == "desc_ptr" => true,
823+
"door_desc_t" if field == "d_data" => true,
824+
"door_arg_t" if field.ends_with("_ptr") => true,
825+
"door_arg_t" if field.ends_with("rbuf") => true,
826+
827+
_ => false
828+
}
829+
});
830+
735831
cfg.skip_fn(move |name| {
736832
// skip those that are manually verified
737833
match name {
@@ -746,13 +842,19 @@ fn test_solaris(target: &str) {
746842
// FIXME: unskip these for next major release
747843
"setpriority" | "personality" => true,
748844

749-
// signal is defined with sighandler_t, so ignore
845+
// signal is defined in terms of sighandler_t, so ignore
750846
"signal" => true,
751847

848+
// Currently missing
752849
"cfmakeraw" | "cfsetspeed" => true,
753850

754-
// FIXME: mincore is defined with caddr_t on Solaris.
755-
"mincore" => true,
851+
// const-ness issues
852+
"execv" | "execve" | "execvp" | "settimeofday" | "sethostname" => true,
853+
854+
// Solaris-different
855+
"getpwent_r" | "getgrent_r" | "updwtmpx" if is_illumos => true,
856+
"madvise" | "mprotect" if is_illumos => true,
857+
"door_call" | "door_return" | "door_create" if is_illumos => true,
756858

757859
_ => false,
758860
}

libc-test/test/cmsg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
extern crate libc;
55

66
#[cfg(unix)]
7+
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
78
mod t {
89

910
use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr};

0 commit comments

Comments
 (0)