git: b697835ce614 - main - Improve reliability of stdout tests.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Thu, 14 Nov 2024 19:41:53 UTC
The branch main has been updated by des:

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

commit b697835ce614de2fa30ba066983d7e71c48f34ce
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-11-14 19:41:35 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-11-14 19:41:47 +0000

    Improve reliability of stdout tests.
    
    If the test runner is under heavy load, the command we are testing may
    succeed in printing to stdout before the dummy receiver has terminated.
    Add a short delay to reduce the likelihood of this happening.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D47572
---
 usr.bin/asa/tests/asa_test.sh  | 1 +
 usr.bin/cmp/tests/cmp_test2.sh | 1 +
 usr.bin/env/tests/env_test.sh  | 1 +
 3 files changed, 3 insertions(+)

diff --git a/usr.bin/asa/tests/asa_test.sh b/usr.bin/asa/tests/asa_test.sh
index 91515bb55d95..2b8fecb12d98 100644
--- a/usr.bin/asa/tests/asa_test.sh
+++ b/usr.bin/asa/tests/asa_test.sh
@@ -70,6 +70,7 @@ stdout_head() {
 stdout_body() {
 	(
 		trap "" PIPE
+		sleep 1
 		echo " $a $b" | asa 2>stderr
 		echo $? >result
 	) | true
diff --git a/usr.bin/cmp/tests/cmp_test2.sh b/usr.bin/cmp/tests/cmp_test2.sh
index 2ec6071851d3..bca8fc18a6b8 100755
--- a/usr.bin/cmp/tests/cmp_test2.sh
+++ b/usr.bin/cmp/tests/cmp_test2.sh
@@ -138,6 +138,7 @@ atf_check_stdout()
 {
 	(
 		trap "" PIPE
+		sleep 1
 		cmp "$@" 2>stderr
 		echo $? >result
 	) | true
diff --git a/usr.bin/env/tests/env_test.sh b/usr.bin/env/tests/env_test.sh
index 2dc8f1a4c911..3210361eb223 100644
--- a/usr.bin/env/tests/env_test.sh
+++ b/usr.bin/env/tests/env_test.sh
@@ -139,6 +139,7 @@ stdout_body()
 {
 	(
 		trap "" PIPE
+		sleep 1
 		env 2>stderr
 		echo $? >result
 	) | true