xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Net/t/hostname.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl -w
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    unless (-d 'blib') {
5*0Sstevel@tonic-gate	chdir 't' if -d 't';
6*0Sstevel@tonic-gate	@INC = '../lib';
7*0Sstevel@tonic-gate    }
8*0Sstevel@tonic-gate    if (!eval "require Socket") {
9*0Sstevel@tonic-gate	print "1..0 # no Socket\n"; exit 0;
10*0Sstevel@tonic-gate    }
11*0Sstevel@tonic-gate    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
12*0Sstevel@tonic-gate        print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
13*0Sstevel@tonic-gate    }
14*0Sstevel@tonic-gate}
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gateuse Net::Domain qw(hostname domainname hostdomain);
17*0Sstevel@tonic-gateuse Net::Config;
18*0Sstevel@tonic-gate
19*0Sstevel@tonic-gateunless($NetConfig{test_hosts}) {
20*0Sstevel@tonic-gate    print "1..0\n";
21*0Sstevel@tonic-gate    exit 0;
22*0Sstevel@tonic-gate}
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gateprint "1..2\n";
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gate$domain = domainname();
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gateif(defined $domain && $domain ne "") {
29*0Sstevel@tonic-gate print "ok 1\n";
30*0Sstevel@tonic-gate}
31*0Sstevel@tonic-gateelse {
32*0Sstevel@tonic-gate print "not ok 1\n";
33*0Sstevel@tonic-gate}
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate# This check thats hostanme does not overwrite $_
36*0Sstevel@tonic-gatemy @domain = qw(foo.example.com bar.example.jp);
37*0Sstevel@tonic-gatemy @copy = @domain;
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gatemy @dummy = grep { hostname eq $_ } @domain;
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate($domain[0] && $domain[0] eq $copy[0])
42*0Sstevel@tonic-gate  ? print "ok 2\n"
43*0Sstevel@tonic-gate  : print "not ok 2\n";
44