Formatação (cargo fmt) e ajustes do clippy para o CI da 1.0.0
Release / Cria a release (push) Canceled after 0s
Release / CLI (linux-aarch64) (push) Canceled after 0s
Release / CLI (linux-x86_64) (push) Canceled after 0s
Release / CLI (macos-aarch64) (push) Canceled after 0s
Release / CLI (macos-x86_64) (push) Canceled after 0s
Release / CLI (windows-x86_64) (push) Canceled after 0s
Release / App desktop (linux-x86_64) (push) Canceled after 0s
Release / App desktop (macos-aarch64) (push) Canceled after 0s
Release / App desktop (macos-x86_64) (push) Canceled after 0s
Release / App desktop (windows-x86_64) (push) Canceled after 0s
Release / Publica a release (push) Canceled after 0s
Release / Cria a release (push) Canceled after 0s
Release / CLI (linux-aarch64) (push) Canceled after 0s
Release / CLI (linux-x86_64) (push) Canceled after 0s
Release / CLI (macos-aarch64) (push) Canceled after 0s
Release / CLI (macos-x86_64) (push) Canceled after 0s
Release / CLI (windows-x86_64) (push) Canceled after 0s
Release / App desktop (linux-x86_64) (push) Canceled after 0s
Release / App desktop (macos-aarch64) (push) Canceled after 0s
Release / App desktop (macos-x86_64) (push) Canceled after 0s
Release / App desktop (windows-x86_64) (push) Canceled after 0s
Release / Publica a release (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
74218e7beb
commit
beb83fef92
49 files changed
+3806
-854
No files matched your search
@@ -7,7 +7,11 @@ use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn have(t: &str) -> bool {
|
||||
Command::new("sh").args(["-c", &format!("command -v {t}")]).output().map(|o| o.status.success()).unwrap_or(false)
|
||||
Command::new("sh")
|
||||
.args(["-c", &format!("command -v {t}")])
|
||||
.output()
|
||||
.map(|o| o.status.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn ext4_image(mib: u64) -> Option<Vec<u8>> {
|
||||
@@ -19,18 +23,33 @@ fn ext4_image(mib: u64) -> Option<Vec<u8>> {
|
||||
for d in 0..12 {
|
||||
std::fs::create_dir_all(root.join(format!("pasta{d}/sub"))).unwrap();
|
||||
for f in 0..40 {
|
||||
std::fs::write(root.join(format!("pasta{d}/arq{f}.txt")), vec![b'a' + (f % 26) as u8; 300 + f * 37]).unwrap();
|
||||
std::fs::write(
|
||||
root.join(format!("pasta{d}/arq{f}.txt")),
|
||||
vec![b'a' + (f % 26) as u8; 300 + f * 37],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
let img = dir.path().join("e.img");
|
||||
std::fs::File::create(&img).unwrap().set_len(mib << 20).unwrap();
|
||||
assert!(Command::new("mke2fs").args(["-q", "-F", "-t", "ext4", "-b", "1024", "-d"]).arg(&root).arg(&img).status().unwrap().success());
|
||||
std::fs::File::create(&img)
|
||||
.unwrap()
|
||||
.set_len(mib << 20)
|
||||
.unwrap();
|
||||
assert!(Command::new("mke2fs")
|
||||
.args(["-q", "-F", "-t", "ext4", "-b", "1024", "-d"])
|
||||
.arg(&root)
|
||||
.arg(&img)
|
||||
.status()
|
||||
.unwrap()
|
||||
.success());
|
||||
Some(std::fs::read(img).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_raid5_chunk_layout_and_shuffled_order() {
|
||||
let Some(logical) = ext4_image(24) else { return };
|
||||
let Some(logical) = ext4_image(24) else {
|
||||
return;
|
||||
};
|
||||
let (n, chunk) = (3usize, 32768usize);
|
||||
let dd = n - 1;
|
||||
let rows = logical.len() / (chunk * dd);
|
||||
@@ -51,11 +70,17 @@ fn finds_raid5_chunk_layout_and_shuffled_order() {
|
||||
disks[pd][row * chunk..(row + 1) * chunk].copy_from_slice(&p);
|
||||
}
|
||||
// Entrega os discos embaralhados: fornecidos = [2, 0, 1] do array real.
|
||||
let given: Vec<Arc<dyn Source>> = [2usize, 0, 1].iter().map(|&i| Arc::new(MemSource(disks[i].clone())) as Arc<dyn Source>).collect();
|
||||
let given: Vec<Arc<dyn Source>> = [2usize, 0, 1]
|
||||
.iter()
|
||||
.map(|&i| Arc::new(MemSource(disks[i].clone())) as Arc<dyn Source>)
|
||||
.collect();
|
||||
let found = raid_detect::detect(&given, &|| false);
|
||||
assert!(!found.is_empty());
|
||||
for c in found.iter().take(6) {
|
||||
eprintln!("CAND {:?} {} {:?} {:?} {:.2}", c.level, c.chunk, c.layout, c.order, c.score);
|
||||
eprintln!(
|
||||
"CAND {:?} {} {:?} {:?} {:.2}",
|
||||
c.level, c.chunk, c.layout, c.order, c.score
|
||||
);
|
||||
}
|
||||
let best = &found[0];
|
||||
assert_eq!(best.level, Level::R5);
|
||||
@@ -63,19 +88,30 @@ fn finds_raid5_chunk_layout_and_shuffled_order() {
|
||||
// Layouts e ordens diferentes podem ser equivalentes; o que importa é o conteúdo montado.
|
||||
let r = guara_core::raid::RaidSource::new(best.params(&given)).unwrap();
|
||||
let got = guara_core::source::read_vec(&r, 0, logical.len()).unwrap();
|
||||
assert!(got == logical, "montagem escolhida ({:?}, {:?}, {:?}) não reproduz o volume", best.layout, best.order, best.level);
|
||||
assert!(
|
||||
got == logical,
|
||||
"montagem escolhida ({:?}, {:?}, {:?}) não reproduz o volume",
|
||||
best.layout,
|
||||
best.order,
|
||||
best.level
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_raid0() {
|
||||
let Some(logical) = ext4_image(24) else { return };
|
||||
let Some(logical) = ext4_image(24) else {
|
||||
return;
|
||||
};
|
||||
let (n, chunk) = (2usize, 65536usize);
|
||||
let rows = logical.len() / (chunk * n);
|
||||
let mut disks = vec![vec![]; n];
|
||||
for c in 0..rows * n {
|
||||
disks[c % n].extend_from_slice(&logical[c * chunk..(c + 1) * chunk]);
|
||||
}
|
||||
let given: Vec<Arc<dyn Source>> = [1usize, 0].iter().map(|&i| Arc::new(MemSource(disks[i].clone())) as Arc<dyn Source>).collect();
|
||||
let given: Vec<Arc<dyn Source>> = [1usize, 0]
|
||||
.iter()
|
||||
.map(|&i| Arc::new(MemSource(disks[i].clone())) as Arc<dyn Source>)
|
||||
.collect();
|
||||
let found = raid_detect::detect(&given, &|| false);
|
||||
let best = &found[0];
|
||||
assert_eq!(best.level, Level::R0);
|
||||
|
||||
Reference in new issue
Block a user