Skip to main content

Attempt

Struct Attempt 

Source
pub struct Attempt { /* private fields */ }
Expand description

One run with one selected allocation attempt failed.

Implementations§

Source§

impl Attempt

Source

pub fn target_allocation(&self) -> usize

Zero-based allocation attempt selected for failure.

Source

pub fn observed_allocations(&self) -> usize

Number of allocation attempts observed during this run.

Source

pub fn injected(&self) -> bool

Returns whether the selected allocation attempt was actually reached and failed.

Source

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}
Source

pub fn outcome(&self) -> &Outcome

Outcome of this run.

Source

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§

Source§

impl Clone for Attempt

Source§

fn clone(&self) -> Attempt

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Attempt

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Attempt

Source§

fn eq(&self, other: &Attempt) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Attempt

Source§

impl StructuralPartialEq for Attempt

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.