diff options
author | Martin Kröning <mkroening@posteo.net> | 2021-07-28 23:05:29 +0200 |
---|---|---|
committer | Martin Kröning <mkroening@posteo.net> | 2021-07-29 23:03:25 +0200 |
commit | 8af1a48e9b2657b79da7c6dceb41205880a3eaca (patch) | |
tree | 04c413efe8873d02cd537d85b4e4397a3a6e56e8 | |
parent | a7794832a61a43c089df2e3d886c00f38c2d7d87 (diff) | |
download | rust-libc-8af1a48e9b2657b79da7c6dceb41205880a3eaca.tar.gz |
Add tests for SIGRTMAX and SIGRTMIN
-rw-r--r-- | libc-test/Cargo.toml | 5 | ||||
-rwxr-xr-x | libc-test/build.rs | 7 | ||||
-rw-r--r-- | libc-test/src/sigrt.c | 9 | ||||
-rw-r--r-- | libc-test/test/sigrt.rs | 32 |
4 files changed, 53 insertions, 0 deletions
diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 233c7a5efd..3adbbc7fdd 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -72,6 +72,11 @@ path = "test/errqueue.rs" harness = true [[test]] +name = "sigrt" +path = "test/sigrt.rs" +harness = true + +[[test]] name = "semver" path = "test/semver.rs" harness = false diff --git a/libc-test/build.rs b/libc-test/build.rs index 975e0d16dd..97f5e36c42 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -26,6 +26,13 @@ fn do_cc() { if target.contains("android") || target.contains("linux") { cc::Build::new().file("src/errqueue.c").compile("errqueue"); } + if target.contains("linux") + || target.contains("l4re") + || target.contains("android") + || target.contains("emscripten") + { + cc::Build::new().file("src/sigrt.c").compile("sigrt"); + } } fn do_ctest() { diff --git a/libc-test/src/sigrt.c b/libc-test/src/sigrt.c new file mode 100644 index 0000000000..6140e7a8ba --- /dev/null +++ b/libc-test/src/sigrt.c @@ -0,0 +1,9 @@ +#include <signal.h> + +int sigrtmax() { + return SIGRTMAX; +} + +int sigrtmin() { + return SIGRTMIN; +} diff --git a/libc-test/test/sigrt.rs b/libc-test/test/sigrt.rs new file mode 100644 index 0000000000..453dcb341d --- /dev/null +++ b/libc-test/test/sigrt.rs @@ -0,0 +1,32 @@ +//! Compare libc's SIGRTMAX and SIGRTMIN functions against the actual C macros + +extern crate libc; + +#[cfg(any( + target_os = "linux", + target_os = "l4re", + target_os = "android", + target_os = "emscripten" +))] +mod t { + use libc; + + extern "C" { + pub fn sigrtmax() -> libc::c_int; + pub fn sigrtmin() -> libc::c_int; + } + + #[test] + fn test_sigrtmax() { + unsafe { + assert_eq!(libc::SIGRTMAX(), sigrtmax()); + } + } + + #[test] + fn test_sigrtmin() { + unsafe { + assert_eq!(libc::SIGRTMIN(), sigrtmin()); + } + } +} |