From f21a4e3c1d0a2dd8241f4b29352abe8105ac0e2a Mon Sep 17 00:00:00 2001 From: Jan Scheer Date: Fri, 12 Aug 2022 23:51:28 +0200 Subject: [PATCH] tests: fix tests for FreeBSD (#3778) --- tests/by-util/test_cp.rs | 6 +++++- tests/by-util/test_df.rs | 9 ++++++++- tests/by-util/test_ls.rs | 15 ++++++++++++++- tests/by-util/test_stat.rs | 4 ++-- tests/by-util/test_tail.rs | 16 ++++++++-------- tests/by-util/test_test.rs | 2 +- tests/by-util/test_touch.rs | 1 + 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index fa53969d1c0..85271e669aa 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -9,7 +9,7 @@ use std::os::unix::fs; #[cfg(unix)] use std::os::unix::fs::symlink as symlink_file; -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "freebsd")))] use std::os::unix::fs::MetadataExt; #[cfg(all(unix, not(target_os = "freebsd")))] use std::os::unix::fs::PermissionsExt; @@ -22,7 +22,9 @@ use filetime::FileTime; use rlimit::Resource; #[cfg(any(target_os = "linux", target_os = "android"))] use std::fs as std_fs; +#[cfg(not(target_os = "freebsd"))] use std::thread::sleep; +#[cfg(not(target_os = "freebsd"))] use std::time::Duration; use uucore::display::Quotable; @@ -1581,6 +1583,7 @@ fn test_copy_dir_symlink() { } #[test] +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD fn test_copy_dir_with_symlinks() { let (at, mut ucmd) = at_and_ucmd!(); at.mkdir("dir"); @@ -1725,6 +1728,7 @@ fn test_copy_through_dangling_symlink_no_dereference() { } /// Test for copying a dangling symbolic link and its permissions. +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD #[test] fn test_copy_through_dangling_symlink_no_dereference_permissions() { let (at, mut ucmd) = at_and_ucmd!(); diff --git a/tests/by-util/test_df.rs b/tests/by-util/test_df.rs index 13cfdcef4c8..76df27b58d4 100644 --- a/tests/by-util/test_df.rs +++ b/tests/by-util/test_df.rs @@ -180,6 +180,7 @@ fn test_precedence_of_human_readable_header_over_output_header() { } #[test] +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD fn test_total_option_with_single_dash() { // These should fail because `-total` should have two dashes, // not just one. @@ -201,7 +202,7 @@ fn test_order_same() { } /// Test of mount point begin repeated -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "freebsd")))] // FIXME: fix this test for FreeBSD #[test] fn test_output_mp_repeat() { let output1 = new_ucmd!().arg("/").arg("/").succeeds().stdout_move_str(); @@ -228,6 +229,7 @@ fn test_output_option() { } #[test] +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD fn test_output_option_without_equals_sign() { new_ucmd!().arg("--output").arg(".").succeeds(); } @@ -251,6 +253,7 @@ fn test_type_option() { } #[test] +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD fn test_type_option_with_file() { let fs_type = new_ucmd!() .args(&["--output=fstype", "."]) @@ -369,6 +372,7 @@ fn test_total() { /// /// The "total" label should appear in the "source" column, or in the /// "target" column if "source" is not visible. +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD #[test] fn test_total_label_in_correct_column() { let output = new_ucmd!() @@ -797,6 +801,7 @@ fn test_output_file_all_filesystems() { } #[test] +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD fn test_output_file_specific_files() { // Create three files. let (at, mut ucmd) = at_and_ucmd!(); @@ -815,6 +820,7 @@ fn test_output_file_specific_files() { } #[test] +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD fn test_file_column_width_if_filename_contains_unicode_chars() { let (at, mut ucmd) = at_and_ucmd!(); at.touch("äöü.txt"); @@ -837,6 +843,7 @@ fn test_output_field_no_more_than_once() { } #[test] +#[cfg(not(target_os = "freebsd"))] // FIXME: fix this test for FreeBSD fn test_nonexistent_file() { new_ucmd!() .arg("does-not-exist") diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index f1f139387cc..a85e25c3b75 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -73,7 +73,7 @@ fn test_ls_ordering() { } #[cfg(all(feature = "truncate", feature = "dd"))] -#[test] +#[test] // FIXME: fix this test for FreeBSD fn test_ls_allocation_size() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; @@ -114,6 +114,7 @@ fn test_ls_allocation_size() { .succeeds() .stdout_matches(&Regex::new("[^ ] 2 [^ ]").unwrap()); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .arg("-s1") @@ -129,6 +130,7 @@ fn test_ls_allocation_size() { // block size is 0 whereas size/len is 4194304 .stdout_contains("4194304"); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .arg("-s1") @@ -162,6 +164,7 @@ fn test_ls_allocation_size() { assert_eq!(empty_file_len, file_with_holes_len); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .env("LS_BLOCK_SIZE", "8K") @@ -174,6 +177,7 @@ fn test_ls_allocation_size() { .stdout_contains("0 file-with-holes") .stdout_contains("512 zero-file"); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .env("BLOCK_SIZE", "4K") @@ -185,6 +189,7 @@ fn test_ls_allocation_size() { .stdout_contains("0 file-with-holes") .stdout_contains("1024 zero-file"); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .env("BLOCK_SIZE", "4K") @@ -197,6 +202,7 @@ fn test_ls_allocation_size() { .stdout_contains("0 file-with-holes") .stdout_contains("4.2M zero-file"); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .env("BLOCK_SIZE", "4096") @@ -208,6 +214,7 @@ fn test_ls_allocation_size() { .stdout_contains("0 file-with-holes") .stdout_contains("1024 zero-file"); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .env("POSIXLY_CORRECT", "true") @@ -220,6 +227,7 @@ fn test_ls_allocation_size() { .stdout_contains("8192 zero-file"); // -k should make 'ls' ignore the env var + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .env("BLOCK_SIZE", "4K") @@ -232,6 +240,7 @@ fn test_ls_allocation_size() { .stdout_contains("4096 zero-file"); // but manually specified blocksize overrides -k + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .arg("-s1k") @@ -243,6 +252,7 @@ fn test_ls_allocation_size() { .stdout_contains("0 file-with-holes") .stdout_contains("1024 zero-file"); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .arg("-s1") @@ -255,6 +265,7 @@ fn test_ls_allocation_size() { .stdout_contains("1024 zero-file"); // si option should always trump the human-readable option + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .arg("-s1h") @@ -266,6 +277,7 @@ fn test_ls_allocation_size() { .stdout_contains("0 file-with-holes") .stdout_contains("4.2M zero-file"); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .arg("-s1") @@ -277,6 +289,7 @@ fn test_ls_allocation_size() { .stdout_contains("0 file-with-holes") .stdout_contains("4.0M zero-file"); + #[cfg(not(target_os = "freebsd"))] scene .ucmd() .arg("-s1") diff --git a/tests/by-util/test_stat.rs b/tests/by-util/test_stat.rs index 68185046707..2a69fa88eab 100644 --- a/tests/by-util/test_stat.rs +++ b/tests/by-util/test_stat.rs @@ -360,7 +360,7 @@ fn test_pipe_fifo() { } #[test] -#[cfg(all(unix, not(target_os = "android")))] +#[cfg(all(unix, not(any(target_os = "android", target_os = "freebsd"))))] fn test_stdin_pipe_fifo1() { // $ echo | stat - // File: - @@ -400,7 +400,7 @@ fn test_stdin_pipe_fifo2() { } #[test] -#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))] +#[cfg(all(unix, not(any(target_os = "android", target_os = "macos", target_os = "freebsd"))))] fn test_stdin_redirect() { // $ touch f && stat - < f // File: - diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index 4c227a4a7f0..d4755a48832 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -211,7 +211,7 @@ fn test_follow_redirect_stdin_name_retry() { } #[test] -#[cfg(all(unix, not(target_os = "android")))] // FIXME: fix this test for Android +#[cfg(all(unix, not(any(target_os = "android", target_os = "freebsd"))))] // FIXME: fix this test for Android/FreeBSD fn test_stdin_redirect_dir() { // $ mkdir dir // $ tail < dir, $ tail - < dir @@ -1913,7 +1913,7 @@ fn test_follow_truncate_fast() { } #[test] -#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux +#[cfg(target_os = "linux")] // FIXME: make this work not just on Linux fn test_follow_name_move_create1() { // This test triggers a move/create event while `tail --follow=name file` is running. // ((sleep 2 && mv file backup && sleep 2 && cp backup file &)>/dev/null 2>&1 &) ; tail --follow=name file @@ -1958,7 +1958,7 @@ fn test_follow_name_move_create1() { } #[test] -#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux +#[cfg(target_os = "linux")] // FIXME: make this work not just on Linux fn test_follow_name_move_create2() { // inspired by: "gnu/tests/tail-2/inotify-hash-abuse.sh" // Exercise an abort-inducing flaw in inotify-enabled tail -F @@ -2029,7 +2029,7 @@ fn test_follow_name_move_create2() { } #[test] -#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux +#[cfg(target_os = "linux")] // FIXME: make this work not just on Linux fn test_follow_name_move1() { // This test triggers a move event while `tail --follow=name file` is running. // ((sleep 2 && mv file backup &)>/dev/null 2>&1 &) ; tail --follow=name file @@ -2074,7 +2074,7 @@ fn test_follow_name_move1() { } #[test] -#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux +#[cfg(target_os = "linux")] // FIXME: make this work not just on Linux fn test_follow_name_move2() { // Like test_follow_name_move1, but move to a name that's already monitored. @@ -2155,7 +2155,7 @@ fn test_follow_name_move2() { } #[test] -#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux +#[cfg(target_os = "linux")] // FIXME: make this work not just on Linux fn test_follow_name_move_retry1() { // Similar to test_follow_name_move1 but with `--retry` (`-F`) // This test triggers two move/rename events while `tail --follow=name --retry file` is running. @@ -2206,7 +2206,7 @@ fn test_follow_name_move_retry1() { } } #[test] -#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux +#[cfg(target_os = "linux")] // FIXME: make this work not just on Linux fn test_follow_name_move_retry2() { // inspired by: "gnu/tests/tail-2/F-vs-rename.sh" // Similar to test_follow_name_move2 (move to a name that's already monitored) @@ -2304,7 +2304,7 @@ fn test_follow_name_move_retry2() { } #[test] -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "freebsd")))] // FIXME: fix this test for FreeBSD fn test_follow_inotify_only_regular() { // The GNU test inotify-only-regular.sh uses strace to ensure that `tail -f` // doesn't make inotify syscalls and only uses inotify for regular files or fifos. diff --git a/tests/by-util/test_test.rs b/tests/by-util/test_test.rs index 8500d63ed22..3d74dfa90a6 100644 --- a/tests/by-util/test_test.rs +++ b/tests/by-util/test_test.rs @@ -667,7 +667,7 @@ fn test_file_not_owned_by_euid() { } #[test] -#[cfg(not(windows))] +#[cfg(all(not(windows), not(target_os = "freebsd")))] fn test_file_owned_by_egid() { new_ucmd!().args(&["-G", "regular_file"]).succeeds(); } diff --git a/tests/by-util/test_touch.rs b/tests/by-util/test_touch.rs index 7a70b556eae..bdef1e1e54c 100644 --- a/tests/by-util/test_touch.rs +++ b/tests/by-util/test_touch.rs @@ -621,6 +621,7 @@ fn test_touch_no_such_file_error_msg() { } #[test] +#[cfg(not(target_os = "freebsd"))] fn test_touch_changes_time_of_file_in_stdout() { // command like: `touch - 1< ./c` // should change the timestamp of c