This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
APItest/t/handy.t: Use abbrev. char name in test names
[perl5.git] / cpan / libnet / t / ftp.t
1 #!perl
2
3 use 5.008001;
4
5 use strict;
6 use warnings;
7
8 BEGIN {
9     if (!eval { require Socket }) {
10         print "1..0 # Skip: no Socket module\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
17 use Net::Config;
18 use Net::FTP;
19
20 unless(defined($NetConfig{ftp_testhost})) {
21     print "1..0 # Skip: no ftp_testhost defined in config\n";
22     exit 0;
23 }
24
25 unless($NetConfig{test_hosts}) {
26     print "1..0 # Skip: test_hosts not enabled in config\n";
27     exit 0;
28 }
29
30 my $t = 1;
31 print "1..7\n";
32
33 my $ftp = Net::FTP->new($NetConfig{ftp_testhost})
34         or (print("not ok 1\n"), exit);
35
36 printf "ok %d\n",$t++;
37
38 $ftp->login('anonymous') or die($ftp->message . "\n");
39 printf "ok %d\n",$t++;
40
41 $ftp->pwd  or do {
42   print STDERR $ftp->message,"\n";
43   print "not ";
44 };
45
46 printf "ok %d\n",$t++;
47
48 $ftp->cwd('/pub') or do {
49   print STDERR $ftp->message,"\n";
50   print "not ";
51 };
52
53 my $data;
54 if ($data = $ftp->stor('libnet.tst')) {
55   my $text = "abc\ndef\nqwe\n";
56   printf "ok %d\n",$t++;
57   $data->write($text,length $text);
58   $data->close;
59   $data = $ftp->retr('libnet.tst');
60   my $buf;
61   $data->read($buf,length $text);
62   $data->close;
63   print "not " unless $text eq $buf;
64   printf "ok %d\n",$t++;
65   $ftp->delete('libnet.tst') or print "not ";
66   printf "ok %d\n",$t++;
67   
68 }
69 else {
70   print "# ",$ftp->message,"\n";
71   printf "ok %d\n",$t++;
72   printf "ok %d\n",$t++;
73   printf "ok %d\n",$t++;
74 }
75
76 $ftp->quit  or do {
77   print STDERR $ftp->message,"\n";
78   print "not ";
79 };
80
81 printf "ok %d\n",$t++;