This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Let perl_clone copy PL_exit_flags
[perl5.git] / lib / Net / t / ftp.t
CommitLineData
406c51ee
JH
1#!./perl -w
2
3use Net::Config;
4use Net::FTP;
5
6unless(defined($NetConfig{ftp_testhost}) && $NetConfig{test_hosts}) {
7 print "1..0\n";
8 exit 0;
9}
10
11my $t = 1;
12print "1..7\n";
13
14$ftp = Net::FTP->new($NetConfig{ftp_testhost}, Debug => 0)
15 or (print("not ok 1\n"), exit);
16
17printf "ok %d\n",$t++;
18
19$ftp->login('anonymous') or die($ftp->message . "\n");
20printf "ok %d\n",$t++;
21
22$ftp->pwd or do {
23 print STDERR $ftp->message,"\n";
24 print "not ";
25};
26
27printf "ok %d\n",$t++;
28
29$ftp->cwd('/pub') or do {
30 print STDERR $ftp->message,"\n";
31 print "not ";
32};
33
34if ($data = $ftp->stor('libnet.tst')) {
35 my $text = "abc\ndef\nqwe\n";
36 printf "ok %d\n",$t++;
37 $data->write($text,length $text);
38 $data->close;
39 $data = $ftp->retr('libnet.tst');
40 $data->read($buf,length $text);
41 $data->close;
42 print "not " unless $text eq $buf;
43 printf "ok %d\n",$t++;
44 $ftp->delete('libnet.tst') or print "not ";
45 printf "ok %d\n",$t++;
46
47}
48else {
49 print STDERR $ftp->message,"\n";
50 printf "not ok %d\n",$t++;
51 printf "not ok %d\n",$t++;
52 printf "not ok %d\n",$t++;
53}
54
55$ftp->quit or do {
56 print STDERR $ftp->message,"\n";
57 print "not ";
58};
59
60printf "ok %d\n",$t++;