summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/errno.rs207
-rw-r--r--src/lib.rs3
2 files changed, 210 insertions, 0 deletions
diff --git a/src/errno.rs b/src/errno.rs
index 35809f9b..cc6d750e 100644
--- a/src/errno.rs
+++ b/src/errno.rs
@@ -659,3 +659,210 @@ mod consts {
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+ use nixtest::assert_errno_eq;
+ use libc::c_int;
+
+ macro_rules! check_errno {
+ ($errno:ident) => {{
+ assert_errno_eq(stringify!($errno), $errno as c_int);
+ }};
+
+ ($errno:ident, $($rest:ident),+) => {{
+ check_errno!($errno);
+ check_errno!($($rest),*);
+ }};
+ }
+
+ #[test]
+ pub fn test_errno_values() {
+ check_errno!(
+ EPERM,
+ ENOENT,
+ ESRCH,
+ EINTR,
+ EIO,
+ ENXIO,
+ E2BIG,
+ ENOEXEC,
+ EBADF,
+ ECHILD,
+ EAGAIN,
+ ENOMEM,
+ EACCES,
+ EFAULT,
+ ENOTBLK,
+ EBUSY,
+ EEXIST,
+ EXDEV,
+ ENODEV,
+ ENOTDIR,
+ EISDIR,
+ EINVAL,
+ ENFILE,
+ EMFILE,
+ ENOTTY,
+ ETXTBSY,
+ EFBIG,
+ ENOSPC,
+ ESPIPE,
+ EROFS,
+ EMLINK,
+ EPIPE,
+ EDOM,
+ ERANGE,
+ EDEADLK,
+ ENAMETOOLONG,
+ ENOLCK,
+ ENOSYS,
+ ENOTEMPTY,
+ ELOOP,
+ ENOMSG,
+ EIDRM);
+
+ check_errno!(
+ EINPROGRESS,
+ EALREADY,
+ ENOTSOCK,
+ EDESTADDRREQ,
+ EMSGSIZE,
+ EPROTOTYPE,
+ ENOPROTOOPT,
+ EPROTONOSUPPORT,
+ ESOCKTNOSUPPORT,
+ EPFNOSUPPORT,
+ EAFNOSUPPORT,
+ EADDRINUSE,
+ EADDRNOTAVAIL,
+ ENETDOWN,
+ ENETUNREACH,
+ ENETRESET,
+ ECONNABORTED,
+ ECONNRESET,
+ ENOBUFS,
+ EISCONN,
+ ENOTCONN,
+ ESHUTDOWN,
+ ETOOMANYREFS,
+ ETIMEDOUT,
+ ECONNREFUSED,
+ EHOSTDOWN,
+ EHOSTUNREACH);
+ }
+
+ #[test]
+ #[cfg(target_os = "linux")]
+ pub fn test_linux_errnos() {
+ check_errno!(
+ ECHRNG,
+ EL2NSYNC,
+ EL3HLT,
+ EL3RST,
+ ELNRNG,
+ EUNATCH,
+ ENOCSI,
+ EL2HLT,
+ EBADE,
+ EBADR,
+ EXFULL,
+ ENOANO,
+ EBADRQC,
+ EBADSLT,
+ EBFONT,
+ ENOSTR,
+ ENODATA,
+ ETIME,
+ ENOSR,
+ ENONET,
+ ENOPKG,
+ EREMOTE,
+ ENOLINK,
+ EADV,
+ ESRMNT,
+ ECOMM,
+ EPROTO,
+ EMULTIHOP,
+ EDOTDOT,
+ EBADMSG,
+ EOVERFLOW,
+ ENOTUNIQ,
+ EBADFD,
+ EREMCHG,
+ ELIBACC,
+ ELIBBAD,
+ ELIBSCN,
+ ELIBMAX,
+ ELIBEXEC,
+ EILSEQ,
+ ERESTART,
+ ESTRPIPE,
+ EUSERS,
+ EOPNOTSUPP,
+ ESTALE,
+ EUCLEAN,
+ ENOTNAM,
+ ENAVAIL,
+ EISNAM,
+ EREMOTEIO,
+ EDQUOT,
+ ENOMEDIUM,
+ EMEDIUMTYPE,
+ ECANCELED,
+ ENOKEY,
+ EKEYEXPIRED,
+ EKEYREVOKED,
+ EKEYREJECTED,
+ EOWNERDEAD,
+ ENOTRECOVERABLE,
+ ERFKILL,
+ EHWPOISON);
+ }
+
+
+ #[test]
+ #[cfg(target_os = "macos")]
+ pub fn test_darwin_errnos() {
+ check_errno!(
+ ENOTSUP,
+ EPROCLIM,
+ EUSERS,
+ EDQUOT,
+ ESTALE,
+ EREMOTE,
+ EBADRPC,
+ ERPCMISMATCH,
+ EPROGUNAVAIL,
+ EPROGMISMATCH,
+ EPROCUNAVAIL,
+ EFTYPE,
+ EAUTH,
+ ENEEDAUTH,
+ EPWROFF,
+ EDEVERR,
+ EOVERFLOW,
+ EBADEXEC,
+ EBADARCH,
+ ESHLIBVERS,
+ EBADMACHO,
+ ECANCELED,
+ EILSEQ,
+ ENOATTR,
+ EBADMSG,
+ EMULTIHOP,
+ ENODATA,
+ ENOLINK,
+ ENOSR,
+ ENOSTR,
+ EPROTO,
+ ETIME,
+ EOPNOTSUPP,
+ ENOPOLICY,
+ ENOTRECOVERABLE,
+ EOWNERDEAD,
+ EQFULL
+ );
+ }
+}
diff --git a/src/lib.rs b/src/lib.rs
index e9e72378..53024175 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,6 +9,9 @@ extern crate bitflags;
extern crate libc;
extern crate core;
+#[cfg(test)]
+extern crate "nix-test" as nixtest;
+
// Re-export some libc constants
pub use libc::{c_int, c_void};