Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,20 +1057,30 @@ fn test_cp_reflink_always_failure_dest_cleanup() {

#[test]
#[cfg(target_os = "linux")]
fn test_cp_reflink_always_failure() {
fn test_cp_reflink_always_invalid_argument() {

@oech3 oech3 Aug 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly disagree with separating 2 tests at least for. Because 2 test cases are exactly coming from same code path (thus, same logic).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just drop test for cross device.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it really matter ? :)
tests are cheap

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just need to check that os errno is extracted at here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests should be as small as possible, but no smaller :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still disagree with separating 2 tests at least for.

let scene = TestScenario::new(util_name!());
scene
.ucmd()
.args(&["--reflink=always", "/dev/null", "/dev/full"])
.fails()
.no_stdout()
.stderr_contains("Invalid argument");
}

#[test]
#[cfg(target_os = "linux")]
fn test_cp_reflink_always_cross_device() {
let scene = TestScenario::new(util_name!());
scene
.ucmd()
.args(&["--reflink=always", "/dev/null", "target"])
.fails()
.no_stdout()
.stderr_contains("ross-device link"); // cover both of glibc and musl
.stderr_contains(if cfg!(target_env = "musl") {
"'target': Cross-device link"
} else {
"Invalid cross-device link"
});
}

#[test]
Expand Down
Loading