]>
git.proxmox.com Git - proxmox-backup.git/blob - tests/pxar.rs
e2f0a211aa15f1c79afbf1bb17b107949687a67d
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")
33 .unwrap_or_else(|err
| {
34 panic
!("Failed to invoke '{}': {}", exec_path
, err
)
37 /* Use rsync with --dry-run and --itemize-changes to compare
38 src_dir and dest_dir */
39 let stdout
= Command
::new("rsync")
41 .arg("--itemize-changes")
50 .stdout(Stdio
::piped())
56 let reader
= BufReader
::new(stdout
);
57 let linecount
= reader
.lines().fold(0, |count
, _
| count
+ 1 );
58 println
!("Rsync listed {} differences to address", linecount
);
62 .arg("./tests/archive.pxar")
64 .unwrap_or_else(|err
| {
65 panic
!("Failed to invoke 'rm': {}", err
)
68 // Cleanup destination dir
73 .unwrap_or_else(|err
| {
74 panic
!("Failed to invoke 'rm': {}", err
)
77 // If source and destination folder contain the same content,
78 // the output of the rsync invokation should yield no lines.
80 panic
!("pxar create and extract did not yield the same contents");