Skip to content

Commit

Permalink
tests: loop on EACCES while waiting for keyring collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mathstuf committed Jul 30, 2019
1 parent 87d9631 commit 421f739
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/tests/invalidate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn invalidate_keyring() {
let keyring_observer = keyring.clone();

keyring.invalidate().unwrap();
utils::wait_for_keyring_gc_read(&keyring_observer);
utils::wait_for_keyring_gc(&keyring_observer);

let err = keyring_observer.read().unwrap_err();
assert_eq!(err, errno::Errno(libc::ENOKEY));
Expand Down
2 changes: 1 addition & 1 deletion src/tests/newring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn duplicate_keyring_names() {
assert_eq!(1, keyrings.len());
assert_eq!(new_keyring2, keyrings[0]);

utils::wait_for_keyring_gc_description(&new_keyring1);
utils::wait_for_keyring_gc(&new_keyring1);

// It should be inaccessible.
let err = new_keyring1.description().unwrap_err();
Expand Down
19 changes: 2 additions & 17 deletions src/tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,10 @@ pub fn wait_for_key_gc(key: &Key) {

/// Keys are deleted asynchronously; describing the key succeeds until it has been garbage
/// collected.
pub fn wait_for_keyring_gc_read(keyring: &Keyring) {
pub fn wait_for_keyring_gc(keyring: &Keyring) {
loop {
match keyring.read() {
Ok(_) => (),
Err(errno::Errno(libc::ENOKEY)) => break,
e @ Err(_) => {
e.unwrap();
unreachable!()
},
}
}
}

/// Keys are deleted asynchronously; describing the key succeeds until it has been garbage
/// collected.
pub fn wait_for_keyring_gc_description(keyring: &Keyring) {
loop {
match keyring.description() {
Ok(_) => (),
Ok(_) | Err(errno::Errno(libc::EACCES)) => (),
Err(errno::Errno(libc::ENOKEY)) => break,
e @ Err(_) => {
e.unwrap();
Expand Down

0 comments on commit 421f739

Please sign in to comment.