From owner-dev-commits-src-all@freebsd.org Sat Aug 14 15:22:29 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 6180766EAA8; Sat, 14 Aug 2021 15:22:29 +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 4Gn4104G7Hz3wQq; Sat, 14 Aug 2021 15:22:28 +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 712B524991; Sat, 14 Aug 2021 15:22:28 +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 17EFMSA4029643; Sat, 14 Aug 2021 15:22:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EFMSpt029642; Sat, 14 Aug 2021 15:22:28 GMT (envelope-from git) Date: Sat, 14 Aug 2021 15:22:28 GMT Message-Id: <202108141522.17EFMSpt029642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 58b1a126b98f - main - 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/main X-Git-Reftype: branch X-Git-Commit: 58b1a126b98f9d64f30246c90d6c049fd78dda6b 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, 14 Aug 2021 15:22:29 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=58b1a126b98f9d64f30246c90d6c049fd78dda6b commit 58b1a126b98f9d64f30246c90d6c049fd78dda6b Author: Mark Johnston AuthorDate: 2021-07-05 15:01:41 +0000 Commit: Mark Johnston 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 }