mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #6076 from cre4ture/fix/test_ls_with_f2fs
fix `ls`: test_ls_allocation_size fails on filesystem `f2fs` (android)
This commit is contained in:
commit
c13ebe5e26
4 changed files with 54 additions and 24 deletions
2
.github/workflows/android.yml
vendored
2
.github/workflows/android.yml
vendored
|
@ -19,7 +19,7 @@ concurrency:
|
|||
|
||||
env:
|
||||
TERMUX: v0.118.0
|
||||
KEY_POSTFIX: nextest+rustc-hash+adb+sshd+upgrade+XGB+inc17
|
||||
KEY_POSTFIX: nextest+rustc-hash+adb+sshd+upgrade+XGB+inc18
|
||||
COMMON_EMULATOR_OPTIONS: -no-window -noaudio -no-boot-anim -camera-back none -gpu swiftshader_indirect
|
||||
EMULATOR_DISK_SIZE: 12GB
|
||||
EMULATOR_HEAP_SIZE: 2048M
|
||||
|
|
|
@ -73,6 +73,21 @@ fn test_ls_ordering() {
|
|||
.stdout_matches(&Regex::new("some-dir1:\\ntotal 0").unwrap());
|
||||
}
|
||||
|
||||
#[cfg(all(unix, feature = "df", not(target_os = "freebsd")))]
|
||||
fn get_filesystem_type(scene: &TestScenario, path: &Path) -> String {
|
||||
let mut cmd = scene.ccmd("df");
|
||||
cmd.args(&["-PT"]).arg(path);
|
||||
let output = cmd.succeeds();
|
||||
let stdout_str = String::from_utf8_lossy(output.stdout());
|
||||
println!("output of stat call ({:?}):\n{}", cmd, stdout_str);
|
||||
let regex_str = r#"Filesystem\s+Type\s+.+[\r\n]+([^\s]+)\s+(?<fstype>[^\s]+)\s+"#;
|
||||
let regex = Regex::new(regex_str).unwrap();
|
||||
let m = regex.captures(&stdout_str).unwrap();
|
||||
let fstype = m["fstype"].to_owned();
|
||||
println!("detected fstype: {}", fstype);
|
||||
fstype
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "truncate", feature = "dd"))]
|
||||
#[test] // FIXME: fix this test for FreeBSD
|
||||
fn test_ls_allocation_size() {
|
||||
|
@ -81,7 +96,7 @@ fn test_ls_allocation_size() {
|
|||
at.mkdir("some-dir1");
|
||||
at.touch("some-dir1/empty-file");
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(all(unix, feature = "df"))]
|
||||
{
|
||||
scene
|
||||
.ccmd("truncate")
|
||||
|
@ -115,13 +130,24 @@ fn test_ls_allocation_size() {
|
|||
.succeeds()
|
||||
.stdout_matches(&Regex::new("[^ ] 2 [^ ]").unwrap());
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
let (zero_file_size_4k, zero_file_size_1k, zero_file_size_8k, zero_file_size_4m) =
|
||||
match get_filesystem_type(&scene, &scene.fixtures.subdir).as_str() {
|
||||
// apparently f2fs (flash friendly fs) accepts small overhead for better performance
|
||||
"f2fs" => (4100, 1025, 8200, "4.1M"),
|
||||
_ => (4096, 1024, 8192, "4.0M"),
|
||||
};
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-s1")
|
||||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_is("total 4096\n 0 empty-file\n 0 file-with-holes\n4096 zero-file\n");
|
||||
.stdout_is(format!(
|
||||
"total {zero_file_size_4k}\n 0 empty-file\n 0 file-with-holes\n\
|
||||
{zero_file_size_4k} zero-file\n"
|
||||
));
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -138,7 +164,7 @@ fn test_ls_allocation_size() {
|
|||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_contains("0 empty-file")
|
||||
.stdout_contains("4096 zero-file");
|
||||
.stdout_contains(format!("{zero_file_size_4k} zero-file"));
|
||||
|
||||
// Test alignment of different block sized files
|
||||
let res = scene.ucmd().arg("-si1").arg("some-dir1").succeeds();
|
||||
|
@ -185,10 +211,10 @@ fn test_ls_allocation_size() {
|
|||
.arg("-s1")
|
||||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_contains("total 1024")
|
||||
.stdout_contains(format!("total {zero_file_size_1k}"))
|
||||
.stdout_contains("0 empty-file")
|
||||
.stdout_contains("0 file-with-holes")
|
||||
.stdout_contains("1024 zero-file");
|
||||
.stdout_contains(format!("{zero_file_size_1k} zero-file"));
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
scene
|
||||
|
@ -210,10 +236,10 @@ fn test_ls_allocation_size() {
|
|||
.arg("-s1")
|
||||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_contains("total 1024")
|
||||
.stdout_contains(format!("total {zero_file_size_1k}"))
|
||||
.stdout_contains("0 empty-file")
|
||||
.stdout_contains("0 file-with-holes")
|
||||
.stdout_contains("1024 zero-file");
|
||||
.stdout_contains(format!("{zero_file_size_1k} zero-file"));
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
scene
|
||||
|
@ -222,10 +248,10 @@ fn test_ls_allocation_size() {
|
|||
.arg("-s1")
|
||||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_contains("total 8192")
|
||||
.stdout_contains(format!("total {zero_file_size_8k}"))
|
||||
.stdout_contains("0 empty-file")
|
||||
.stdout_contains("0 file-with-holes")
|
||||
.stdout_contains("8192 zero-file");
|
||||
.stdout_contains(format!("{zero_file_size_8k} zero-file"));
|
||||
|
||||
// -k should make 'ls' ignore the env var
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
|
@ -235,10 +261,10 @@ fn test_ls_allocation_size() {
|
|||
.arg("-s1k")
|
||||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_contains("total 4096")
|
||||
.stdout_contains(format!("total {zero_file_size_4k}"))
|
||||
.stdout_contains("0 empty-file")
|
||||
.stdout_contains("0 file-with-holes")
|
||||
.stdout_contains("4096 zero-file");
|
||||
.stdout_contains(format!("{zero_file_size_4k} zero-file"));
|
||||
|
||||
// but manually specified blocksize overrides -k
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
|
@ -248,10 +274,10 @@ fn test_ls_allocation_size() {
|
|||
.arg("--block-size=4K")
|
||||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_contains("total 1024")
|
||||
.stdout_contains(format!("total {zero_file_size_1k}"))
|
||||
.stdout_contains("0 empty-file")
|
||||
.stdout_contains("0 file-with-holes")
|
||||
.stdout_contains("1024 zero-file");
|
||||
.stdout_contains(format!("{zero_file_size_1k} zero-file"));
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
scene
|
||||
|
@ -260,10 +286,10 @@ fn test_ls_allocation_size() {
|
|||
.arg("--block-size=4K")
|
||||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_contains("total 1024")
|
||||
.stdout_contains(format!("total {zero_file_size_1k}"))
|
||||
.stdout_contains("0 empty-file")
|
||||
.stdout_contains("0 file-with-holes")
|
||||
.stdout_contains("1024 zero-file");
|
||||
.stdout_contains(format!("{zero_file_size_1k} zero-file"));
|
||||
|
||||
// si option should always trump the human-readable option
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
|
@ -285,10 +311,10 @@ fn test_ls_allocation_size() {
|
|||
.arg("--block-size=human-readable")
|
||||
.arg("some-dir1")
|
||||
.succeeds()
|
||||
.stdout_contains("total 4.0M")
|
||||
.stdout_contains(format!("total {zero_file_size_4m}"))
|
||||
.stdout_contains("0 empty-file")
|
||||
.stdout_contains("0 file-with-holes")
|
||||
.stdout_contains("4.0M zero-file");
|
||||
.stdout_contains(format!("{zero_file_size_4m} zero-file"));
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
scene
|
||||
|
|
|
@ -371,7 +371,6 @@ run_command_via_ssh() {
|
|||
|
||||
test_ssh_connection() {
|
||||
run_command_via_ssh echo ssh connection is working
|
||||
run_command_via_ssh free -mh
|
||||
}
|
||||
|
||||
# takes a local (on runner side) script file and runs it via ssh on the virtual android device. forwards return code.
|
||||
|
@ -509,7 +508,7 @@ snapshot() {
|
|||
|
||||
apt_upgrade_all_packages
|
||||
|
||||
install_packages_via_ssh_using_apt "rust binutils openssl tar"
|
||||
install_packages_via_ssh_using_apt "rust binutils openssl tar mount-utils"
|
||||
|
||||
echo "Read /proc/cpuinfo"
|
||||
run_command_via_ssh "cat /proc/cpuinfo"
|
||||
|
@ -573,8 +572,7 @@ build() {
|
|||
|
||||
reinit_ssh_connection
|
||||
|
||||
echo "Read /proc/cpuinfo"
|
||||
run_command_via_ssh "cat /proc/cpuinfo"
|
||||
run_script_file_via_ssh "$this_repo/util/android-scripts/collect-info.sh"
|
||||
|
||||
command="export CARGO_TERM_COLOR=always;
|
||||
export CARGO_INCREMENTAL=0; \
|
||||
|
@ -589,8 +587,7 @@ tests() {
|
|||
|
||||
reinit_ssh_connection
|
||||
|
||||
echo "Read /proc/cpuinfo"
|
||||
run_command_via_ssh "cat /proc/cpuinfo"
|
||||
run_script_file_via_ssh "$this_repo/util/android-scripts/collect-info.sh"
|
||||
|
||||
run_script_file_via_ssh "$this_repo/util/android-scripts/run-tests.sh" || return
|
||||
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
# spell-checker:ignore nextest watchplus PIPESTATUS
|
||||
|
||||
echo "system resources - RAM:"
|
||||
free -hm
|
||||
echo "system resources - CPU:"
|
||||
lscpu
|
||||
echo "system resources - file systems:"
|
||||
mount
|
||||
|
||||
echo "$HOME"
|
||||
PATH=$HOME/.cargo/bin:$PATH
|
||||
export PATH
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue