diff options
author | Carl Lerche <me@carllerche.com> | 2015-05-21 15:02:12 -0700 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2015-05-21 15:02:12 -0700 |
commit | 74d18318803a9a41632cab15d65305fd414aa198 (patch) | |
tree | 76c8e2733dda6e39f6c50939f70ab984bdd4e099 | |
parent | 075c037f8b85fde33d29ff591958e23cac88139e (diff) | |
download | nix-74d18318803a9a41632cab15d65305fd414aa198.zip |
Test sockopt const values
-rw-r--r-- | nix-test/Makefile | 2 | ||||
-rw-r--r-- | nix-test/src/const.c | 281 | ||||
-rw-r--r-- | nix-test/src/errno.c | 192 | ||||
-rw-r--r-- | nix-test/src/lib.rs | 21 | ||||
-rw-r--r-- | src/errno.rs | 4 | ||||
-rw-r--r-- | src/sys/socket/consts.rs | 93 | ||||
-rw-r--r-- | test/sys/test_ioctl.rs | 15 |
7 files changed, 407 insertions, 201 deletions
diff --git a/nix-test/Makefile b/nix-test/Makefile index 4d04f10b..67674529 100644 --- a/nix-test/Makefile +++ b/nix-test/Makefile @@ -1,6 +1,6 @@ OUT = libnixtest.a CFLAGS = -fPIC -D$(OS) -OBJS = errno.o \ +OBJS = const.o \ sizes.o $(OUT): $(OBJS) diff --git a/nix-test/src/const.c b/nix-test/src/const.c new file mode 100644 index 00000000..d9c1054a --- /dev/null +++ b/nix-test/src/const.c @@ -0,0 +1,281 @@ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/ip.h> +#include <netinet/ip6.h> +#include <netinet/tcp.h> +#include <netinet/udp.h> + +#define GET_CONST(CONST) \ + do { \ + if (0 == strcmp(err, #CONST)) { \ + return CONST; \ + } \ + } while (0) + +int +get_int_const(const char* err) { + + /* + * + * ===== ERRNO ===== + * + */ + + GET_CONST(EPERM); + GET_CONST(ENOENT); + GET_CONST(ESRCH); + GET_CONST(EINTR); + GET_CONST(EIO); + GET_CONST(ENXIO); + GET_CONST(E2BIG); + GET_CONST(ENOEXEC); + GET_CONST(EBADF); + GET_CONST(ECHILD); + GET_CONST(EAGAIN); + GET_CONST(ENOMEM); + GET_CONST(EACCES); + GET_CONST(EFAULT); + GET_CONST(ENOTBLK); + GET_CONST(EBUSY); + GET_CONST(EEXIST); + GET_CONST(EXDEV); + GET_CONST(ENODEV); + GET_CONST(ENOTDIR); + GET_CONST(EISDIR); + GET_CONST(EINVAL); + GET_CONST(ENFILE); + GET_CONST(EMFILE); + GET_CONST(ENOTTY); + GET_CONST(ETXTBSY); + GET_CONST(EFBIG); + GET_CONST(ENOSPC); + GET_CONST(ESPIPE); + GET_CONST(EROFS); + GET_CONST(EMLINK); + GET_CONST(EPIPE); + GET_CONST(EDOM); + GET_CONST(ERANGE); + GET_CONST(EDEADLK); + GET_CONST(ENAMETOOLONG); + GET_CONST(ENOLCK); + GET_CONST(ENOSYS); + GET_CONST(ENOTEMPTY); + GET_CONST(ELOOP); + GET_CONST(ENOMSG); + GET_CONST(EIDRM); + GET_CONST(EINPROGRESS); + GET_CONST(EALREADY); + GET_CONST(ENOTSOCK); + GET_CONST(EDESTADDRREQ); + GET_CONST(EMSGSIZE); + GET_CONST(EPROTOTYPE); + GET_CONST(ENOPROTOOPT); + GET_CONST(EPROTONOSUPPORT); + GET_CONST(ESOCKTNOSUPPORT); + GET_CONST(EPFNOSUPPORT); + GET_CONST(EAFNOSUPPORT); + GET_CONST(EADDRINUSE); + GET_CONST(EADDRNOTAVAIL); + GET_CONST(ENETDOWN); + GET_CONST(ENETUNREACH); + GET_CONST(ENETRESET); + GET_CONST(ECONNABORTED); + GET_CONST(ECONNRESET); + GET_CONST(ENOBUFS); + GET_CONST(EISCONN); + GET_CONST(ENOTCONN); + GET_CONST(ESHUTDOWN); + GET_CONST(ETOOMANYREFS); + GET_CONST(ETIMEDOUT); + GET_CONST(ECONNREFUSED); + GET_CONST(EHOSTDOWN); + GET_CONST(EHOSTUNREACH); + +#ifdef LINUX + GET_CONST(ECHRNG); + GET_CONST(EL2NSYNC); + GET_CONST(EL3HLT); + GET_CONST(EL3RST); + GET_CONST(ELNRNG); + GET_CONST(EUNATCH); + GET_CONST(ENOCSI); + GET_CONST(EL2HLT); + GET_CONST(EBADE); + GET_CONST(EBADR); + GET_CONST(EXFULL); + GET_CONST(ENOANO); + GET_CONST(EBADRQC); + GET_CONST(EBADSLT); + GET_CONST(EBFONT); + GET_CONST(ENOSTR); + GET_CONST(ENODATA); + GET_CONST(ETIME); + GET_CONST(ENOSR); + GET_CONST(ENONET); + GET_CONST(ENOPKG); + GET_CONST(EREMOTE); + GET_CONST(ENOLINK); + GET_CONST(EADV); + GET_CONST(ESRMNT); + GET_CONST(ECOMM); + GET_CONST(EPROTO); + GET_CONST(EMULTIHOP); + GET_CONST(EDOTDOT); + GET_CONST(EBADMSG); + GET_CONST(EOVERFLOW); + GET_CONST(ENOTUNIQ); + GET_CONST(EBADFD); + GET_CONST(EREMCHG); + GET_CONST(ELIBACC); + GET_CONST(ELIBBAD); + GET_CONST(ELIBSCN); + GET_CONST(ELIBMAX); + GET_CONST(ELIBEXEC); + GET_CONST(EILSEQ); + GET_CONST(ERESTART); + GET_CONST(ESTRPIPE); + GET_CONST(EUSERS); + GET_CONST(EOPNOTSUPP); + GET_CONST(ESTALE); + GET_CONST(EUCLEAN); + GET_CONST(ENOTNAM); + GET_CONST(ENAVAIL); + GET_CONST(EISNAM); + GET_CONST(EREMOTEIO); + GET_CONST(EDQUOT); + GET_CONST(ENOMEDIUM); + GET_CONST(EMEDIUMTYPE); + GET_CONST(ECANCELED); + GET_CONST(ENOKEY); + GET_CONST(EKEYEXPIRED); + GET_CONST(EKEYREVOKED); + GET_CONST(EKEYREJECTED); + GET_CONST(EOWNERDEAD); + GET_CONST(ENOTRECOVERABLE); +#ifndef __ANDROID__ + GET_CONST(ERFKILL); + GET_CONST(EHWPOISON); +#endif +#endif + +#ifdef DARWIN + GET_CONST(ENOTSUP); + GET_CONST(EPROCLIM); + GET_CONST(EUSERS); + GET_CONST(EDQUOT); + GET_CONST(ESTALE); + GET_CONST(EREMOTE); + GET_CONST(EBADRPC); + GET_CONST(ERPCMISMATCH); + GET_CONST(EPROGUNAVAIL); + GET_CONST(EPROGMISMATCH); + GET_CONST(EPROCUNAVAIL); + GET_CONST(EFTYPE); + GET_CONST(EAUTH); + GET_CONST(ENEEDAUTH); + GET_CONST(EPWROFF); + GET_CONST(EDEVERR); + GET_CONST(EOVERFLOW); + GET_CONST(EBADEXEC); + GET_CONST(EBADARCH); + GET_CONST(ESHLIBVERS); + GET_CONST(EBADMACHO); + GET_CONST(ECANCELED); + GET_CONST(EILSEQ); + GET_CONST(ENOATTR); + GET_CONST(EBADMSG); + GET_CONST(EMULTIHOP); + GET_CONST(ENODATA); + GET_CONST(ENOLINK); + GET_CONST(ENOSR); + GET_CONST(ENOSTR); + GET_CONST(EPROTO); + GET_CONST(ETIME); + GET_CONST(EOPNOTSUPP); + GET_CONST(ENOPOLICY); + GET_CONST(ENOTRECOVERABLE); + GET_CONST(EOWNERDEAD); + GET_CONST(EQFULL); +#endif + + /* + * + * ===== SOCKET OPTIONS ===== + * + */ + + GET_CONST(AF_UNIX); + GET_CONST(AF_LOCAL); + GET_CONST(AF_INET); + GET_CONST(AF_INET6); + GET_CONST(SOCK_STREAM); + GET_CONST(SOCK_DGRAM); + GET_CONST(SOCK_SEQPACKET); + GET_CONST(SOCK_RAW); + GET_CONST(SOCK_RDM); + GET_CONST(SOL_SOCKET); + GET_CONST(IPPROTO_IP); + GET_CONST(IPPROTO_IPV6); + GET_CONST(IPPROTO_TCP); + GET_CONST(IPPROTO_UDP); + GET_CONST(SO_ACCEPTCONN); + GET_CONST(SO_BROADCAST); + GET_CONST(SO_DEBUG); + GET_CONST(SO_ERROR); + GET_CONST(SO_DONTROUTE); + GET_CONST(SO_KEEPALIVE); + GET_CONST(SO_LINGER); + GET_CONST(SO_OOBINLINE); + GET_CONST(SO_RCVBUF); + GET_CONST(SO_RCVLOWAT); + GET_CONST(SO_SNDLOWAT); + GET_CONST(SO_RCVTIMEO); + GET_CONST(SO_SNDTIMEO); + GET_CONST(SO_REUSEADDR); + GET_CONST(SO_REUSEPORT); + GET_CONST(SO_SNDBUF); + GET_CONST(SO_TIMESTAMP); + GET_CONST(SO_TYPE); + GET_CONST(TCP_NODELAY); + GET_CONST(TCP_MAXSEG); + GET_CONST(IP_MULTICAST_IF); + GET_CONST(IP_MULTICAST_TTL); + GET_CONST(IP_MULTICAST_LOOP); + GET_CONST(IP_ADD_MEMBERSHIP); + GET_CONST(IP_DROP_MEMBERSHIP); + GET_CONST(INADDR_ANY); + GET_CONST(INADDR_NONE); + GET_CONST(INADDR_BROADCAST); + GET_CONST(MSG_OOB); + GET_CONST(MSG_PEEK); + GET_CONST(MSG_DONTWAIT); + GET_CONST(SHUT_RD); + GET_CONST(SHUT_WR); + GET_CONST(SHUT_RDWR); + +#ifdef LINUX + GET_CONST(SOL_IP); + GET_CONST(SOL_TCP); + GET_CONST(SOL_IPV6); + GET_CONST(SOL_UDP); + GET_CONST(SO_BINDTODEVICE); + GET_CONST(SO_BSDCOMPAT); + GET_CONST(SO_DOMAIN); + GET_CONST(SO_MARK); + GET_CONST(TCP_CORK); + GET_CONST(SO_BUSY_POLL); + GET_CONST(SO_RXQ_OVFL); + GET_CONST(SO_PASSCRED); + GET_CONST(SO_PRIORITY); + GET_CONST(SO_PROTOCOL); + GET_CONST(SO_RCVBUFFORCE); + GET_CONST(SO_PEEK_OFF); + GET_CONST(SO_PEERCRED); + GET_CONST(SO_SNDBUFFORCE); +#endif + + return -1; +} diff --git a/nix-test/src/errno.c b/nix-test/src/errno.c deleted file mode 100644 index eaf882c8..00000000 --- a/nix-test/src/errno.c +++ /dev/null @@ -1,192 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <errno.h> - -#define ERRNO_EQ(ERR) \ - do { \ - if (0 == strcmp(err, #ERR)) { \ - return ERR; \ - } \ - } while (0) - -int -assert_errno_eq(const char* err) { - ERRNO_EQ(EPERM); - ERRNO_EQ(ENOENT); - ERRNO_EQ(ESRCH); - ERRNO_EQ(EINTR); - ERRNO_EQ(EIO); - ERRNO_EQ(ENXIO); - ERRNO_EQ(E2BIG); - ERRNO_EQ(ENOEXEC); - ERRNO_EQ(EBADF); - ERRNO_EQ(ECHILD); - ERRNO_EQ(EAGAIN); - ERRNO_EQ(ENOMEM); - ERRNO_EQ(EACCES); - ERRNO_EQ(EFAULT); - ERRNO_EQ(ENOTBLK); - ERRNO_EQ(EBUSY); - ERRNO_EQ(EEXIST); - ERRNO_EQ(EXDEV); - ERRNO_EQ(ENODEV); - ERRNO_EQ(ENOTDIR); - ERRNO_EQ(EISDIR); - ERRNO_EQ(EINVAL); - ERRNO_EQ(ENFILE); - ERRNO_EQ(EMFILE); - ERRNO_EQ(ENOTTY); - ERRNO_EQ(ETXTBSY); - ERRNO_EQ(EFBIG); - ERRNO_EQ(ENOSPC); - ERRNO_EQ(ESPIPE); - ERRNO_EQ(EROFS); - ERRNO_EQ(EMLINK); - ERRNO_EQ(EPIPE); - ERRNO_EQ(EDOM); - ERRNO_EQ(ERANGE); - ERRNO_EQ(EDEADLK); - ERRNO_EQ(ENAMETOOLONG); - ERRNO_EQ(ENOLCK); - ERRNO_EQ(ENOSYS); - ERRNO_EQ(ENOTEMPTY); - ERRNO_EQ(ELOOP); - ERRNO_EQ(ENOMSG); - ERRNO_EQ(EIDRM); - ERRNO_EQ(EINPROGRESS); - ERRNO_EQ(EALREADY); - ERRNO_EQ(ENOTSOCK); - ERRNO_EQ(EDESTADDRREQ); - ERRNO_EQ(EMSGSIZE); - ERRNO_EQ(EPROTOTYPE); - ERRNO_EQ(ENOPROTOOPT); - ERRNO_EQ(EPROTONOSUPPORT); - ERRNO_EQ(ESOCKTNOSUPPORT); - ERRNO_EQ(EPFNOSUPPORT); - ERRNO_EQ(EAFNOSUPPORT); - ERRNO_EQ(EADDRINUSE); - ERRNO_EQ(EADDRNOTAVAIL); - ERRNO_EQ(ENETDOWN); - ERRNO_EQ(ENETUNREACH); - ERRNO_EQ(ENETRESET); - ERRNO_EQ(ECONNABORTED); - ERRNO_EQ(ECONNRESET); - ERRNO_EQ(ENOBUFS); - ERRNO_EQ(EISCONN); - ERRNO_EQ(ENOTCONN); - ERRNO_EQ(ESHUTDOWN); - ERRNO_EQ(ETOOMANYREFS); - ERRNO_EQ(ETIMEDOUT); - ERRNO_EQ(ECONNREFUSED); - ERRNO_EQ(EHOSTDOWN); - ERRNO_EQ(EHOSTUNREACH); - -#ifdef LINUX - ERRNO_EQ(ECHRNG); - ERRNO_EQ(EL2NSYNC); - ERRNO_EQ(EL3HLT); - ERRNO_EQ(EL3RST); - ERRNO_EQ(ELNRNG); - ERRNO_EQ(EUNATCH); - ERRNO_EQ(ENOCSI); - ERRNO_EQ(EL2HLT); - ERRNO_EQ(EBADE); - ERRNO_EQ(EBADR); - ERRNO_EQ(EXFULL); - ERRNO_EQ(ENOANO); - ERRNO_EQ(EBADRQC); - ERRNO_EQ(EBADSLT); - ERRNO_EQ(EBFONT); - ERRNO_EQ(ENOSTR); - ERRNO_EQ(ENODATA); - ERRNO_EQ(ETIME); - ERRNO_EQ(ENOSR); - ERRNO_EQ(ENONET); - ERRNO_EQ(ENOPKG); - ERRNO_EQ(EREMOTE); - ERRNO_EQ(ENOLINK); - ERRNO_EQ(EADV); - ERRNO_EQ(ESRMNT); - ERRNO_EQ(ECOMM); - ERRNO_EQ(EPROTO); - ERRNO_EQ(EMULTIHOP); - ERRNO_EQ(EDOTDOT); - ERRNO_EQ(EBADMSG); - ERRNO_EQ(EOVERFLOW); - ERRNO_EQ(ENOTUNIQ); - ERRNO_EQ(EBADFD); - ERRNO_EQ(EREMCHG); - ERRNO_EQ(ELIBACC); - ERRNO_EQ(ELIBBAD); - ERRNO_EQ(ELIBSCN); - ERRNO_EQ(ELIBMAX); - ERRNO_EQ(ELIBEXEC); - ERRNO_EQ(EILSEQ); - ERRNO_EQ(ERESTART); - ERRNO_EQ(ESTRPIPE); - ERRNO_EQ(EUSERS); - ERRNO_EQ(EOPNOTSUPP); - ERRNO_EQ(ESTALE); - ERRNO_EQ(EUCLEAN); - ERRNO_EQ(ENOTNAM); - ERRNO_EQ(ENAVAIL); - ERRNO_EQ(EISNAM); - ERRNO_EQ(EREMOTEIO); - ERRNO_EQ(EDQUOT); - ERRNO_EQ(ENOMEDIUM); - ERRNO_EQ(EMEDIUMTYPE); - ERRNO_EQ(ECANCELED); - ERRNO_EQ(ENOKEY); - ERRNO_EQ(EKEYEXPIRED); - ERRNO_EQ(EKEYREVOKED); - ERRNO_EQ(EKEYREJECTED); - ERRNO_EQ(EOWNERDEAD); - ERRNO_EQ(ENOTRECOVERABLE); -#ifndef __ANDROID__ - ERRNO_EQ(ERFKILL); - ERRNO_EQ(EHWPOISON); -#endif -#endif - -#ifdef DARWIN - ERRNO_EQ(ENOTSUP); - ERRNO_EQ(EPROCLIM); - ERRNO_EQ(EUSERS); - ERRNO_EQ(EDQUOT); - ERRNO_EQ(ESTALE); - ERRNO_EQ(EREMOTE); - ERRNO_EQ(EBADRPC); - ERRNO_EQ(ERPCMISMATCH); - ERRNO_EQ(EPROGUNAVAIL); - ERRNO_EQ(EPROGMISMATCH); - ERRNO_EQ(EPROCUNAVAIL); - ERRNO_EQ(EFTYPE); - ERRNO_EQ(EAUTH); - ERRNO_EQ(ENEEDAUTH); - ERRNO_EQ(EPWROFF); - ERRNO_EQ(EDEVERR); - ERRNO_EQ(EOVERFLOW); - ERRNO_EQ(EBADEXEC); - ERRNO_EQ(EBADARCH); - ERRNO_EQ(ESHLIBVERS); - ERRNO_EQ(EBADMACHO); - ERRNO_EQ(ECANCELED); - ERRNO_EQ(EILSEQ); - ERRNO_EQ(ENOATTR); - ERRNO_EQ(EBADMSG); - ERRNO_EQ(EMULTIHOP); - ERRNO_EQ(ENODATA); - ERRNO_EQ(ENOLINK); - ERRNO_EQ(ENOSR); - ERRNO_EQ(ENOSTR); - ERRNO_EQ(EPROTO); - ERRNO_EQ(ETIME); - ERRNO_EQ(EOPNOTSUPP); - ERRNO_EQ(ENOPOLICY); - ERRNO_EQ(ENOTRECOVERABLE); - ERRNO_EQ(EOWNERDEAD); - ERRNO_EQ(EQFULL); -#endif - - return 0; -} diff --git a/nix-test/src/lib.rs b/nix-test/src/lib.rs index 66a66413..25ab7fc7 100644 --- a/nix-test/src/lib.rs +++ b/nix-test/src/lib.rs @@ -1,24 +1,23 @@ extern crate libc; +use std::fmt; use std::ffi::CString; -use libc::{c_int}; +use libc::{c_int, c_char}; mod ffi { use libc::{c_int, c_char, size_t}; #[link(name = "nixtest", kind = "static")] extern { - pub fn assert_errno_eq(errno: *const c_char) -> c_int; + pub fn get_int_const(errno: *const c_char) -> c_int; pub fn size_of(ty: *const c_char) -> size_t; } } -pub fn assert_errno_eq(name: &str, actual: c_int) { +pub fn assert_const_eq<T: GetConst>(name: &str, actual: T) { unsafe { let cstr = CString::new(name).unwrap(); - let expect = ffi::assert_errno_eq(cstr.as_ptr()); - - assert!(expect > 0, "undefined errno {}", name); + let expect = GetConst::get_const(cstr.as_ptr()); if actual != expect { panic!("incorrect value for errno {}; expect={}; actual={}", @@ -42,3 +41,13 @@ pub fn assert_size_of<T>(name: &str) { } } } + +pub trait GetConst : PartialEq<Self> + fmt::Display { + unsafe fn get_const(name: *const c_char) -> Self; +} + +impl GetConst for c_int { + unsafe fn get_const(name: *const c_char) -> c_int { + ffi::get_int_const(name) + } +} diff --git a/src/errno.rs b/src/errno.rs index 9ed3d7d6..258b7805 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -1204,12 +1204,12 @@ mod consts { #[cfg(test)] mod test { use super::*; - use nixtest::assert_errno_eq; + use nixtest::assert_const_eq; use libc::c_int; macro_rules! check_errno { ($($errno:ident),+) => {{ - $(assert_errno_eq(stringify!($errno), $errno as c_int);)+ + $(assert_const_eq(stringify!($errno), $errno as c_int);)+ }}; } diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs index 91337189..7d2af535 100644 --- a/src/sys/socket/consts.rs +++ b/src/sys/socket/consts.rs @@ -188,3 +188,96 @@ mod os { pub const SHUT_WR: c_int = 1; pub const SHUT_RDWR: c_int = 2; } + +#[cfg(test)] +mod test { + use super::*; + use nixtest::assert_const_eq; + use libc::c_int; + + macro_rules! check_const { + ($($konst:ident),+) => {{ + $(assert_const_eq(stringify!($konst), $konst as c_int);)+ + }}; + } + + #[test] + pub fn test_const_values() { + check_const!( + AF_UNIX, + AF_LOCAL, + AF_INET, + AF_INET6, + SOCK_STREAM, + SOCK_DGRAM, + SOCK_SEQPACKET, + SOCK_RAW, + SOCK_RDM, + SOL_SOCKET, + IPPROTO_IP, + IPPROTO_IPV6, + IPPROTO_TCP, + IPPROTO_UDP, + SO_ACCEPTCONN, + SO_BROADCAST, + SO_DEBUG, + SO_ERROR, + SO_DONTROUTE, + SO_KEEPALIVE, + SO_LINGER, + SO_OOBINLINE, + SO_RCVBUF, + SO_RCVLOWAT, + SO_SNDLOWAT, + SO_RCVTIMEO, + SO_SNDTIMEO, + SO_REUSEADDR, + SO_REUSEPORT, + SO_SNDBUF, + SO_TIMESTAMP, + SO_TYPE, + TCP_NODELAY, + TCP_MAXSEG, + IP_MULTICAST_IF, + IP_MULTICAST_TTL, + IP_MULTICAST_LOOP, + IP_ADD_MEMBERSHIP, + IP_DROP_MEMBERSHIP, + INADDR_ANY, + INADDR_NONE, + INADDR_BROADCAST, + MSG_OOB, + MSG_PEEK, + MSG_DONTWAIT, + SHUT_RD, + SHUT_WR, + SHUT_RDWR + ); + + + } + + #[cfg(target_os = "linux")] + #[test] + pub fn test_linux_consts() { + check_const!( + SOL_IP, + SOL_TCP, + SOL_UDP, + SOL_IPV6, + SO_BINDTODEVICE, + SO_BSDCOMPAT, + SO_DOMAIN, + SO_MARK, + TCP_CORK, + SO_BUSY_POLL, + SO_RXQ_OVFL, + SO_PASSCRED, + SO_PRIORITY, + SO_PROTOCOL, + SO_RCVBUFFORCE, + SO_PEEK_OFF, + SO_PEERCRED, + SO_SNDBUFFORCE); + } +} diff --git a/test/sys/test_ioctl.rs b/test/sys/test_ioctl.rs index 2654bd81..49f49206 100644 --- a/test/sys/test_ioctl.rs +++ b/test/sys/test_ioctl.rs @@ -13,6 +13,11 @@ fn test_op_none() { fn test_op_write() { assert_eq!(op_write('z' as u8, 10, 1), 0x40017A0A); assert_eq!(op_write('z' as u8, 10, 512), 0x42007A0A); +} + +#[cfg(target_pointer_width = "64")] +#[test] +fn test_op_write_64() { assert_eq!(op_write('z' as u8, 10, 1 << 32), 0x40007A0A); } @@ -20,6 +25,11 @@ fn test_op_write() { fn test_op_read() { assert_eq!(op_read('z' as u8, 10, 1), 0x80017A0A); assert_eq!(op_read('z' as u8, 10, 512), 0x82007A0A); +} + +#[cfg(target_pointer_width = "64")] +#[test] +fn test_op_read_64() { assert_eq!(op_read('z' as u8, 10, 1 << 32), 0x80007A0A); } @@ -27,5 +37,10 @@ fn test_op_read() { fn test_op_read_write() { assert_eq!(op_read_write('z' as u8, 10, 1), 0xC0017A0A); assert_eq!(op_read_write('z' as u8, 10, 512), 0xC2007A0A); +} + +#[cfg(target_pointer_width = "64")] +#[test] +fn test_op_read_write_64() { assert_eq!(op_read_write('z' as u8, 10, 1 << 32), 0xC0007A0A); } |