Skip to content

Commit b905aef

Browse files
committed
Auto merge of #1281 - semarie:openbsd-test, r=gnzlbg
cleanup libc-test for OpenBSD here a cleanup for libc-test for OpenBSD Some elements (compat for old and now unsupported OpenBSD versions) could be removed, but I think it is better to address them after this PR is merged. the testsuite for OpenBSD still pass with it (well, with #1280) r? @gnzlbg
2 parents 841dbe3 + 91748de commit b905aef

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

libc-test/build.rs

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fn do_ctest() {
3131

3232
match &target {
3333
t if t.contains("apple") => return test_apple(t),
34+
t if t.contains("openbsd") => return test_openbsd(t),
3435
t if t.contains("windows") => return test_windows(t),
3536
t if t.contains("redox") => return test_redox(t),
3637
t if t.contains("cloudabi") => return test_cloudabi(t),
@@ -946,6 +947,150 @@ fn test_apple(target: &str) {
946947
cfg.generate("../src/lib.rs", "main.rs");
947948
}
948949

950+
fn test_openbsd(target: &str) {
951+
assert!(target.contains("openbsd"));
952+
953+
let mut cfg = ctest::TestGenerator::new();
954+
cfg.flag("-Wno-deprecated-declarations");
955+
956+
headers! { cfg:
957+
"errno.h",
958+
"fcntl.h",
959+
"limits.h",
960+
"locale.h",
961+
"stddef.h",
962+
"stdint.h",
963+
"stdio.h",
964+
"stdlib.h",
965+
"sys/stat.h",
966+
"sys/types.h",
967+
"time.h",
968+
"wchar.h",
969+
"ctype.h",
970+
"dirent.h",
971+
"sys/socket.h",
972+
"net/if.h",
973+
"net/route.h",
974+
"net/if_arp.h",
975+
"netdb.h",
976+
"netinet/in.h",
977+
"netinet/ip.h",
978+
"netinet/tcp.h",
979+
"netinet/udp.h",
980+
"resolv.h",
981+
"pthread.h",
982+
"dlfcn.h",
983+
"signal.h",
984+
"string.h",
985+
"sys/file.h",
986+
"sys/ioctl.h",
987+
"sys/mman.h",
988+
"sys/resource.h",
989+
"sys/socket.h",
990+
"sys/time.h",
991+
"sys/un.h",
992+
"sys/wait.h",
993+
"unistd.h",
994+
"utime.h",
995+
"pwd.h",
996+
"grp.h",
997+
"sys/utsname.h",
998+
"sys/ptrace.h",
999+
"sys/mount.h",
1000+
"sys/uio.h",
1001+
"sched.h",
1002+
"termios.h",
1003+
"poll.h",
1004+
"syslog.h",
1005+
"semaphore.h",
1006+
"sys/statvfs.h",
1007+
"sys/times.h",
1008+
"glob.h",
1009+
"ifaddrs.h",
1010+
"langinfo.h",
1011+
"sys/sysctl.h",
1012+
"utmp.h",
1013+
"sys/event.h",
1014+
"net/if_dl.h",
1015+
"util.h",
1016+
"ufs/ufs/quota.h",
1017+
"pthread_np.h",
1018+
"sys/syscall.h",
1019+
}
1020+
1021+
cfg.skip_struct(move |ty| {
1022+
match ty {
1023+
// FIXME: actually a union
1024+
"sigval" => true,
1025+
1026+
_ => false,
1027+
}
1028+
});
1029+
1030+
cfg.skip_const(move |name| {
1031+
match name {
1032+
// Removed in OpenBSD 6.0
1033+
"KERN_USERMOUNT" | "KERN_ARND" => true,
1034+
_ => false,
1035+
}
1036+
});
1037+
1038+
cfg.skip_fn(move |name| {
1039+
match name {
1040+
"execv" | "execve" | "execvp" | "execvpe" => true,
1041+
1042+
// typed 2nd arg
1043+
"gettimeofday" => true,
1044+
1045+
// Removed in OpenBSD 6.5
1046+
// https://marc.info/?l=openbsd-cvs&m=154723400730318
1047+
"mincore" => true,
1048+
1049+
_ => false,
1050+
}
1051+
});
1052+
1053+
cfg.type_name(move |ty, is_struct, is_union| {
1054+
match ty {
1055+
// Just pass all these through, no need for a "struct" prefix
1056+
"FILE" | "DIR" | "Dl_info" => ty.to_string(),
1057+
1058+
// OSX calls this something else
1059+
"sighandler_t" => "sig_t".to_string(),
1060+
1061+
t if is_union => format!("union {}", t),
1062+
t if t.ends_with("_t") => t.to_string(),
1063+
t if is_struct => format!("struct {}", t),
1064+
t => t.to_string(),
1065+
}
1066+
});
1067+
1068+
cfg.field_name(move |struct_, field| {
1069+
match field {
1070+
"st_birthtime" if struct_.starts_with("stat") => {
1071+
"__st_birthtime".to_string()
1072+
}
1073+
"st_birthtime_nsec" if struct_.starts_with("stat") => {
1074+
"__st_birthtimensec".to_string()
1075+
}
1076+
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
1077+
s.replace("e_nsec", ".tv_nsec")
1078+
}
1079+
"sa_sigaction" if struct_ == "sigaction" => {
1080+
"sa_handler".to_string()
1081+
}
1082+
s => s.to_string(),
1083+
}
1084+
});
1085+
1086+
cfg.skip_field_type(move |struct_, field| {
1087+
// type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1
1088+
(struct_ == "siginfo_t" && field == "si_addr")
1089+
});
1090+
1091+
cfg.generate("../src/lib.rs", "linux_fcntl.rs");
1092+
}
1093+
9491094
fn test_windows(target: &str) {
9501095
assert!(target.contains("windows"));
9511096
let gnu = target.contains("gnu");

0 commit comments

Comments
 (0)