mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
Merge pull request #6293 from cakebaker/cp_remove_panics_in_tests
cp: remove panics in tests
This commit is contained in:
commit
1162c53f56
1 changed files with 186 additions and 373 deletions
|
@ -3402,29 +3402,23 @@ fn test_cp_archive_on_directory_ending_dot() {
|
|||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
|
||||
fn test_cp_debug_default() {
|
||||
#[cfg(target_os = "macos")]
|
||||
let expected = "copy offload: unknown, reflink: unsupported, sparse detection: unsupported";
|
||||
#[cfg(target_os = "linux")]
|
||||
let expected = "copy offload: unknown, reflink: unsupported, sparse detection: no";
|
||||
#[cfg(windows)]
|
||||
let expected = "copy offload: unsupported, reflink: unsupported, sparse detection: unsupported";
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
at.touch("a");
|
||||
let result = ts.ucmd().arg("--debug").arg("a").arg("b").succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
#[cfg(target_os = "macos")]
|
||||
if !stdout_str
|
||||
.contains("copy offload: unknown, reflink: unsupported, sparse detection: unsupported")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
if !stdout_str.contains("copy offload: unknown, reflink: unsupported, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
if !stdout_str
|
||||
.contains("copy offload: unsupported, reflink: unsupported, sparse detection: unsupported")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds()
|
||||
.stdout_contains(expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3436,6 +3430,7 @@ fn test_cp_debug_multiple_default() {
|
|||
at.touch("a");
|
||||
at.touch("b");
|
||||
at.mkdir(dir);
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
.arg("--debug")
|
||||
|
@ -3444,62 +3439,15 @@ fn test_cp_debug_multiple_default() {
|
|||
.arg(dir)
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
if !stdout_str
|
||||
.contains("copy offload: unknown, reflink: unsupported, sparse detection: unsupported")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
|
||||
// two files, two occurrences
|
||||
assert_eq!(
|
||||
result
|
||||
.stdout_str()
|
||||
.matches(
|
||||
"copy offload: unknown, reflink: unsupported, sparse detection: unsupported"
|
||||
)
|
||||
.count(),
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
let expected = "copy offload: unknown, reflink: unsupported, sparse detection: unsupported";
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
if !stdout_str.contains("copy offload: unknown, reflink: unsupported, sparse detection: no")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
let expected = "copy offload: unknown, reflink: unsupported, sparse detection: no";
|
||||
#[cfg(windows)]
|
||||
let expected = "copy offload: unsupported, reflink: unsupported, sparse detection: unsupported";
|
||||
|
||||
// two files, two occurrences
|
||||
assert_eq!(
|
||||
result
|
||||
.stdout_str()
|
||||
.matches("copy offload: unknown, reflink: unsupported, sparse detection: no")
|
||||
.count(),
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
if !stdout_str.contains(
|
||||
"copy offload: unsupported, reflink: unsupported, sparse detection: unsupported",
|
||||
) {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
|
||||
// two files, two occurrences
|
||||
assert_eq!(
|
||||
result
|
||||
.stdout_str()
|
||||
.matches("copy offload: unsupported, reflink: unsupported, sparse detection: unsupported")
|
||||
.count(),
|
||||
2
|
||||
);
|
||||
}
|
||||
// two files, two occurrences
|
||||
assert_eq!(result.stdout_str().matches(expected).count(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3508,19 +3456,15 @@ fn test_cp_debug_sparse_reflink() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
at.touch("a");
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=always")
|
||||
.arg("--reflink=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: zeros") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: zeros");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3544,18 +3488,14 @@ fn test_cp_debug_sparse_always() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
at.touch("a");
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=always")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: unsupported, sparse detection: zeros")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: unsupported, sparse detection: zeros");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3564,17 +3504,14 @@ fn test_cp_debug_sparse_never() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
at.touch("a");
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3593,63 +3530,40 @@ fn test_cp_debug_sparse_auto() {
|
|||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
{
|
||||
let result = ts
|
||||
.ucmd()
|
||||
#[cfg(target_os = "macos")]
|
||||
let expected = "copy offload: unknown, reflink: unsupported, sparse detection: unsupported";
|
||||
#[cfg(target_os = "linux")]
|
||||
let expected = "copy offload: unknown, reflink: unsupported, sparse detection: no";
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=auto")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
if !stdout_str
|
||||
.contains("copy offload: unknown, reflink: unsupported, sparse detection: unsupported")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
if !stdout_str.contains("copy offload: unknown, reflink: unsupported, sparse detection: no")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains(expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
fn test_cp_debug_reflink_auto() {
|
||||
#[cfg(target_os = "macos")]
|
||||
let expected = "copy offload: unknown, reflink: unsupported, sparse detection: unsupported";
|
||||
#[cfg(target_os = "linux")]
|
||||
let expected = "copy offload: unknown, reflink: unsupported, sparse detection: no";
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
at.touch("a");
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=auto")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: unknown, reflink: unsupported, sparse detection: no")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str
|
||||
.contains("copy offload: unknown, reflink: unsupported, sparse detection: unsupported")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains(expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3658,19 +3572,14 @@ fn test_cp_debug_sparse_always_reflink_auto() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
at.touch("a");
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=always")
|
||||
.arg("--reflink=auto")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: unsupported, sparse detection: zeros")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: unsupported, sparse detection: zeros");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3678,11 +3587,10 @@ fn test_cp_only_source_no_target() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
at.touch("a");
|
||||
let result = ts.ucmd().arg("a").fails();
|
||||
let stderr_str = result.stderr_str();
|
||||
if !stderr_str.contains("missing destination file operand after \"a\"") {
|
||||
panic!("Failure: stderr was \n{stderr_str}");
|
||||
}
|
||||
ts.ucmd()
|
||||
.arg("a")
|
||||
.fails()
|
||||
.stderr_contains("missing destination file operand after \"a\"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3822,6 +3730,7 @@ fn test_acl_preserve() {
|
|||
|
||||
assert!(compare_xattrs(&file, &file_target));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn test_cp_debug_reflink_never_with_hole() {
|
||||
|
@ -3834,24 +3743,19 @@ fn test_cp_debug_reflink_never_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
if dst_file_metadata.blocks() != src_file_metadata.blocks() {
|
||||
panic!("File not sparsely copied");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE");
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
assert_eq!(src_file_metadata.blocks(), dst_file_metadata.blocks());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn test_cp_debug_reflink_never_empty_file_with_hole() {
|
||||
|
@ -3864,23 +3768,17 @@ fn test_cp_debug_reflink_never_empty_file_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
if dst_file_metadata.blocks() != src_file_metadata.blocks() {
|
||||
panic!("File not sparsely copied");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: unknown, reflink: no, sparse detection: SEEK_HOLE");
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: unknown, reflink: no, sparse detection: SEEK_HOLE") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
assert_eq!(src_file_metadata.blocks(), dst_file_metadata.blocks());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3896,18 +3794,17 @@ fn test_cp_debug_default_with_hole() {
|
|||
f.set_len(10000).unwrap();
|
||||
|
||||
at.append_bytes("a", "hello".as_bytes());
|
||||
let result = ts.ucmd().arg("--debug").arg("a").arg("b").succeeds();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
if dst_file_metadata.blocks() != src_file_metadata.blocks() {
|
||||
panic!("File not sparsely copied");
|
||||
}
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: yes, reflink: unsupported, sparse detection: SEEK_HOLE")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: yes, reflink: unsupported, sparse detection: SEEK_HOLE");
|
||||
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
assert_eq!(src_file_metadata.blocks(), dst_file_metadata.blocks());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3923,19 +3820,14 @@ fn test_cp_debug_default_less_than_512_bytes() {
|
|||
.unwrap();
|
||||
f.set_len(400).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=auto")
|
||||
.arg("--sparse=auto")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: yes, reflink: unsupported, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: yes, reflink: unsupported, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3950,13 +3842,14 @@ fn test_cp_debug_default_without_hole() {
|
|||
|
||||
at.append_bytes("a", &filler_bytes);
|
||||
|
||||
let result = ts.ucmd().arg("--debug").arg("a").arg("b").succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: yes, reflink: unsupported, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: yes, reflink: unsupported, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn test_cp_debug_default_empty_file_with_hole() {
|
||||
|
@ -3969,19 +3862,18 @@ fn test_cp_debug_default_empty_file_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
|
||||
let result = ts.ucmd().arg("--debug").arg("a").arg("b").succeeds();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
if dst_file_metadata.blocks() != src_file_metadata.blocks() {
|
||||
panic!("File not sparsely copied");
|
||||
}
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds()
|
||||
.stdout_contains(
|
||||
"copy offload: unknown, reflink: unsupported, sparse detection: SEEK_HOLE",
|
||||
);
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str
|
||||
.contains("copy offload: unknown, reflink: unsupported, sparse detection: SEEK_HOLE")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
assert_eq!(src_file_metadata.blocks(), dst_file_metadata.blocks());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3996,25 +3888,18 @@ fn test_cp_debug_reflink_never_sparse_always_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("--sparse=always")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE + zeros");
|
||||
|
||||
let src_file_metadata = std::fs::metadata(at.plus("a")).unwrap();
|
||||
if dst_file_metadata.blocks() != src_file_metadata.blocks() {
|
||||
panic!("File not sparsely copied");
|
||||
}
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str
|
||||
.contains("copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE + zeros")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
assert_eq!(src_file_metadata.blocks(), dst_file_metadata.blocks());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4026,23 +3911,20 @@ fn test_cp_debug_reflink_never_sparse_always_without_hole() {
|
|||
at.write("a", "hello");
|
||||
at.append_bytes("a", &empty_bytes);
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("--sparse=always")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: zeros");
|
||||
|
||||
if dst_file_metadata.blocks() != dst_file_metadata.blksize() / 512 {
|
||||
panic!("Zero sequenced blocks not removed");
|
||||
}
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: zeros") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
assert_eq!(
|
||||
dst_file_metadata.blocks(),
|
||||
dst_file_metadata.blksize() / 512
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4057,19 +3939,14 @@ fn test_cp_debug_reflink_never_sparse_always_empty_file_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("--sparse=always")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: unknown, reflink: no, sparse detection: SEEK_HOLE") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: unknown, reflink: no, sparse detection: SEEK_HOLE");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4086,9 +3963,7 @@ fn test_cp_default_virtual_file() {
|
|||
let dest_size = std::fs::metadata(at.plus("b"))
|
||||
.expect("Metadata of copied file cannot be read")
|
||||
.size();
|
||||
if dest_size == 0 {
|
||||
panic!("Copy unsuccessful");
|
||||
}
|
||||
assert!(dest_size > 0);
|
||||
}
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
|
@ -4100,25 +3975,20 @@ fn test_cp_debug_reflink_auto_sparse_always_non_sparse_file_with_long_zero_seque
|
|||
at.touch("a");
|
||||
at.append_bytes("a", &buf);
|
||||
at.append_bytes("a", "hello".as_bytes());
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=always")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: unsupported, sparse detection: zeros");
|
||||
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
|
||||
if dst_file_metadata.blocks() != dst_file_metadata.blksize() / 512 {
|
||||
panic!("Zero sequenced blocks not removed");
|
||||
}
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: unsupported, sparse detection: zeros")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
assert_eq!(
|
||||
dst_file_metadata.blocks(),
|
||||
dst_file_metadata.blksize() / 512
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4127,17 +3997,14 @@ fn test_cp_debug_sparse_never_empty_sparse_file() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
at.touch("a");
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4150,46 +4017,38 @@ fn test_cp_debug_reflink_never_sparse_always_non_sparse_file_with_long_zero_sequ
|
|||
at.touch("a");
|
||||
at.append_bytes("a", &buf);
|
||||
at.append_bytes("a", "hello".as_bytes());
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("--sparse=always")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: zeros");
|
||||
|
||||
let dst_file_metadata = std::fs::metadata(at.plus("b")).unwrap();
|
||||
|
||||
if dst_file_metadata.blocks() != dst_file_metadata.blksize() / 512 {
|
||||
panic!("Zero sequenced blocks not removed");
|
||||
}
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: zeros") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
assert_eq!(
|
||||
dst_file_metadata.blocks(),
|
||||
dst_file_metadata.blksize() / 512
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_cp_debug_sparse_always_sparse_virtual_file() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=always")
|
||||
.arg("/sys/kernel/address_bits")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains(
|
||||
"copy offload: avoided, reflink: unsupported, sparse detection: SEEK_HOLE + zeros",
|
||||
) {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains(
|
||||
"copy offload: avoided, reflink: unsupported, sparse detection: SEEK_HOLE + zeros",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn test_cp_debug_reflink_never_less_than_512_bytes() {
|
||||
|
@ -4203,18 +4062,13 @@ fn test_cp_debug_reflink_never_less_than_512_bytes() {
|
|||
.unwrap();
|
||||
f.set_len(400).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4229,19 +4083,16 @@ fn test_cp_debug_reflink_never_sparse_never_empty_file_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("--sparse=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: unknown, reflink: no, sparse detection: SEEK_HOLE") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: unknown, reflink: no, sparse detection: SEEK_HOLE");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn test_cp_debug_reflink_never_file_with_hole() {
|
||||
|
@ -4254,18 +4105,15 @@ fn test_cp_debug_reflink_never_file_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
at.append_bytes("a", "hello".as_bytes());
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("--sparse=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4281,19 +4129,14 @@ fn test_cp_debug_sparse_never_less_than_512_bytes() {
|
|||
.unwrap();
|
||||
f.set_len(400).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=auto")
|
||||
.arg("--sparse=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4308,20 +4151,16 @@ fn test_cp_debug_sparse_never_without_hole() {
|
|||
|
||||
at.append_bytes("a", &filler_bytes);
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--reflink=auto")
|
||||
.arg("--sparse=never")
|
||||
.arg("--debug")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn test_cp_debug_sparse_never_empty_file_with_hole() {
|
||||
|
@ -4334,19 +4173,16 @@ fn test_cp_debug_sparse_never_empty_file_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=auto")
|
||||
.arg("--sparse=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: unknown, reflink: no, sparse detection: SEEK_HOLE") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: unknown, reflink: no, sparse detection: SEEK_HOLE");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn test_cp_debug_sparse_never_file_with_hole() {
|
||||
|
@ -4359,73 +4195,54 @@ fn test_cp_debug_sparse_never_file_with_hole() {
|
|||
.unwrap();
|
||||
f.set_len(10000).unwrap();
|
||||
at.append_bytes("a", "hello".as_bytes());
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=auto")
|
||||
.arg("--sparse=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_cp_debug_default_sparse_virtual_file() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("/sys/kernel/address_bits")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str
|
||||
.contains("copy offload: unsupported, reflink: unsupported, sparse detection: SEEK_HOLE")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains(
|
||||
"copy offload: unsupported, reflink: unsupported, sparse detection: SEEK_HOLE",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_cp_debug_sparse_never_zero_sized_virtual_file() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--sparse=never")
|
||||
.arg("/proc/version")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_cp_debug_default_zero_sized_virtual_file() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let result = ts
|
||||
.ucmd()
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("/proc/version")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: unsupported, reflink: unsupported, sparse detection: no")
|
||||
{
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: unsupported, reflink: unsupported, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4436,18 +4253,14 @@ fn test_cp_debug_reflink_never_without_hole() {
|
|||
let at = &ts.fixtures;
|
||||
at.write("a", "hello");
|
||||
at.append_bytes("a", &filler_bytes);
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--debug")
|
||||
.arg("--reflink=never")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
let stdout_str = result.stdout_str();
|
||||
if !stdout_str.contains("copy offload: avoided, reflink: no, sparse detection: no") {
|
||||
panic!("Failure: stdout was \n{stdout_str}");
|
||||
}
|
||||
.succeeds()
|
||||
.stdout_contains("copy offload: avoided, reflink: no, sparse detection: no");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue