Skip to content

Commit

Permalink
unix: add a simple test to check the flags
Browse files Browse the repository at this point in the history
Check basic bit conflicts by comparing the sum and the or of all known
flags. Add a regression test for #896.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
  • Loading branch information
elmarco authored and Thomasdezeeuw committed Mar 7, 2019
1 parent de1972c commit 3aa20a8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sys/unix/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ const PRI: usize = 0;
// Export to support `Ready::all`
pub const READY_ALL: usize = ERROR | HUP | AIO | LIO | PRI;

#[test]
fn test_ready_all() {
let readable = Ready::readable().as_usize();
let writable = Ready::writable().as_usize();

assert_eq!(
READY_ALL | readable | writable,
ERROR + HUP + AIO + LIO + PRI + readable + writable
);

// Issue #896.
#[cfg(any(target_os = "linux", target_os = "android", target_os = "solaris"))]
assert!(!Ready::from(UnixReady::priority()).is_writable());
}

impl UnixReady {
/// Returns a `Ready` representing AIO completion readiness
///
Expand Down

0 comments on commit 3aa20a8

Please sign in to comment.