Date: Sat, 14 Aug 2021 15:22:28 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 58b1a126b98f - main - tail: Add regression tests for -f and -F Message-ID: <202108141522.17EFMSpt029642@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=58b1a126b98f9d64f30246c90d6c049fd78dda6b commit 58b1a126b98f9d64f30246c90d6c049fd78dda6b Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-07-05 15:01:41 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-08-14 15:19:42 +0000 tail: Add regression tests for -f and -F MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31055 --- usr.bin/tail/tests/tail_test.sh | 83 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/usr.bin/tail/tests/tail_test.sh b/usr.bin/tail/tests/tail_test.sh index 9eecf460d1e5..66d435f2cd02 100755 --- a/usr.bin/tail/tests/tail_test.sh +++ b/usr.bin/tail/tests/tail_test.sh @@ -272,6 +272,85 @@ broken_pipe_body() -x '(tail -n 856 ints; echo exit code: $? >&2) | sleep 2' } +atf_test_case stdin +stdin_head() +{ + atf_set "descr" "Check basic operations on standard input" +} +stdin_body() +{ + seq 1 5 > infile + seq 1 5 > expectfile + seq 5 1 > expectfile_r + + tail < infile > outfile + tail -r < infile > outfile_r + + atf_check cmp expectfile outfile + atf_check cmp expectfile_r outfile_r +} + +atf_test_case follow +follow_head() +{ + atf_set "descr" "Basic regression test for -f" +} +follow_body() +{ + local pid + + seq 1 5 > expectfile + seq 1 3 > infile + tail -f infile > outfile & + pid=$! + sleep 0.1 + seq 4 5 >> infile + sleep 0.1 + atf_check cmp expectfile outfile + atf_check kill $pid +} + +atf_test_case follow_stdin +follow_stdin_head() +{ + atf_set "descr" "Verify that -f works with files piped to standard input" +} +follow_stdin_body() +{ + local pid + + seq 1 5 > expectfile + seq 1 3 > infile + tail -f < infile > outfile & + pid=$! + sleep 0.1 + seq 4 5 >> infile + sleep 0.1 + atf_check cmp expectfile outfile + atf_check kill $pid +} + +atf_test_case follow_rename +follow_rename_head() +{ + atf_set "descr" "Verify that -F works" +} +follow_rename_body() +{ + local pid + + seq 1 5 > expectfile + seq 1 3 > infile + tail -F infile > outfile & + pid=$! + seq 4 5 > infile_new + atf_check mv infile infile_old + atf_check mv infile_new infile + # tail -F polls for a new file every 1s. + sleep 2 + atf_check cmp expectfile outfile + atf_check kill $pid +} atf_init_test_cases() { @@ -289,4 +368,8 @@ atf_init_test_cases() atf_add_test_case longfile_rc145782_longlines atf_add_test_case longfile_rn2500 atf_add_test_case broken_pipe + atf_add_test_case stdin + atf_add_test_case follow + atf_add_test_case follow_stdin + atf_add_test_case follow_rename }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108141522.17EFMSpt029642>