6fc053ed85
Limit the total number of entries and therefore the approximate memory consumption instead of doing this on a per directory basis as it was previously. This makes more sense as it limits not only the width but also the depth of the directory tree. Further, instead of hardcoding this value, allow to pass this information as additional optional parameter 'entires-max'. By this, creation of the archive with directories containing a large number of entries is possible. Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
76 lines
1.6 KiB
Rust
76 lines
1.6 KiB
Rust
use failure::*;
|
|
|
|
use std::process::Command;
|
|
use proxmox_backup::pxar::*;
|
|
|
|
fn run_test(dir_name: &str) -> Result<(), Error> {
|
|
|
|
println!("run pxar test {}", dir_name);
|
|
|
|
Command::new("casync")
|
|
.arg("make")
|
|
.arg("test-casync.catar")
|
|
.arg(dir_name)
|
|
.status()
|
|
.expect("failed to execute casync");
|
|
|
|
let mut writer = std::fs::OpenOptions::new()
|
|
.create(true)
|
|
.write(true)
|
|
.truncate(true)
|
|
.open("test-proxmox.catar")?;
|
|
|
|
let mut dir = nix::dir::Dir::open(
|
|
dir_name, nix::fcntl::OFlag::O_NOFOLLOW,
|
|
nix::sys::stat::Mode::empty())?;
|
|
|
|
let path = std::path::PathBuf::from(dir_name);
|
|
|
|
let catalog = None::<&mut catalog::DummyCatalogWriter>;
|
|
Encoder::encode(
|
|
path,
|
|
&mut dir,
|
|
&mut writer,
|
|
catalog,
|
|
None,
|
|
false,
|
|
false,
|
|
flags::DEFAULT,
|
|
Vec::new(),
|
|
ENCODER_MAX_ENTRIES,
|
|
)?;
|
|
|
|
Command::new("cmp")
|
|
.arg("--verbose")
|
|
.arg("test-casync.catar")
|
|
.arg("test-proxmox.catar")
|
|
.status()
|
|
.expect("test failed - archives are different");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn run_all_tests() -> Result<(), Error> {
|
|
|
|
run_test("tests/catar_data/test_file")?;
|
|
|
|
run_test("tests/catar_data/test_symlink")?;
|
|
|
|
run_test("tests/catar_data/test_subdir")?;
|
|
|
|
run_test("tests/catar_data/test_goodbye_sort_order")?;
|
|
|
|
run_test("tests/catar_data/test_files_and_subdirs")?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test] #[ignore]
|
|
fn catar_simple() {
|
|
|
|
if let Err(err) = run_all_tests() {
|
|
eprintln!("Error: {}", err);
|
|
std::process::exit(1);
|
|
}
|
|
}
|