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