Skip to content

Commit

Permalink
Improve debugging of mq tests by using assert_* macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Susurrus committed Jun 7, 2019
1 parent e3cfa88 commit c14a4de
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/test_mq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ fn test_mq_getattr() {
};
let mqd = r.unwrap();

let read_attr = mq_getattr(mqd);
assert!(read_attr.unwrap() == initial_attr);
let read_attr = mq_getattr(mqd).unwrap();
assert_eq!(read_attr, initial_attr);
mq_close(mqd).unwrap();
}

Expand All @@ -79,21 +79,21 @@ fn test_mq_setattr() {
let mqd = r.unwrap();

let new_attr = MqAttr::new(0, 20, MSG_SIZE * 2, 100);
let old_attr = mq_setattr(mqd, &new_attr);
assert!(old_attr.unwrap() == initial_attr);
let old_attr = mq_setattr(mqd, &new_attr).unwrap();
assert_eq!(old_attr, initial_attr);

let new_attr_get = mq_getattr(mqd);
let new_attr_get = mq_getattr(mqd).unwrap();
// The following tests make sense. No changes here because according to the Linux man page only
// O_NONBLOCK can be set (see tests below)
assert!(new_attr_get.unwrap() != new_attr);
assert_ne!(new_attr_get, new_attr);

let new_attr_non_blocking = MqAttr::new(MQ_OFlag::O_NONBLOCK.bits() as c_long, 10, MSG_SIZE, 0);
mq_setattr(mqd, &new_attr_non_blocking).unwrap();
let new_attr_get = mq_getattr(mqd);
let new_attr_get = mq_getattr(mqd).unwrap();

// now the O_NONBLOCK flag has been set
assert!(new_attr_get.unwrap() != initial_attr);
assert!(new_attr_get.unwrap() == new_attr_non_blocking);
assert_ne!(new_attr_get, initial_attr);
assert_eq!(new_attr_get, new_attr_non_blocking);
mq_close(mqd).unwrap();
}

Expand Down

0 comments on commit c14a4de

Please sign in to comment.