git: e437440b7aa4 - stable/14 - uniq tests: Make uniq_test:stdout more reliable

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 27 Jun 2024 15:31:18 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=e437440b7aa4a9f36d2219fc32cb6bd60d118dd6

commit e437440b7aa4a9f36d2219fc32cb6bd60d118dd6
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-06-14 00:00:47 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-27 15:27:42 +0000

    uniq tests: Make uniq_test:stdout more reliable
    
    When running regression tests in paralle, this one occasionally fails
    because uniq exits with status 0.  I believe this is because the test is
    a bit racy: it assumes that true(1) will exit before uniq writes to
    standard out.
    
    Just sleep for a bit to give the other end of the pipe to exit.
    
    Reviewed by:    des
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D45534
    
    (cherry picked from commit d9220f64da8b1d55b15259e8b266b50371ed4f47)
---
 usr.bin/uniq/tests/uniq_test.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/usr.bin/uniq/tests/uniq_test.sh b/usr.bin/uniq/tests/uniq_test.sh
index 804e82ce7766..9d37245dee4e 100755
--- a/usr.bin/uniq/tests/uniq_test.sh
+++ b/usr.bin/uniq/tests/uniq_test.sh
@@ -167,6 +167,8 @@ stdout_head() {
 stdout_body() {
 	(
 		trap "" PIPE
+		# Give true(1) some time to exit.
+		sleep 1
 		echo a | uniq 2>stderr
 		echo $? >result
 	) | true