]> git.proxmox.com Git - proxmox-backup.git/blob - tests/catar.rs
api2/tape/restore: return backup manifest in try_restore_snapshot_archive
[proxmox-backup.git] / tests / catar.rs
1 use anyhow::{Error};
2
3 use std::process::Command;
4 use proxmox_backup::pxar::*;
5
6 fn run_test(dir_name: &str) -> Result<(), Error> {
7
8 println!("run pxar test {}", dir_name);
9
10 Command::new("casync")
11 .arg("make")
12 .arg("test-casync.catar")
13 .arg(dir_name)
14 .status()
15 .expect("failed to execute casync");
16
17 let writer = std::fs::OpenOptions::new()
18 .create(true)
19 .write(true)
20 .truncate(true)
21 .open("test-proxmox.catar")?;
22 let writer = pxar::encoder::sync::StandardWriter::new(writer);
23
24 let dir = nix::dir::Dir::open(
25 dir_name, nix::fcntl::OFlag::O_NOFOLLOW,
26 nix::sys::stat::Mode::empty())?;
27
28 let options = PxarCreateOptions {
29 entries_max: ENCODER_MAX_ENTRIES,
30 ..PxarCreateOptions::default()
31 };
32
33 let rt = tokio::runtime::Runtime::new().unwrap();
34 rt.block_on(create_archive(
35 dir,
36 writer,
37 Flags::DEFAULT,
38 |_| Ok(()),
39 None,
40 options,
41 ))?;
42
43 Command::new("cmp")
44 .arg("--verbose")
45 .arg("test-casync.catar")
46 .arg("test-proxmox.catar")
47 .status()
48 .expect("test failed - archives are different");
49
50 Ok(())
51 }
52
53 fn run_all_tests() -> Result<(), Error> {
54
55 run_test("tests/catar_data/test_file")?;
56
57 run_test("tests/catar_data/test_symlink")?;
58
59 run_test("tests/catar_data/test_subdir")?;
60
61 run_test("tests/catar_data/test_goodbye_sort_order")?;
62
63 run_test("tests/catar_data/test_files_and_subdirs")?;
64
65 Ok(())
66 }
67
68 #[test] #[ignore]
69 fn catar_simple() {
70
71 if let Err(err) = run_all_tests() {
72 eprintln!("Error: {}", err);
73 std::process::exit(1);
74 }
75 }