From owner-dev-commits-src-all@freebsd.org Sat Aug 21 17:59:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 89E156762DD; Sat, 21 Aug 2021 17:59:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GsR8f3D2Cz4Vsw; Sat, 21 Aug 2021 17:59:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 474DF11852; Sat, 21 Aug 2021 17:59:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17LHxEXm008131; Sat, 21 Aug 2021 17:59:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17LHxECd008130; Sat, 21 Aug 2021 17:59:14 GMT (envelope-from git) Date: Sat, 21 Aug 2021 17:59:14 GMT Message-Id: <202108211759.17LHxECd008130@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 4c6246b76ed9 - stable/13 - tail: Add regression tests for -f and -F MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4c6246b76ed951680d6b9491fbb9497160a4ca16 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Aug 2021 17:59:14 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4c6246b76ed951680d6b9491fbb9497160a4ca16 commit 4c6246b76ed951680d6b9491fbb9497160a4ca16 Author: Mark Johnston AuthorDate: 2021-07-05 15:01:41 +0000 Commit: Mark Johnston CommitDate: 2021-08-21 16:18:21 +0000 tail: Add regression tests for -f and -F Sponsored by: The FreeBSD Foundation (cherry picked from commit 58b1a126b98f9d64f30246c90d6c049fd78dda6b) --- 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 }