2018-12-30 14:33:43 +00:00
|
|
|
use failure::*;
|
|
|
|
|
|
|
|
use std::process::Command;
|
2019-04-06 09:26:17 +00:00
|
|
|
use proxmox_backup::pxar::*;
|
2018-12-30 14:33:43 +00:00
|
|
|
|
|
|
|
fn run_test(dir_name: &str) -> Result<(), Error> {
|
|
|
|
|
2019-04-06 09:26:17 +00:00
|
|
|
println!("run pxar test {}", dir_name);
|
2018-12-30 14:33:43 +00:00
|
|
|
|
|
|
|
Command::new("casync")
|
|
|
|
.arg("make")
|
|
|
|
.arg("test-casync.catar")
|
|
|
|
.arg(dir_name)
|
|
|
|
.status()
|
|
|
|
.expect("failed to execute casync");
|
|
|
|
|
2019-01-02 10:02:56 +00:00
|
|
|
let mut writer = std::fs::OpenOptions::new()
|
2018-12-30 14:33:43 +00:00
|
|
|
.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);
|
|
|
|
|
2019-05-22 15:50:44 +00:00
|
|
|
Encoder::encode(path, &mut dir, &mut writer, false, false, false, false)?;
|
2018-12-30 14:33:43 +00:00
|
|
|
|
|
|
|
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")?;
|
|
|
|
|
2018-12-31 09:19:15 +00:00
|
|
|
run_test("tests/catar_data/test_goodbye_sort_order")?;
|
2018-12-30 16:32:52 +00:00
|
|
|
|
2018-12-31 09:22:39 +00:00
|
|
|
run_test("tests/catar_data/test_files_and_subdirs")?;
|
|
|
|
|
2018-12-30 14:33:43 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-01-31 14:32:04 +00:00
|
|
|
#[test] #[ignore]
|
2018-12-31 09:19:15 +00:00
|
|
|
fn catar_simple() {
|
2018-12-30 14:33:43 +00:00
|
|
|
|
|
|
|
if let Err(err) = run_all_tests() {
|
|
|
|
eprintln!("Error: {}", err);
|
|
|
|
std::process::exit(1);
|
|
|
|
}
|
|
|
|
}
|