]>
git.proxmox.com Git - proxmox-backup.git/blob - tests/pxar.rs
1 use std
::io
::{BufRead, BufReader}
;
2 use std
::process
::{Command, Stdio}
;
4 // Test if xattrs are correctly archived and restored
6 fn pxar_create_and_extract() {
7 let src_dir
= "./tests/catar_data/test_xattrs_src/";
8 let dest_dir
= "./tests/catar_data/test_xattrs_dest/";
10 let exec_path
= if cfg
!(debug_assertions
) {
13 "./target/release/pxar"
16 println
!("run '{} create archive.pxar {}'", exec_path
, src_dir
);
18 Command
::new(exec_path
)
20 .arg("./tests/archive.pxar")
23 .unwrap_or_else(|err
| {
24 panic
!("Failed to invoke '{}': {}", exec_path
, err
)
27 println
!("run '{} extract archive.pxar {}'", exec_path
, dest_dir
);
29 Command
::new(exec_path
)
31 .arg("./tests/archive.pxar")
35 .unwrap_or_else(|err
| {
36 panic
!("Failed to invoke '{}': {}", exec_path
, err
)
39 println
!("run 'rsync --dry-run --itemize-changes --archive {} {}' to verify'", src_dir
, dest_dir
);
40 /* Use rsync with --dry-run and --itemize-changes to compare
41 src_dir and dest_dir */
42 let stdout
= Command
::new("rsync")
44 .arg("--itemize-changes")
48 .stdout(Stdio
::piped())
54 let reader
= BufReader
::new(stdout
);
55 let mut line_iter
= reader
.lines().map(|l
| l
.unwrap());
56 let mut linecount
= 0;
57 while let Some(curr
) = line_iter
.next() {
61 println
!("Rsync listed {} differences to address", linecount
);
65 .arg("./tests/archive.pxar")
67 .unwrap_or_else(|err
| {
68 panic
!("Failed to invoke 'rm': {}", err
)
71 // Cleanup destination dir
76 .unwrap_or_else(|err
| {
77 panic
!("Failed to invoke 'rm': {}", err
)
80 // If source and destination folder contain the same content,
81 // the output of the rsync invokation should yield no lines.
83 panic
!("pxar create and extract did not yield the same contents");