diff options
Diffstat (limited to 'test/sys')
-rw-r--r-- | test/sys/mod.rs | 1 | ||||
-rw-r--r-- | test/sys/test_ioctl.rs | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/test/sys/mod.rs b/test/sys/mod.rs index 21c5817c..17649e24 100644 --- a/test/sys/mod.rs +++ b/test/sys/mod.rs @@ -1,3 +1,4 @@ mod test_socket; mod test_termios; mod test_uio; +mod test_ioctl; diff --git a/test/sys/test_ioctl.rs b/test/sys/test_ioctl.rs new file mode 100644 index 00000000..2654bd81 --- /dev/null +++ b/test/sys/test_ioctl.rs @@ -0,0 +1,31 @@ +use nix::sys::ioctl::*; + +// See C code for source of values for op calculations: +// https://gist.github.com/posborne/83ea6880770a1aef332e + +#[test] +fn test_op_none() { + assert_eq!(op_none('q' as u8, 10), 0x0000710A); + assert_eq!(op_none('a' as u8, 255), 0x000061FF); +} + +#[test] +fn test_op_write() { + assert_eq!(op_write('z' as u8, 10, 1), 0x40017A0A); + assert_eq!(op_write('z' as u8, 10, 512), 0x42007A0A); + assert_eq!(op_write('z' as u8, 10, 1 << 32), 0x40007A0A); +} + +#[test] +fn test_op_read() { + assert_eq!(op_read('z' as u8, 10, 1), 0x80017A0A); + assert_eq!(op_read('z' as u8, 10, 512), 0x82007A0A); + assert_eq!(op_read('z' as u8, 10, 1 << 32), 0x80007A0A); +} + +#[test] +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); + assert_eq!(op_read_write('z' as u8, 10, 1 << 32), 0xC0007A0A); +} |