& what's to be done for 5.8.0?
[p5sagit/p5-mst-13.2.git] / lib / Net / t / ftp.t
CommitLineData
406c51ee 1#!./perl -w
2
88587957 3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
406c51ee 8use Net::Config;
9use Net::FTP;
10
11unless(defined($NetConfig{ftp_testhost}) && $NetConfig{test_hosts}) {
12 print "1..0\n";
13 exit 0;
14}
15
16my $t = 1;
17print "1..7\n";
18
686337f3 19$ftp = Net::FTP->new($NetConfig{ftp_testhost})
406c51ee 20 or (print("not ok 1\n"), exit);
21
22printf "ok %d\n",$t++;
23
24$ftp->login('anonymous') or die($ftp->message . "\n");
25printf "ok %d\n",$t++;
26
27$ftp->pwd or do {
28 print STDERR $ftp->message,"\n";
29 print "not ";
30};
31
32printf "ok %d\n",$t++;
33
34$ftp->cwd('/pub') or do {
35 print STDERR $ftp->message,"\n";
36 print "not ";
37};
38
39if ($data = $ftp->stor('libnet.tst')) {
40 my $text = "abc\ndef\nqwe\n";
41 printf "ok %d\n",$t++;
42 $data->write($text,length $text);
43 $data->close;
44 $data = $ftp->retr('libnet.tst');
45 $data->read($buf,length $text);
46 $data->close;
47 print "not " unless $text eq $buf;
48 printf "ok %d\n",$t++;
49 $ftp->delete('libnet.tst') or print "not ";
50 printf "ok %d\n",$t++;
51
52}
53else {
686337f3 54 print "# ",$ftp->message,"\n";
55 printf "ok %d\n",$t++;
56 printf "ok %d\n",$t++;
57 printf "ok %d\n",$t++;
406c51ee 58}
59
60$ftp->quit or do {
61 print STDERR $ftp->message,"\n";
62 print "not ";
63};
64
65printf "ok %d\n",$t++;