summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2020-01-28 19:25:46 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2020-01-28 19:25:46 +0000
commit1d4f7f86e8a54d3dbf324a5cfe6065ed6acf4e1f (patch)
treecb3ac1ca5819e4dd6c4b477e026dfe9464aa3c7a /regress
parentdbf761f1c4fd61d9be65f25b02440a8a4b651ed4 (diff)
With nc -NU netcat can probe if a UNIX stream socket is listening.
Add a test for this. Use case needed by florian@.
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/nc/Makefile24
1 files changed, 23 insertions, 1 deletions
diff --git a/regress/usr.bin/nc/Makefile b/regress/usr.bin/nc/Makefile
index a25578630d9..4a9cd1efc47 100644
--- a/regress/usr.bin/nc/Makefile
+++ b/regress/usr.bin/nc/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.7 2020/01/26 23:48:50 beck Exp $
+# $OpenBSD: Makefile,v 1.8 2020/01/28 19:25:45 bluhm Exp $
# Copyright (c) 2020 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -840,6 +840,28 @@ run-unix-namelookup:
# XXX message succeeded is missing
! grep 'Connection to server.sock .* succeeded!' client.err
+REGRESS_TARGETS += run-unix-probe
+run-unix-probe:
+ @echo '======== $@ ========'
+ rm -f server.sock
+ ${SERVER_NC} -U -n -v -l server.sock ${SERVER_BG}
+ ${LISTEN_WAIT}
+ # connect and close immediately, check if socket is listening
+ ${NC} -N -U -v server.sock </dev/null ${CLIENT_LOG}
+ # XXX message Bound and Listening is redundant
+ grep 'Bound on server.sock$$' server.err
+ grep 'Listening on server.sock$$' server.err
+ grep 'Connection received on server.sock$$' server.err
+ # XXX message succeeded is missing
+ ! grep 'Connection to server.sock .* succeeded!' client.err
+ # server accepts one connection, second connection should be refused
+ ! ${NC} -N -U -v server.sock </dev/null ${CLIENT_LOG}
+ grep 'server.sock: Connection refused' client.err
+ # connection to non existing socket file should fail
+ rm server.sock
+ ! ${NC} -N -U -v server.sock </dev/null ${CLIENT_LOG}
+ grep 'server.sock: No such file or directory' client.err
+
# UNIX keep
REGRESS_TARGETS += run-unix-keep