Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
Signed-off-by: Xintao <[email protected]>
  • Loading branch information
hunterlxt committed Jun 1, 2020
1 parent ebb5745 commit fe2791d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 46 deletions.
48 changes: 3 additions & 45 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
//!
//! do_fallible_work();
//!
//! local_registry.cleanup();
//! local_registry.teardown();
//! }
//! ```
//!
Expand All @@ -125,7 +125,7 @@
//! local_registry.register_current();
//! fail::cfg("p0", "pause").unwrap();
//! println!("Local registry: {:?}", fail::list());
//! local_registry.cleanup();
//! local_registry.teardown();
//! println!("Local registry: {:?}", fail::list());
//! local_registry.deregister_current();
//! }
Expand Down Expand Up @@ -603,7 +603,7 @@ impl FailPointRegistry {
}

/// Clean up registered fail points in this registry.
pub fn cleanup(&self) {
pub fn teardown(&self) {
let mut registry = self.registry.write().unwrap();
cleanup(&mut registry);
}
Expand Down Expand Up @@ -1107,48 +1107,6 @@ mod tests {
}
}

#[test]
fn test_multiple_threads() {
let local_registry = new_fail_group();
local_registry.register_current();
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
local_registry.register_current();
cfg("thread_point", "sleep(10)").unwrap();
tx.send(()).unwrap();
});
rx.recv().unwrap();
let l = list();
assert!(l
.iter()
.find(|&x| x == &("thread_point".to_owned(), "sleep(10)".to_owned()))
.is_some());

let (tx, rx) = mpsc::channel();
let t = thread::spawn(move || {
let local_registry = new_fail_group();
local_registry.register_current();
cfg("thread_point", "panic").unwrap();
let l = list();
assert!(l
.iter()
.find(|&x| x == &("thread_point".to_owned(), "panic".to_owned()))
.is_some());
rx.recv().unwrap();
local_registry.cleanup();
let l = list();
assert!(l.is_empty());
});

tx.send(()).unwrap();
let l = list();
assert!(l
.iter()
.find(|&x| x == &("thread_point".to_owned(), "panic".to_owned()))
.is_none());
t.join().unwrap();
}

// This case should be tested as integration case, but when calling `teardown` other cases
// like `test_pause` maybe also affected, so it's better keep it here.
#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn test_multiple_threads_cleanup() {
&& l.len() == 1
);
rx.recv().unwrap();
local_registry.cleanup();
local_registry.teardown();
let l = fail::list();
assert!(l.is_empty());
});
Expand Down

0 comments on commit fe2791d

Please sign in to comment.