git: d9220f64da8b - main - uniq tests: Make uniq_test:stdout more reliable

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 14 Jun 2024 01:21:13 UTC
The branch main has been updated by markj:

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

commit d9220f64da8b1d55b15259e8b266b50371ed4f47
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-06-14 00:00:47 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-14 00:00:47 +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
---
 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