]>
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 Command
::new(exec_path
)
29 .arg("./tests/archive.pxar")
32 .unwrap_or_else(|err
| {
33 panic
!("Failed to invoke '{}': {}", exec_path
, err
)
36 /* Use rsync with --dry-run and --itemize-changes to compare
37 src_dir and dest_dir */
38 let stdout
= Command
::new("rsync")
40 .arg("--itemize-changes")
49 .stdout(Stdio
::piped())
55 let reader
= BufReader
::new(stdout
);
56 let linecount
= reader
.lines().fold(0, |count
, _
| count
+ 1 );
57 println
!("Rsync listed {} differences to address", linecount
);
61 .arg("./tests/archive.pxar")
63 .unwrap_or_else(|err
| {
64 panic
!("Failed to invoke 'rm': {}", err
)
67 // Cleanup destination dir
72 .unwrap_or_else(|err
| {
73 panic
!("Failed to invoke 'rm': {}", err
)
76 // If source and destination folder contain the same content,
77 // the output of the rsync invokation should yield no lines.
79 panic
!("pxar create and extract did not yield the same contents");