X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=ef7d3d5ffae7efbc3025357f58fe78d7b4982c25;hp=4fb9e4f2d571ba65776b2f33434ad6acb4ab3641;hb=a61bccecfba1c9501910d28de24bac945e95001f;hpb=4b940d1e349e382cb077be97af43a4893de9ea55 diff --git a/src/generator.ml b/src/generator.ml index 4fb9e4f..ef7d3d5 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -342,6 +342,19 @@ and cmd = string list * Apart from that, long descriptions are just perldoc paragraphs. *) +(* Generate a random UUID (used in tests). *) +let uuidgen () = + let chan = Unix.open_process_in "uuidgen" in + let uuid = input_line chan in + (match Unix.close_process_in chan with + | Unix.WEXITED 0 -> () + | Unix.WEXITED _ -> + failwith "uuidgen: process exited with non-zero status" + | Unix.WSIGNALED _ | Unix.WSTOPPED _ -> + failwith "uuidgen: process signalled or stopped by signal" + ); + uuid + (* These test functions are used in the language binding tests. *) let test_all_args = [ @@ -2077,17 +2090,18 @@ This returns the ext2/3/4 filesystem label of the filesystem on C."); ("set_e2uuid", (RErr, [Device "device"; String "uuid"]), 82, [], - [InitBasicFS, Always, TestOutput ( - [["set_e2uuid"; "/dev/sda1"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"]; - ["get_e2uuid"; "/dev/sda1"]], "a3a61220-882b-4f61-89f4-cf24dcc7297d"); - InitBasicFS, Always, TestOutput ( - [["set_e2uuid"; "/dev/sda1"; "clear"]; - ["get_e2uuid"; "/dev/sda1"]], ""); - (* We can't predict what UUIDs will be, so just check the commands run. *) - InitBasicFS, Always, TestRun ( - [["set_e2uuid"; "/dev/sda1"; "random"]]); - InitBasicFS, Always, TestRun ( - [["set_e2uuid"; "/dev/sda1"; "time"]])], + (let uuid = uuidgen () in + [InitBasicFS, Always, TestOutput ( + [["set_e2uuid"; "/dev/sda1"; uuid]; + ["get_e2uuid"; "/dev/sda1"]], uuid); + InitBasicFS, Always, TestOutput ( + [["set_e2uuid"; "/dev/sda1"; "clear"]; + ["get_e2uuid"; "/dev/sda1"]], ""); + (* We can't predict what UUIDs will be, so just check the commands run. *) + InitBasicFS, Always, TestRun ( + [["set_e2uuid"; "/dev/sda1"; "random"]]); + InitBasicFS, Always, TestRun ( + [["set_e2uuid"; "/dev/sda1"; "time"]])]), "set the ext2/3/4 filesystem UUID", "\ This sets the ext2/3/4 filesystem UUID of the filesystem on @@ -2805,9 +2819,10 @@ Note that you cannot attach a swap label to a block device a limitation of the kernel or swap tools."); ("mkswap_U", (RErr, [String "uuid"; Device "device"]), 132, [], - [InitEmpty, Always, TestRun ( - [["sfdiskM"; "/dev/sda"; ","]; - ["mkswap_U"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"; "/dev/sda1"]])], + (let uuid = uuidgen () in + [InitEmpty, Always, TestRun ( + [["sfdiskM"; "/dev/sda"; ","]; + ["mkswap_U"; uuid; "/dev/sda1"]])]), "create a swap partition with an explicit UUID", "\ Create a swap partition on C with UUID C."); @@ -3316,10 +3331,11 @@ This command disables the libguestfs appliance swap on labeled swap partition."); ("swapon_uuid", (RErr, [String "uuid"]), 176, [], - [InitEmpty, Always, TestRun ( - [["mkswap_U"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"; "/dev/sdb"]; - ["swapon_uuid"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"]; - ["swapoff_uuid"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"]])], + (let uuid = uuidgen () in + [InitEmpty, Always, TestRun ( + [["mkswap_U"; uuid; "/dev/sdb"]; + ["swapon_uuid"; uuid]; + ["swapoff_uuid"; uuid]])]), "enable swap on swap partition by UUID", "\ This command enables swap to a swap partition with the given UUID. @@ -3459,6 +3475,90 @@ This gets the SELinux security context of the daemon. See the documentation about SELINUX in L, and C"); + ("mkfs_b", (RErr, [String "fstype"; Int "blocksize"; Device "device"]), 187, [], + [InitEmpty, Always, TestOutput ( + [["sfdiskM"; "/dev/sda"; ","]; + ["mkfs_b"; "ext2"; "4096"; "/dev/sda1"]; + ["mount"; "/dev/sda1"; "/"]; + ["write_file"; "/new"; "new file contents"; "0"]; + ["cat"; "/new"]], "new file contents")], + "make a filesystem with block size", + "\ +This call is similar to C, but it allows you to +control the block size of the resulting filesystem. Supported +block sizes depend on the filesystem type, but typically they +are C<1024>, C<2048> or C<4096> only."); + + ("mke2journal", (RErr, [Int "blocksize"; Device "device"]), 188, [], + [InitEmpty, Always, TestOutput ( + [["sfdiskM"; "/dev/sda"; ",100 ,"]; + ["mke2journal"; "4096"; "/dev/sda1"]; + ["mke2fs_J"; "ext2"; "4096"; "/dev/sda2"; "/dev/sda1"]; + ["mount"; "/dev/sda2"; "/"]; + ["write_file"; "/new"; "new file contents"; "0"]; + ["cat"; "/new"]], "new file contents")], + "make ext2/3/4 external journal", + "\ +This creates an ext2 external journal on C. It is equivalent +to the command: + + mke2fs -O journal_dev -b blocksize device"); + + ("mke2journal_L", (RErr, [Int "blocksize"; String "label"; Device "device"]), 189, [], + [InitEmpty, Always, TestOutput ( + [["sfdiskM"; "/dev/sda"; ",100 ,"]; + ["mke2journal_L"; "4096"; "JOURNAL"; "/dev/sda1"]; + ["mke2fs_JL"; "ext2"; "4096"; "/dev/sda2"; "JOURNAL"]; + ["mount"; "/dev/sda2"; "/"]; + ["write_file"; "/new"; "new file contents"; "0"]; + ["cat"; "/new"]], "new file contents")], + "make ext2/3/4 external journal with label", + "\ +This creates an ext2 external journal on C with label C