From 3f97c13dc047e9643399f5775ce40959fa7a939a Mon Sep 17 00:00:00 2001 From: anton Date: Fri, 3 Nov 2023 14:05:30 +0000 Subject: [PATCH] Make netcat tests less flaky by ensuring the server has terminated before examining the outcome. ok bluhm@ --- regress/usr.bin/nc/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/regress/usr.bin/nc/Makefile b/regress/usr.bin/nc/Makefile index f7c91953b73..ea369fa2496 100644 --- a/regress/usr.bin/nc/Makefile +++ b/regress/usr.bin/nc/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2022/12/18 12:53:50 tb Exp $ +# $OpenBSD: Makefile,v 1.13 2023/11/03 14:05:30 anton Exp $ # Copyright (c) 2020 Alexander Bluhm # @@ -93,6 +93,12 @@ RUNNING_WAIT = \ while ps -xww -o comm,stat | grep -q '${NC:T} .*R'; \ do [[ `date +%s` -lt $$timeout ]] || { echo timeout; exit 1; }; done +# Server close barrier. Since netcat only handles a single connection and then +# terminates, issuing this command after the first request will ensure that the +# server has terminated upon completion. +SERVER_CLOSE_WAIT = \ + nc localhost ${PORT} 2>/dev/null || : + ### TCP #### REGRESS_TARGETS += run-tcp @@ -458,6 +464,7 @@ run-tls-client-bad-ca: client.crt server.crt ca.crt fake-ca.crt ! ${NC} -c -R ca.crt -C client.crt -K client.key -v \ localhost ${PORT} ${CLIENT_LOG} ${CONNECT_WAIT} + ${SERVER_CLOSE_WAIT} grep 'Listening on localhost ' server.err grep 'Connection received on localhost ' server.err grep 'Connection to localhost .* succeeded!' client.err -- 2.20.1