summaryrefslogtreecommitdiff
path: root/test/sys/test_ioctl.rs
blob: 49f49206eaec2a78d11d28b9391321e5fe17d233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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);
}

#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_write_64() {
    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);
}

#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_read_64() {
    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);
}

#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_read_write_64() {
    assert_eq!(op_read_write('z' as u8, 10, 1 << 32), 0xC0007A0A);
}