Commit graph

116 commits

Author SHA1 Message Date
Daniel Hofstetter
b248b9d34c tail: disable some tests on Android 2023-05-27 08:02:03 +02:00
Joining7943
c6f6c87780 tests/tail: Change static global variables to const 2023-04-23 23:11:40 +02:00
Joining7943
20e32971dd tail/args: Fix parsing when -F is used together with --retry or --follow 2023-04-18 21:47:20 +02:00
Daniel Hofstetter
7a888da409 tests: remove all "extern crate" statements 2023-04-10 08:31:31 +02:00
Daniel Hofstetter
0140f4f7d0 tests: fix "unresolved import" warnings on Windows 2023-03-20 16:26:31 +01:00
Daniel Hofstetter
94aeba9854 tests: fix unused imports warnings on Windows 2023-03-20 16:06:56 +01:00
Daniel Hofstetter
6988eb7ec6 tests: expand wildcard imports 2023-03-20 15:32:35 +01:00
Joining7943
946aab37ed Cargo: Bump fundu version v0.3.0 -> v0.4.2. Adjust test in test_tail. 2023-03-12 15:37:44 +01:00
Benjamin Bara
9b49f368c7 tail: parse default before obsolete 2023-02-28 18:58:12 +01:00
Benjamin Bara
f6edea2d05 tail: enable non-utf8 paths 2023-02-28 18:58:12 +01:00
Benjamin Bara
dc34e89d50 tail: skip clap for obsolete args 2023-02-28 18:58:12 +01:00
Benjamin Bara
b83c30b12e tail: improve GNU compatibility 2023-02-28 18:58:12 +01:00
Joining7943
0ed6a9f882 tail: Fix parsing of sleep interval. Use duration parser from fundu crate.
Activate tests for parsing sleep interval
2023-02-12 20:23:55 +01:00
Joining7943
c809bb3888 tests/tail: Disable test_follow_with_pid on freebsd because of intermittent failures in the ci 2023-01-28 13:02:33 +01:00
Daniel Hofstetter
f6b646e4e5 clippy: fix warnings introduced with Rust 1.67.0 2023-01-27 17:37:56 +01:00
Joining7943
1fadeb43b2 tests/util: Do not trim stderr in CmdResult::stderr_is. Add method stderr_trimmed_is.
Fix tests assert whitespace instead of trimming it. Disable some tests in `test_tr` because `tr`
produces too many newlines.
2023-01-22 14:56:19 +01:00
Joining7943
463c58afd0 tests/tail: Remove redundant set_stdin(Stdio::null()) 2023-01-03 16:30:12 +01:00
Joining7943
9b35c5d5c1 tests/util: Use Stdio::null as default in UCommand for Child stdin instead of Stdio::piped 2023-01-03 16:30:08 +01:00
Joining7943
b339f6d80c tests/tail: Add all additional tests written during refactoring tail from tip of refactoring branch
Other changes summmary:
* Use module level imports instead of fully qualified imports where appropriate
* Fix intermittent failing test_positive_zero_bytes because of broken pipe
* Cleanup old disabled test for warning of following indefinitely
2022-12-13 16:16:14 +01:00
Joining7943
d57545d09c tail: Refactor: Handle warnings and early exits in one place. Remove InputService ...
Other changes summary:
* Cleanup imports
* Remove stdin_is_pipe_of_fifo function
* Rename WatcherService to Observer
2022-12-13 16:16:08 +01:00
Joining7943
4a2ced5940 tests: Adjust some tests to use improved UChild. test_tac: Ignore pipe tests on windows.
Summary:
* Disable test_retry6 on android because of intermittent failures
* Use wait() instead of wait_with_output in test_cat, test_cp, test_sort
* tests/sort: Simplify usage of test_sigpipe_panic
* Fix tests in test_tee.

tests/tac:
There was a change in the `tests/common/util.rs` test api concerning piped input which may have
revealed a bug in the implementation of tac. Please see also
https://github.com/uutils/coreutils/pull/4136
2022-12-02 13:13:10 +01:00
Joining7943
4f54eedb74 tests/util: Improve UChild. Cleanup redundant functions in util.rs.
A short summary of changes:

* Add some basic tests for UChild and the run methods.
* Try more often in a fixed interval to create the tempfile for CapturedOutput.
* Fix drop order of struct fields for better cleanup of temporary files/dirs.
* Mark UChild::wait_with_output and UChild::pipe_in_and_wait_with_output deprecated
* Make CapturedOutput private
* Panic in stdout_all, stdout_all_bytes etc. if output is not captured.
* Rename some methods, refactor, clean up, fix documentation, add try_... methods
2022-12-02 08:06:48 +01:00
Joining7943
982fb682e9 tests: Use UChild in tests. Rename run_no_wait_child to run_no_wait and return UChild
tests/tail:
* test_stdin_redirect_file:. Test fails now when assert_alive()!
The follow test `tail -f < file` where file's content is `foo` fails with:
    Assertion failed. Expected 'tail' to be running but exited with status=exit status: 0

I also tried on the command line and can confirm that tail isn't runnning when following by
descriptor. The test is deactivated until the implementation is fixed.

* test_follow_stdin_descriptor
* test_follow_stdin_explicit_indefinitely.
* test_follow_single
* test_follow_non_utf8_bytes
* test_follow_multiple
* test_follow_name_multiple
* test_follow_invalid_pid
* test_single_big_args
* test_retry3
* test_retry4
* test_retry5
* test_retry7
* test_retry8
* test_retry9
* test_follow_descriptor_vs_rename1
* test_follow_descriptor_vs_rename2
* test_follow_name_retry_headers
* test_follow_name_remove
* test_follow_name_truncate1
* test_follow_name_truncate2
* test_follow_name_truncate3
* test_follow_name_truncate4
* test_follow_truncate_fast
* test_follow_name_move_create1
* test_follow_name_move_create2
* test_follow_name_move1
* test_follow_name_move2
* test_follow_name_move_retry1
* test_follow_name_move_retry2
* test_follow_inotify_only_regular
* test_fifo
* test_illegal_seek

tests/cat:
* test_dev_full
* test_dev_full_show_all
* test_dev_random
* test_fifo_symlink

tests/dd:
* test_random_73k_test_lazy_fullblock
* test_sync_delayed_reader

tests/factor:
* test_parallel

tests/rm:
* test_rm_force_prompts_order
* test_rm_descend_directory
* test_rm_prompts

tests/seq:
* the helper run method

tests/sort:
* test_sigpipe_panic

tests/tee:
* the helper run_tee method

tests/tty:
* test_tty module

tests/yes:
* the helper run method
2022-12-02 08:06:45 +01:00
Joining7943
040a5e8301 tests/util: Implement UChild. UCommand: implement stderr_to_stdout, capture output as default
See pr #4136 (https://github.com/uutils/coreutils/pull/4136)
2022-12-02 08:05:05 +01:00
Joining7943
9b446bf261 tests/tail: Fix clippy warning same-item-push. Do not push same flag twice. 2022-12-02 08:05:05 +01:00
Daniel Hofstetter
9a2174ba02 chore: standardize creation of empty strings 2022-12-01 13:49:23 +01:00
Joining7943
1725151ef8 tests/tail: Fix tests to reflect changes from the refactoring #3905 2022-10-05 13:32:35 +02:00
Joining7943
c32d61dcfb tests/tail: Add system tests for ---presume-input-pipe 2022-09-21 16:39:52 +02:00
Joining7943
951c51e740 tail: large refactoring and cleanup of the tail code base. See also #3905 for details 2022-09-13 22:54:36 +02:00
Terts Diepraam
9177cb7b24 all: add tests for usage error exit code 2022-09-10 20:59:42 +02:00
Joining7943
2658f8ae5b tail: improve performance of piped stdin
Rewrite handling of stdin when it is piped and read input in chunks.

Fixes https://github.com/uutils/coreutils/issues/3842
2022-09-09 13:51:37 +02:00
Jan Scheer
88d3aee71c tail: fix offset for stdin redirect if multiple input files 2022-09-05 10:09:04 +02:00
Jan Scheer
74f359bd76 tail: use same-file crate to get a handle of stdin redirected file 2022-09-05 10:09:04 +02:00
Jan Scheer
942928b0ea tail: fix stdin redirect when file is not at its beginning
Previously, if stdin redirect pointed to a regular file,
tailing started at the beginning of the file. However,
tailing needs to start at the current position because this
is expected by tests/tail-2/start-middle.sh.

This fixes the issue by taking the current offset into account
while going backwards through the stdin redirected file.
2022-09-05 10:09:04 +02:00
Jan Scheer
92c3f60440 tail: fix stdin redirect (#3842)
This fixes a bug where calling `tail - < file.txt` would result
in invoking `unbounded_tail()`.
However, it is a stdin redirect to a seekable regular file and
therefore `bounded_tail` should be invoked as if `tail file.txt` had
been called.
2022-09-05 10:09:04 +02:00
Tavo Annus
09cfa44560 Fix tail panicing when seeking backwards
Previously `tail -c n file.txt` caused panic if n > sizeof file.txt.
Now it prints out whole file similarly to GNU tail.
2022-08-24 21:02:47 +03:00
Jan Scheer
391709c911
tests: ignore failing tests for FreeBSD (#3778) 2022-08-13 10:09:05 +02:00
Niyaz Nigmatullin
04df57ebd4 test/tail: ignore pipe errors when tail -n 0, since it doesn't read
anything
2022-08-08 22:29:53 +03:00
Jan Scheer
0555745052
tests: fix Freebsd test failures 2022-08-05 08:04:25 +02:00
Jan Scheer
75edeea5e4
tail: reduce CPU load for polling (#3618)
* tail: reduce CPU load for polling

This reduces the CPU load for polling drastically (from ~80% down to ~5%)
by removing/fixing several previous workarounds related to polling,
while still passing all related GNU test-suite checks.
* set Notify::PollWatcher delay to: sleep_sec/10 instead of
  sleep_sec/100
* set recv_timeout to sleep_sec instead of sleep_sec/100
* remove the manual polling of watched files

Bugs:
* fix an issue with headers to consistently pass
"test_follow_name_retry_headers" and "gnu/tests/tail-2/overlay-headers.sh"

Code clean-up and refactor
* make fields of struct FileHandling private (and add getters/setters)
to ensure that the paths are absolute and match the paths returned by
Notify::Events
* replace calls to "crash!" with "return USimpleError"
* clean-up formatting
2022-06-21 22:21:19 +02:00
Jan Scheer
435984713a
test_tail: increase delay for test_follow_name_move_create2
Increase delay for this test to be more resillient against
load-jitter on the CI test VMs.
2022-06-09 23:44:37 +02:00
Jan Scheer
e8834597f3
Merge branch 'main' into tail_notify 2022-06-06 16:00:46 +02:00
Jan Scheer
beb2b7cf5e
tail: use functionality from uucore::error where applicable
* minor code clean-up
* remove test-suite summary from README
2022-06-06 14:36:51 +02:00
Jan Scheer
e0efd6cc90
tail: update readme
* add clippy fixes
* add cicd fixes
2022-06-03 13:35:58 +02:00
Jan Scheer
94fe42634b
test_tail: a lot of minor improvements
* fix test_retry7
* fix test_follow_descriptor_vs_rename2
* set permissions with set_permissions instead of a call to chmod
* improve documentation
2022-06-02 17:03:49 +02:00
Jan Scheer
2e918813c1
test_tail: add test_follow_name_move_create2 2022-06-02 17:01:22 +02:00
Jan Scheer
42fa386d89
test_tail: add test_follow_truncate_fast 2022-06-02 16:56:09 +02:00
Jan Scheer
f3aacac9d8
test_tail: add test_follow_name_truncate4 2022-06-02 16:55:04 +02:00
Jan Scheer
bb5dc8bd2f
tail: verify that -[nc]0 without -f, exit without reading
This passes: "gnu/tests/tail-2/tail-n0f.sh"

* add tests for "-[nc]0 wo -f"

* add bubble-up UResult
* rename return_code -> exit_code
2022-05-27 23:36:31 +02:00
Jan Scheer
4bbf708c81
tail: fix handling of PermissionDenied Error
* add tests for opening unreadable files
2022-05-26 13:00:40 +02:00