15 my %_attr_data = ( # DEFAULT
24 my ($self, $attr) = @_;
25 return $_attr_data{$attr} if exists $_attr_data{$attr};
26 return $self->SUPER::_default_for($attr);
32 ($self->SUPER::_standard_keys(), keys %_attr_data);
43 my $server = HTTPServer->new (LocalAddr => 'localhost',
45 ReuseAddr => 1) or die "Cannot create server!!!";
46 $server->run ($self->{_urls});
49 # print "Spawned HTTP server with pid: $pid\n";
51 # print "Calling $self->{_cmdline}\n";
52 my $errcode = system ($self->{_cmdline});
56 # print "Killed HTTP server\n";
58 $errcode == $self->{_errcode}
59 or die "Test failed: wrong code returned (was: $errcode, expected: $self->{_errcode})";
61 if (my $error_str = $self->_verify_download()) {
65 print "Test successful.\n"
69 sub _verify_download {
72 # use slurp mode to read file content
73 my $old_input_record_separator = $/;
76 while (my ($filename, $filedata) = each %{$self->{_downloads}}) {
77 open (FILE, $filename)
78 or return "Test failed: file $filename not downloaded";
81 $content eq $filedata->{'content'}
82 or return "Test failed: wrong content for file $filename";
84 if (exists($filedata->{'timestamp'})) {
85 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
86 $atime,$mtime,$ctime,$blksize,$blocks) = stat FILE;
88 $mtime == $filedata->{'timestamp'}
89 or return "Test failed: wrong timestamp for file $filename";
95 $/ = $old_input_record_separator;