aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/cmd/dtrace
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@FreeBSD.org>2018-07-15 20:41:16 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2018-07-15 20:41:16 +0000
commite0f9b8233faceb43e7b3a4f1cda8746c501102fd (patch)
tree9ab5746b5407146e0cf96dfd8d549b28687bb7fe /cddl/contrib/opensolaris/cmd/dtrace
parentdc9f20b3f3a122fbe313a48939831d4a8278d9c5 (diff)
downloadsrc-e0f9b8233faceb43e7b3a4f1cda8746c501102fd.tar.gz
src-e0f9b8233faceb43e7b3a4f1cda8746c501102fd.zip
Don't require a local sshd for the local TCP state dtrace test
This change is similar to the one done in r286171 for tst.ipv4localtcp.ksh. This not only reduces the requirements on the system used for testing but results also in a graceful teardown of the TCP connection. Reviewed by: gnn@ Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D16276
Notes
Notes: svn path=/head/; revision=336316
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/dtrace')
-rwxr-xr-xcddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh23
1 files changed, 17 insertions, 6 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
index 3e85143bd397..470bd1daa5ff 100755
--- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
@@ -36,12 +36,11 @@
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. The lo0 interface missing or not up.
-# 3. The local ssh service is not online.
-# 4. An unlikely race causes the unlocked global send/receive
+# 3. An unlikely race causes the unlocked global send/receive
# variables to be corrupted.
#
-# This test performs a TCP connection to the ssh service (port 22) and
-# checks that at least the following packet counts were traced:
+# This test performs a TCP connection and checks that at least the
+# following packet counts were traced:
#
# 3 x ip:::send (2 during the TCP handshake, then a FIN)
# 4 x tcp:::send (2 during the TCP handshake, 1 message then a FIN)
@@ -63,12 +62,25 @@ fi
dtrace=$1
local=127.0.0.1
-tcpport=22
DIR=/var/tmp/dtest.$$
+tcpport=1024
+bound=5000
+while [ $tcpport -lt $bound ]; do
+ nc -z $local $tcpport >/dev/null || break
+ tcpport=$(($tcpport + 1))
+done
+if [ $tcpport -eq $bound ]; then
+ echo "couldn't find an available TCP port"
+ exit 1
+fi
+
mkdir $DIR
cd $DIR
+# nc will exit when the connection is closed.
+nc -l $local $tcpport &
+
cat > test.pl <<-EOPERL
use IO::Socket;
my \$s = IO::Socket::INET->new(
@@ -77,7 +89,6 @@ cat > test.pl <<-EOPERL
PeerPort => $tcpport,
Timeout => 3);
die "Could not connect to host $local port $tcpport" unless \$s;
- print \$s "testing state machine transitions";
close \$s;
sleep(2);
EOPERL