summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-11-30 11:48:35 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-11-30 11:48:35 +0000
commitf93cdf1ed3323b8d9451a7f4f6365ac30ab8ba81 (patch)
tree445271ceb0c1bf1fbc33833830d1a75ea2bb7bf6 /generator
parent17233ce2113aa730752ae3420cc209b2a72ab616 (diff)
downloadlibguestfs-f93cdf1ed3323b8d9451a7f4f6365ac30ab8ba81.tar.gz
libguestfs-f93cdf1ed3323b8d9451a7f4f6365ac30ab8ba81.tar.xz
libguestfs-f93cdf1ed3323b8d9451a7f4f6365ac30ab8ba81.zip
capitests: Add 'InitScratchFS' test environment.
This should allow us to perform filesystem-based write tests much more quickly, because we don't need to recreate the filesystem from scratch each time.
Diffstat (limited to 'generator')
-rw-r--r--generator/generator_actions.ml8
-rw-r--r--generator/generator_capitests.ml17
-rw-r--r--generator/generator_types.ml21
3 files changed, 38 insertions, 8 deletions
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index d66ef9db..c081606d 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -1406,13 +1406,13 @@ See also C<guestfs_list_filesystems>.");
("list_partitions", (RStringList "partitions", [], []), 8, [],
[InitBasicFS, Always, TestOutputListOfDevices (
- [["list_partitions"]], ["/dev/sda1"]);
+ [["list_partitions"]], ["/dev/sda1"; "/dev/sdb1"]);
InitEmpty, Always, TestOutputListOfDevices (
[["part_init"; "/dev/sda"; "mbr"];
["part_add"; "/dev/sda"; "p"; "64"; "204799"];
["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
- ["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])],
+ ["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"; "/dev/sdb1"])],
"list the partitions",
"\
List all the partitions detected on all block devices.
@@ -5513,10 +5513,10 @@ error occurs.
See also C<guestfs_download>, C<guestfs_pread>.");
("pwrite_device", (RInt "nbytes", [Device "device"; BufferIn "content"; Int64 "offset"], []), 275, [ProtocolLimitWarning],
- [InitPartition, Always, TestOutputList (
+ [InitPartition, Always, TestOutputListOfDevices (
[["pwrite_device"; "/dev/sda"; "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; "446"];
["blockdev_rereadpt"; "/dev/sda"];
- ["list_partitions"]], [])],
+ ["list_partitions"]], ["/dev/sdb1"])],
"write to part of a device",
"\
This command writes to part of a device. It writes the data
diff --git a/generator/generator_capitests.ml b/generator/generator_capitests.ml
index 190e10f7..f5be3e7c 100644
--- a/generator/generator_capitests.ml
+++ b/generator/generator_capitests.ml
@@ -257,6 +257,16 @@ int main (int argc, char *argv[])
/* Cancel previous alarm. */
alarm (0);
+ /* Create ext2 filesystem on /dev/sdb1 partition. */
+ if (guestfs_part_disk (g, \"/dev/sdb\", \"mbr\") == -1) {
+ printf (\"guestfs_part_disk FAILED\\n\");
+ exit (EXIT_FAILURE);
+ }
+ if (guestfs_mkfs (g, \"ext2\", \"/dev/sdb1\") == -1) {
+ printf (\"guestfs_mkfs (/dev/sdb1) FAILED\\n\");
+ exit (EXIT_FAILURE);
+ }
+
nr_tests = %d;
" (500 * 1024 * 1024) (50 * 1024 * 1024) (10 * 1024 * 1024) nr_tests;
@@ -435,6 +445,13 @@ and generate_one_test_body name i test_name init test =
["umount_all"];
["lvm_remove_all"];
["mount_ro"; "/dev/sdd"; "/"]]
+ | InitScratchFS ->
+ pr " /* InitScratchFS for %s */\n" test_name;
+ List.iter (generate_test_command_call test_name)
+ [["blockdev_setrw"; "/dev/sda"];
+ ["umount_all"];
+ ["lvm_remove_all"];
+ ["mount_options"; ""; "/dev/sdb1"; "/"]]
);
let get_seq_last = function
diff --git a/generator/generator_types.ml b/generator/generator_types.ml
index be9a1956..369a49a3 100644
--- a/generator/generator_types.ml
+++ b/generator/generator_types.ml
@@ -334,15 +334,16 @@ and test_init =
| InitEmpty
(* /dev/sda contains a single partition /dev/sda1, with random
- * content. /dev/sdb and /dev/sdc may have random content.
- * No LVM.
+ * content. No LVM.
*)
| InitPartition
(* /dev/sda contains a single partition /dev/sda1, which is formatted
* as ext2, empty [except for lost+found] and mounted on /.
- * /dev/sdb and /dev/sdc may have random content.
* No LVM.
+ *
+ * Note: for testing filesystem operations, it is quicker to use
+ * InitScratchFS
*)
| InitBasicFS
@@ -350,7 +351,9 @@ and test_init =
* /dev/sda1 (is a PV):
* /dev/VG/LV (size 8MB):
* formatted as ext2, empty [except for lost+found], mounted on /
- * /dev/sdb and /dev/sdc may have random content.
+ *
+ * Note: only use this if you really need a freshly created filesystem
+ * on LVM. Normally you should use InitScratchFS instead.
*)
| InitBasicFSonLVM
@@ -359,6 +362,16 @@ and test_init =
*)
| InitISOFS
+ (* /dev/sdb1 (write scratch disk) is mounted on /. The filesystem
+ * will be empty.
+ *
+ * Note that this filesystem is not recreated between tests, and
+ * could contain random files and directories from previous tests.
+ * Therefore it is recommended that you create uniquely named files
+ * and directories for your tests.
+ *)
+ | InitScratchFS
+
(* Sequence of commands for testing. *)
and seq = cmd list
and cmd = string list