diff options
author | Michael Tuexen <tuexen@FreeBSD.org> | 2018-07-15 20:34:22 +0000 |
---|---|---|
committer | Michael Tuexen <tuexen@FreeBSD.org> | 2018-07-15 20:34:22 +0000 |
commit | dc9f20b3f3a122fbe313a48939831d4a8278d9c5 (patch) | |
tree | 49c15d30bd7ff584599d8c2e2760d862c286b91c /cddl/contrib/opensolaris/cmd/dtrace | |
parent | d7aeb429a09bb9835bed09db554033e24ab8d09f (diff) | |
download | src-dc9f20b3f3a122fbe313a48939831d4a8278d9c5.tar.gz src-dc9f20b3f3a122fbe313a48939831d4a8278d9c5.zip |
Fix the UDP tests for dtrace.
The code imported from opensolaris was depending on ping supporting
UDP for sending probes. Since this is not supported by ping on FreeBSD
use a perl script instead.
The remote test requires the usage of ksh93, so state that in the
sheband.
Enable the local test, but keep the remote test disabled, since it
requires a remote machine on the LAN.
Reviewed by: markj@, gnn@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D16268
Notes
Notes:
svn path=/head/; revision=336315
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/dtrace')
-rwxr-xr-x | cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh | 38 | ||||
-rwxr-xr-x | cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh | 32 |
2 files changed, 59 insertions, 11 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh index 6d08e24a9fbd..323a6e56acbf 100755 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh @@ -1,4 +1,4 @@ -#!/usr/bin/ksh +#!/usr/bin/env ksh # # CDDL HEADER START # @@ -36,14 +36,14 @@ # 4. An unlikely race causes the unlocked global send/receive # variables to be corrupted. # -# This test sends a UDP message using ping and checks that at least the +# This test sends a UDP message using perl and checks that at least the # following counts were traced: # -# 1 x ip:::send (UDP sent to ping's base UDP port) -# 1 x udp:::send (UDP sent to ping's base UDP port) +# 1 x ip:::send (UDP sent to UDP port 33434) +# 1 x udp:::send (UDP sent to UDP port 33434) # 1 x ip:::receive (UDP received) # -# No udp:::receive event is expected as the response ping -U elicits is +# No udp:::receive event is expected since the UDP packet elicts # an ICMP PORT_UNREACHABLE response rather than a UDP packet, and locally # the echo request UDP packet only reaches IP, so the udp:::receive probe # is not triggered by it. @@ -56,8 +56,25 @@ fi dtrace=$1 local=127.0.0.1 +port=33434 +DIR=/var/tmp/dtest.$$ -$dtrace -c "/sbin/ping -U $local" -qs /dev/stdin <<EOF | grep -v 'is alive' +mkdir $DIR +cd $DIR + +cat > test.pl <<-EOPERL + use IO::Socket; + my \$s = IO::Socket::INET->new( + Proto => "udp", + PeerAddr => "$local", + PeerPort => $port); + die "Could not create UDP socket $local port $port" unless \$s; + send \$s, "Hello", 0; + close \$s; + sleep(2); +EOPERL + +$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE BEGIN { ipsend = udpsend = ipreceive = 0; @@ -90,4 +107,11 @@ END printf("ip:::receive - %s\n", ipreceive >= 1 ? "yes" : "no"); printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no"); } -EOF +EODTRACE + +status=$? + +cd / +/bin/rm -rf $DIR + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh index cc7a32c556b1..e16034c95c4d 100755 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh @@ -1,4 +1,4 @@ -#!/usr/bin/ksh +#!/usr/bin/env ksh93 # # CDDL HEADER START # @@ -36,7 +36,7 @@ # 4. An unlikely race causes the unlocked global send/receive # variables to be corrupted. # -# This test sends a UDP message using ping and checks that at least the +# This test sends a UDP message using perl and checks that at least the # following counts were traced: # # 1 x ip:::send (UDP sent to ping's base UDP port) @@ -50,6 +50,8 @@ fi dtrace=$1 getaddr=./get.ipv4remote.pl +port=33434 +DIR=/var/tmp/dtest.$$ if [[ ! -x $getaddr ]]; then print -u2 "could not find or execute sub program: $getaddr" @@ -60,7 +62,22 @@ if (( $? != 0 )); then exit 4 fi -$dtrace -c "/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive' +mkdir $DIR +cd $DIR + +cat > test.pl <<-EOPERL + use IO::Socket; + my \$s = IO::Socket::INET->new( + Proto => "udp", + PeerAddr => "$dest", + PeerPort => $port); + die "Could not create UDP socket $dest port $port" unless \$s; + send \$s, "Hello", 0; + close \$s; + sleep(2); +EOPERL + +$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE BEGIN { ipsend = udpsend = 0; @@ -85,4 +102,11 @@ END printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no"); printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no"); } -EOF +EODTRACE + +status=$? + +cd / +/bin/rm -rf $DIR + +exit $status |