Page MenuHomeFreeBSD

Fix the UDP tests
ClosedPublic

Authored by tuexen on Jul 14 2018, 3:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 7:33 AM
Unknown Object (File)
Sat, Nov 2, 7:27 PM
Unknown Object (File)
Oct 15 2024, 5:50 AM
Unknown Object (File)
Oct 11 2024, 6:19 AM
Unknown Object (File)
Sep 28 2024, 9:48 AM
Unknown Object (File)
Sep 22 2024, 7:50 PM
Unknown Object (File)
Sep 22 2024, 7:26 PM
Unknown Object (File)
Sep 9 2024, 8:13 PM
Subscribers

Details

Summary

Both UDP tests require ping to be able to send UDP packets, which is supported on Solaris but not on FreeBSD. So use a perl scripts instead.

Change the shebang to allow finding the shell outside of /usr/bin, which is the case on FreeBSD, where the shell lives in /usr/local/bin.

The remote test relies on a feature avaliable in ksh93, so use that shell instead.

I could change the extension of the remote test to .ksh93 and extend dtrace.sh to support it. Just let me know, if this is preferred.

We keep the remote test disabled, since it requires other machines to exists on the LAN. This is not always the case...

Test Plan

Run the test scripts. They should pass...

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 18037

Event Timeline

tuexen edited the summary of this revision. (Show Details)
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh
62–77

We should keep the file in /tmp rather than the current directory. It should also get cleaned up.

62–77

If you quote the EOF indicator, the shell won't perform substitutions and so you don't need to escape '$' in the script.

That is, you can write:

cat > test.pl <<'EOPERL'
...
my $s = ...
...
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh
65–80

Same comments as above.

cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh
62–77

Right, will put it in a tmp dir like the other tests. I missed that.

62–77

Regarding the quoting. I can do that, but the other scripts in this dir do it like this one... I just cloned that code (this is actually the first line or perl I wrote...).
Do you want your change or have the code consistent with the rest?

Put script file in temp directory and clean it up finally.

Added back Makefile change missed in last diff

cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh
62–77

I can't quote the EOF delimiter, because then no substitution is done in the here-document.

To be explicit:

Without quoting the EOF delimiter, test.pl contains:

use IO::Socket;
my $s = IO::Socket::INET->new(
    Proto => "udp",
    PeerAddr => "127.0.0.1",
    PeerPort => 33434);
die "Could not create UDP socket 127.0.0.1 port 33434" unless $s;
send $s, "Hello", 0;
close $s;
sleep(2);

which is correct.

However, when quoting the EOF character, test.pl reads:

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);

which does not correct. This script does not work.

So I guess being consistent is a good thing here.

cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh
62–77

Oops, I missed that. Looks fine to me then.

cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh
112

Don't we want to exit $status?

Return the error code which is intended.

cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh
112

Sure we do... I just copied the code from tst.ipv4remotetcp.ksh, the only file in this directory which has this bug, Thanks for catching it.

cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh
112

I fixed the bug in tst.ipv4remotetcp.ksh in r336293.

This revision is now accepted and ready to land.Jul 15 2018, 7:22 PM
This revision was automatically updated to reflect the committed changes.