From 95a990ae02d04b6c339d2fb5b81e482361fa6eac Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:52:34 +0900 Subject: [PATCH] test_install.rs: test for ficlone (reflink) --- .../cspell.dictionaries/workspace.wordlist.txt | 1 + tests/by-util/test_install.rs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.vscode/cspell.dictionaries/workspace.wordlist.txt b/.vscode/cspell.dictionaries/workspace.wordlist.txt index fcacd8d78d1..9342d593438 100644 --- a/.vscode/cspell.dictionaries/workspace.wordlist.txt +++ b/.vscode/cspell.dictionaries/workspace.wordlist.txt @@ -371,6 +371,7 @@ setpipe # * other auxv +btrfs getlimits weblate algs diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index 949c67b9896..8156fac9641 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -35,7 +35,7 @@ fn test_invalid_arg() { } #[test] -fn test_install_basic() { +fn test_install_basic_try_reflink() { let (at, mut ucmd) = at_and_ucmd!(); let dir = "target_dir"; let file1 = "source_file1"; @@ -44,7 +44,23 @@ fn test_install_basic() { at.touch(file1); at.touch(file2); at.mkdir(dir); + #[cfg(not(target_os = "linux"))] ucmd.arg(file1).arg(file2).arg(dir).succeeds().no_stderr(); + // mkfs.btrfs needs root. use strace instead. + #[cfg(target_os = "linux")] + if process::Command::new("strace") + .args(["-qqq", "-o", "strace.out", "-e", "trace=ioctl"]) + .arg(uutests::util::get_tests_binary()) + .args(["install", file1, file2, dir]) + .current_dir(at.as_string()) + .output() + .is_ok() + { + assert!(at.read("strace.out").contains("FICLONE")); + } else { + // missing strace + ucmd.arg(file1).arg(file2).arg(dir).succeeds().no_stderr(); + } assert!(at.file_exists(file1)); assert!(at.file_exists(file2));