1#!perl 2 3use 5.008001; 4 5use strict; 6use warnings; 7 8BEGIN { 9 if (!eval { require Socket }) { 10 print "1..0 # Skip: no Socket\n"; exit 0; 11 } 12 if (ord('A') == 193 && !eval { require Convert::EBCDIC }) { 13 print "1..0 # Skip: EBCDIC but no Convert::EBCDIC\n"; exit 0; 14 } 15} 16 17use Net::Config; 18use Net::NNTP; 19use Net::Cmd qw(CMD_REJECT); 20 21unless(@{$NetConfig{nntp_hosts}}) { 22 print "1..0 # Skip: no nntp_hosts defined in config\n"; 23 exit; 24} 25 26unless($NetConfig{test_hosts}) { 27 print "1..0 # Skip: test_hosts not enabled in config\n"; 28 exit; 29} 30 31print "1..4\n"; 32 33my $i = 1; 34 35my $nntp = Net::NNTP->new(Debug => 0) 36 or (print("not ok 1\n"), exit); 37 38print "ok 1\n"; 39 40my @grp; 41foreach my $grp (qw(test alt.test control news.announce.newusers)) { 42 @grp = $nntp->group($grp); 43 last if @grp; 44} 45 46if($nntp->status == CMD_REJECT) { 47 # Command was rejected, probably because we need authinfo 48 map { print "ok ",$_,"\n" } 2,3,4; 49 exit; 50} 51 52print "not " unless @grp; 53print "ok 2\n"; 54 55 56if(@grp && $grp[2] > $grp[1]) { 57 $nntp->head($grp[1]) or print "not "; 58} 59print "ok 3\n"; 60 61if(@grp) { 62 $nntp->quit or print "not "; 63} 64print "ok 4\n"; 65 66