...
 
Commits (3)
......@@ -36,9 +36,9 @@ my $conn = eval { $tck->setup(); };
BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
((system "brctl addbr tck") == 0) or die "cannot create bridge 'tck'";
((system "ip link add name tck type bridge") == 0) or die "cannot create bridge 'tck'";
END { system "brctl delbr tck" }
END { system "ip link del tck" }
my $b = Sys::Virt::TCK::NetworkBuilder->new(name => "tck");
$b->bridge("tck");
......
......@@ -94,28 +94,34 @@ is($st->size, 1024*1024*50, "size is 50M");
# overhead for a file
ok($st->blocks >= (1024*1024*50/512), "alot of blocks allocated");
lives_ok(sub { $vol->delete(0) }, "deleted volume");
lives_ok(sub { $vol->delete(0) }, "deleted raw volume");
ok_volume(sub { $vol = $pool->create_volume($volqcow1xml) }, "create qcow volume");
SKIP: {
if (`qemu-img -help` !~ "^Supported formats: .* qcow ") {
skip "qcow1 format not supported", 4;
}
$path = xpath($vol, "string(/volume/target/path)");
$st = stat($path);
ok_volume(sub { $vol = $pool->create_volume($volqcow1xml) }, "create qcow1 volume");
ok($st, "path $path exists");
$path = xpath($vol, "string(/volume/target/path)");
$st = stat($path);
# Don't know exactly how large a qcow1 empty file is, but it
# should be quite small :-)
ok($st->size < 1024*1024, "basic qcow1 header is allocated");
ok($st, "path $path exists");
lives_ok(sub { $vol->delete(0) }, "deleted volume");
# Don't know exactly how large a qcow1 empty file is, but it
# should be quite small :-)
ok($st->size < 1024*1024, "basic qcow1 header is allocated");
lives_ok(sub { $vol->delete(0) }, "deleted volume");
}
ok_volume(sub { $vol = $pool->create_volume($volqcow2xml) }, "create qcow volume");
ok_volume(sub { $vol = $pool->create_volume($volqcow2xml) }, "create qcow2 volume");
$path = xpath($vol, "string(/volume/target/path)");
$st = stat($path);
......@@ -126,12 +132,12 @@ ok($st, "path $path exists");
# should be quite small :-)
ok($st->size < 1024*1024, "basic qcow2 header is allocated");
lives_ok(sub { $vol->delete(0) }, "deleted volume");
lives_ok(sub { $vol->delete(0) }, "deleted qcow2 volume");
ok_volume(sub { $vol = $pool->create_volume($volvmdkxml) }, "create qcow volume");
ok_volume(sub { $vol = $pool->create_volume($volvmdkxml) }, "create vmdk volume");
$path = xpath($vol, "string(/volume/target/path)");
$st = stat($path);
......@@ -142,12 +148,12 @@ ok($st, "path $path exists");
# should be quite small :-)
ok($st->size < 1024*1024, "basic vmdk header is allocated");
lives_ok(sub { $vol->delete(0) }, "deleted volume");
lives_ok(sub { $vol->delete(0) }, "deleted vmdk volume");
ok_volume(sub { $vol = $pool->create_volume($volvpcxml) }, "create qcow volume");
ok_volume(sub { $vol = $pool->create_volume($volvpcxml) }, "create vpc volume");
$path = xpath($vol, "string(/volume/target/path)");
$st = stat($path);
......@@ -158,5 +164,5 @@ ok($st, "path $path exists");
# should be quite small :-)
ok($st->size < 1024*1024, "basic vpc header is allocated");
lives_ok(sub { $vol->delete(0) }, "deleted volume");
lives_ok(sub { $vol->delete(0) }, "deleted vpc volume");
......@@ -106,39 +106,45 @@ diag "Now testing cloning of various formats";
my @formats = qw(raw qcow qcow2 vmdk vpc);
foreach my $format (@formats) {
diag "Cloning source volume to $format format";
my $volclonexml = $tck->generic_volume("tck$format", $format, ((1024*1024*50)+4096))->as_xml;
SKIP: {
if (($format eq "qcow") and (`qemu-img -help` !~ "^Supported formats: .* qcow ")) {
skip "qcow1 format not supported", 9;
}
my $clone;
ok_volume(sub { $clone = $pool->clone_volume($volclonexml, $vol) }, "clone to $format volume");
diag "Cloning source volume to $format format";
my $volclonexml = $tck->generic_volume("tck$format", $format, ((1024*1024*50)+4096))->as_xml;
$path = xpath($clone, "string(/volume/target/path)");
$st = stat($path);
ok($st, "path $path exists");
ok($st->size >= ((1024*1024*50)+4096), "size is at least 50M");
my $clone;
ok_volume(sub { $clone = $pool->clone_volume($volclonexml, $vol) }, "clone to $format volume");
$path = xpath($clone, "string(/volume/target/path)");
$st = stat($path);
ok($st, "path $path exists");
ok($st->size >= ((1024*1024*50)+4096), "size is at least 50M");
diag "Cloning cloned volume back to raw format";
my $voldstxml = $tck->generic_volume("tckdst", "raw", ((1024*1024*50)+4096))->as_xml;
my $result;
ok_volume(sub { $result = $pool->clone_volume($voldstxml, $clone) }, "clone back to raw volume");
diag "Cloning cloned volume back to raw format";
my $voldstxml = $tck->generic_volume("tckdst", "raw", ((1024*1024*50)+4096))->as_xml;
my $result;
ok_volume(sub { $result = $pool->clone_volume($voldstxml, $clone) }, "clone back to raw volume");
$path = xpath($result, "string(/volume/target/path)");
$st = stat($path);
ok($st, "path $path exists");
$path = xpath($result, "string(/volume/target/path)");
is($st->size, ((1024*1024*50)+4096), "size is 50M");
$st = stat($path);
ok($st, "path $path exists");
diag "Comparing data between source & result volume";
is($st->size, ((1024*1024*50)+4096), "size is 50M");
my $dstdigest = &digest($path);
diag "Comparing data between source & result volume";
is($srcdigest, $dstdigest, "digests match");
my $dstdigest = &digest($path);
lives_ok(sub { $clone->delete(0) }, "deleted clone volume");
lives_ok(sub { $result->delete(0) }, "deleted result volume");
is($srcdigest, $dstdigest, "digests match");
lives_ok(sub { $clone->delete(0) }, "deleted clone volume");
lives_ok(sub { $result->delete(0) }, "deleted result volume");
}
}
......