Skip to content

Commit

Permalink
Improve output
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeder committed Dec 14, 2024
1 parent 4894197 commit 1c15cc1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ use crate::{
use crossterm::style::Stylize;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use std::process::{self};
use std::{
process::{self},
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
};

const TEST_SALT: &str = "saltsaltsaltsalt";
const TEST_PASSWORD: &str = "password";
Expand Down Expand Up @@ -2046,6 +2052,8 @@ pub fn stability_test(tasks: usize, iterations: usize) {
pbs.push(pb.clone());
}

let failed = Arc::new(AtomicBool::new(false));

(0..tasks).into_par_iter().for_each(|i| {
let pb = &pbs[i];

Expand All @@ -2064,8 +2072,14 @@ pub fn stability_test(tasks: usize, iterations: usize) {
0,
false,
|current_iteration, current_data| {
if failed.load(Ordering::Relaxed) {
process::exit(1);
}

let expected = EXPECTED[current_iteration];
if current_data != &hex::decode(expected).unwrap() {
failed.store(true, Ordering::Release);

println!(
"\n\nTasks #{} failed on iteration #{}\n\nExpected: 0x{}\nActual: 0x{}",
i + 1,
Expand Down

0 comments on commit 1c15cc1

Please sign in to comment.