tests: Use new guestfs_add_drive_scratch API where possible in tests.

Replaces code such as:

  fd = open "test1.img"
  ftruncate fd, size
  close fd
  g.add_drive "test1.img"

with the shorter and simpler:

  g.add_drive_scratch size
This commit is contained in:
Richard W.M. Jones
2013-07-19 16:42:53 +01:00
parent 57064c12ae
commit 14fabcd88e
25 changed files with 35 additions and 352 deletions

View File

@@ -17,18 +17,13 @@
use strict;
use warnings;
use Test::More tests => 26;
use Test::More tests => 25;
use Sys::Guestfs;
my $g = Sys::Guestfs->new ();
ok ($g);
open FILE, ">test.img";
truncate FILE, 500*1024*1024;
close FILE;
ok (1);
$g->add_drive ("test.img");
$g->add_drive_scratch (500*1024*1024);
ok (1);
$g->launch ();
@@ -76,6 +71,4 @@ $g->shutdown ();
ok (1);
undef $g;
ok (1);
unlink ("test.img");
ok (1)

View File

@@ -19,7 +19,7 @@
use strict;
use warnings;
use Test::More tests => 15;
use Test::More tests => 14;
use Errno;
@@ -27,13 +27,7 @@ use Sys::Guestfs;
my $g = Sys::Guestfs->new ();
ok ($g);
open FILE, ">test.img";
truncate FILE, 500*1024*1024;
close FILE;
ok (1);
$g->add_drive ("test.img", format => "raw");
$g->add_drive_scratch (500*1024*1024);
ok (1);
$g->launch ();
@@ -72,5 +66,3 @@ ok ($err != Errno::EEXIST());
undef $g;
ok (1);
unlink ("test.img");