pub struct Attempt { /* private fields */ }Expand description
One run with one selected allocation attempt failed.
Implementations§
Source§impl Attempt
impl Attempt
Sourcepub fn target_allocation(&self) -> usize
pub fn target_allocation(&self) -> usize
Zero-based allocation attempt selected for failure.
Sourcepub fn observed_allocations(&self) -> usize
pub fn observed_allocations(&self) -> usize
Number of allocation attempts observed during this run.
Sourcepub fn injected(&self) -> bool
pub fn injected(&self) -> bool
Returns whether the selected allocation attempt was actually reached and failed.
Sourcepub fn injected_allocation(&self) -> Option<Allocation>
pub fn injected_allocation(&self) -> Option<Allocation>
Returns metadata for the allocation attempt that was failed, if the target allocation was reached.
Examples found in repository?
examples/scenarios.rs (line 156)
154fn print_allocation_metadata(report: &alloc_chaos::Report) {
155 for attempt in report.attempts() {
156 if let Some(allocation) = attempt.injected_allocation() {
157 println!(
158 "metadata: target #{} -> {} size={} align={} new_size={:?}",
159 allocation.index(),
160 allocation.operation(),
161 allocation.size(),
162 allocation.align(),
163 allocation.new_size(),
164 );
165 }
166 }
167}Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if the selected allocation was injected and the closure
completed without panic.
Examples found in repository?
examples/scenarios.rs (line 115)
96fn reproduce_one_failure_and_show_metadata() {
97 let full_report = alloc_chaos::check(checked_packet_builder);
98 full_report.assert_success();
99
100 let target = full_report
101 .attempts()
102 .first()
103 .map(alloc_chaos::Attempt::target_allocation)
104 .expect("packet builder should allocate during the baseline run");
105
106 let report = alloc_chaos::Check::new()
107 .only_failure(target)
108 .run(checked_packet_builder);
109
110 print_report("single-target reproduction", &report);
111 print_allocation_metadata(&report);
112
113 assert!(report.is_truncated());
114 assert_eq!(report.tested_failures(), 1);
115 assert!(report.attempts()[0].is_success());
116 assert!(!report.is_success());
117}Trait Implementations§
impl Eq for Attempt
impl StructuralPartialEq for Attempt
Auto Trait Implementations§
impl Freeze for Attempt
impl RefUnwindSafe for Attempt
impl Send for Attempt
impl Sync for Attempt
impl Unpin for Attempt
impl UnsafeUnpin for Attempt
impl UnwindSafe for Attempt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more