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

@@ -25,16 +25,8 @@ public class GuestFS100Launch
public static void main (String[] argv)
{
try {
// Delete any previous test file if one was left around.
File old = new File ("test.img");
old.delete ();
RandomAccessFile f = new RandomAccessFile ("test.img", "rw");
f.setLength (500 * 1024 * 1024);
f.close ();
GuestFS g = new GuestFS ();
g.add_drive ("test.img");
g.add_drive_scratch (500 * 1024 * 1024, null);
g.launch ();
g.pvcreate ("/dev/sda");
@@ -57,9 +49,6 @@ public class GuestFS100Launch
g.shutdown ();
g.close ();
File f2 = new File ("test.img");
f2.delete ();
}
catch (Exception exn) {
System.err.println (exn);