pub fn check<F>(f: F) -> Reportwhere
F: Fn(),Expand description
Examples found in repository?
examples/scenarios.rs (line 68)
67fn strict_success() {
68 let report = alloc_chaos::check(checked_packet_builder);
69
70 print_report("strict exhaustive check", &report);
71 report.assert_success();
72}
73
74fn bounded_diagnostic_run() {
75 let report = alloc_chaos::Check::new()
76 .max_failures(1)
77 .stop_on_failure(true)
78 .run(checked_packet_builder);
79
80 print_report("bounded diagnostic run", &report);
81 assert!(report.is_truncated());
82 assert!(!report.is_success());
83}
84
85fn range_diagnostic_run() {
86 let report = alloc_chaos::Check::new()
87 .failure_range(1..2)
88 .run(checked_packet_builder);
89
90 print_report("selected failure range", &report);
91 assert!(report.is_truncated());
92 assert_eq!(report.tested_failures(), 1);
93 assert!(!report.is_success());
94}
95
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}