Commit 204b734a authored by Francesc Guasch's avatar Francesc Guasch Committed by Francesc Guasch
Browse files

[#340] If wget fails die loudly

parent 2dcba4cb
......@@ -956,14 +956,21 @@ sub _download_file_lwp {
sub _download_file_external {
my ($url,$device) = @_;
confess "ERROR: wget missing" if !$WGET;
my @cmd = ($WGET,'--quiet',$url,'-O',$device);
my @cmd = ($WGET,'-nv',$url,'-O',$device);
my ($in,$out,$err) = @_;
warn join(" ",@cmd)."\n";
run3(\@cmd,\$in,\$out,\$err);
warn "out=$out" if $out;
warn "err=$err" if $err;
print $out if $out;
chmod 0755,$device or die "$! chmod 0755 $device"
if -e $device;
die $err if $err;
if ($err =~ m{\[(\d+)/(\d+)\]}) {
die "ERROR: Expecting $1 , got $2.\n$err"
if $1 != $2;
return;
}
die $err;
}
sub _search_iso {
......
......@@ -54,6 +54,23 @@ sub test_download {
}
sub test_download_fail {
my ($vm,$id_iso) = @_;
my $iso;
eval { $iso = $vm->_search_iso($id_iso) };
is($@,'') or return;
ok($iso->{url},"Expecting url ".Dumper($iso)) or return;
unlink($iso->{device}) or die "$! $iso->{device}"
if $iso->{device} && -e $iso->{device};
$iso->{url} =~ s{(.*)\.(.*)}{$1-failforced.$2};
my $device;
eval { $device = $vm->_iso_name($iso) };
like($@,qr/./);
ok(!$device);
ok(!-e $device, "Expecting $device missing") if $device;
}
sub local_urls {
rvd_back->_set_url_isos('http://localhost/iso/');
}
......@@ -96,9 +113,11 @@ for my $vm_name ('KVM') {
$msg = "SKIPPED: Test must run as root";
$vm = undef;
}
diag($msg) if !$vm;
skip($msg,10) if !$vm;
test_download_fail($vm, 1);
for my $id_iso (search_id_isos($vm)) {
test_download($vm, $id_iso);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment