xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Net/protoent.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate}
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gateBEGIN {
9*0Sstevel@tonic-gate    our $haspe;
10*0Sstevel@tonic-gate    eval { my @n = getprotobyname "tcp" };
11*0Sstevel@tonic-gate    $haspe = 1 unless $@ && $@ =~ /unimplemented|unsupported/i;
12*0Sstevel@tonic-gate    unless ($haspe) { print "1..0 # Skip: no getprotobyname\n"; exit 0 }
13*0Sstevel@tonic-gate    use Config;
14*0Sstevel@tonic-gate    $haspe = 0 unless $Config{'i_netdb'} eq 'define';
15*0Sstevel@tonic-gate    unless ($haspe) { print "1..0 # Skip: no netdb.h\n"; exit 0 }
16*0Sstevel@tonic-gate}
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gateBEGIN {
19*0Sstevel@tonic-gate    our @protoent = getprotobyname "tcp"; # This is the function getprotobyname.
20*0Sstevel@tonic-gate    unless (@protoent) { print "1..0 # Skip: no tcp protocol\n"; exit 0 }
21*0Sstevel@tonic-gate}
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gateprint "1..3\n";
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gateuse Net::protoent;
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gateprint "ok 1\n";
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gatemy $protoent = getprotobyname "tcp"; # This is the OO getprotobyname.
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gateprint "not " unless $protoent->name   eq $protoent[0];
32*0Sstevel@tonic-gateprint "ok 2\n";
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateprint "not " unless $protoent->proto  == $protoent[2];
35*0Sstevel@tonic-gateprint "ok 3\n";
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate# Testing pretty much anything else is unportable.
38*0Sstevel@tonic-gate
39