use captains_log::*;
use std::panic;
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
use std::thread;
#[cfg(feature = "ringfile")]
#[test]
fn test_ringfile_assert() {
recipe::ring_file("/tmp/ring.log", 10240, Level::Debug, crate::signal_consts::SIGINT)
.build()
.expect("setup");
let counter = Arc::new(AtomicUsize::new(0));
let mut th_s = Vec::new();
for _ in 0..4 {
let _counter = counter.clone();
th_s.push(thread::spawn(move || loop {
let c = _counter.fetch_add(1, Ordering::Relaxed);
if c == 100 {
panic!("reach");
} else if c > 100 {
return;
}
debug!("count {}", c);
std::hint::spin_loop();
}));
}
for th in th_s {
let _ = th.join();
}
}