1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00
wget/tests/FTPTest.pm

71 lines
1.4 KiB
Perl
Raw Normal View History

2007-06-14 12:05:59 -04:00
#!/usr/bin/perl -w
package FTPTest;
use strict;
use FTPServer;
use WgetTest;
2007-06-14 12:05:59 -04:00
our @ISA = qw(WgetTest);
2007-06-14 12:05:59 -04:00
my $VERSION = 0.01;
{
my %_attr_data = ( # DEFAULT
);
sub _default_for
{
my ($self, $attr) = @_;
return $_attr_data{$attr} if exists $_attr_data{$attr};
return $self->SUPER::_default_for($attr);
}
sub _standard_keys
{
my ($self) = @_;
($self->SUPER::_standard_keys(), keys %_attr_data);
}
}
sub _setup_server {
my $self = shift;
foreach my $url (keys %{$self->{_input}}) {
my $filename = $url;
$filename =~ s/^\///;
open (FILE, ">$filename")
or return "Test failed: cannot open input file $filename\n";
print FILE $self->{_input}->{$url}->{content}
or return "Test failed: cannot write input file $filename\n";
close (FILE);
}
2008-06-12 05:18:35 -04:00
$self->{_server} = FTPServer->new (LocalAddr => 'localhost',
ReuseAddr => 1,
rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!";
2007-06-14 12:05:59 -04:00
}
sub _launch_server {
my $self = shift;
my $synch_func = shift;
2008-06-12 05:18:35 -04:00
$self->{_server}->run ($synch_func);
}
2007-06-14 12:05:59 -04:00
2008-06-12 05:18:35 -04:00
sub _substitute_port {
my $self = shift;
my $ret = shift;
$ret =~ s/{{port}}/$self->{_server}->sockport/eg;
return $ret;
2007-06-14 12:05:59 -04:00
}
1;
# vim: et ts=4 sw=4