Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
204b734a
Commit
204b734a
authored
Sep 22, 2017
by
Francesc Guasch
Committed by
Francesc Guasch
Sep 27, 2017
Browse files
[#340] If wget fails die loudly
parent
2dcba4cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/Ravada/VM/KVM.pm
View file @
204b734a
...
...
@@ -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 {
...
...
t/request/20_download_local.t
View file @
204b734a
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment