X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=4d74cb004c713f211bb17b28f686345067a52575;hp=571ea3a070d1b19d2bd6b5536192a35cda01ab48;hb=f9d08600c52dc0730e7dad8d9259b59e32aeece2;hpb=f2b7a8e15c49ebc70c7ea56aefb340362aae5a99 diff --git a/src/generator.ml b/src/generator.ml index 571ea3a..4d74cb0 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -309,6 +309,9 @@ and test_prereq = (* As for 'If' but the test runs _unless_ the code returns true. *) | Unless of string + (* Run the test only if 'string' is available in the daemon. *) + | IfAvailable of string + (* Some initial scenarios for testing. *) and test_init = (* Do nothing, block devices could contain random stuff including @@ -2320,16 +2323,30 @@ any partition tables, filesystem superblocks and so on. See also: C, C."); ("grub_install", (RErr, [Pathname "root"; Device "device"]), 86, [], - (* Test disabled because grub-install incompatible with virtio-blk driver. - * See also: https://bugzilla.redhat.com/show_bug.cgi?id=479760 + (* See: + * https://bugzilla.redhat.com/show_bug.cgi?id=484986 + * https://bugzilla.redhat.com/show_bug.cgi?id=479760 *) - [InitBasicFS, Disabled, TestOutputTrue ( - [["grub_install"; "/"; "/dev/sda1"]; + [InitBasicFS, Always, TestOutputTrue ( + [["mkdir_p"; "/boot/grub"]; + ["write"; "/boot/grub/device.map"; "(hd0) /dev/vda"]; + ["grub_install"; "/"; "/dev/vda"]; ["is_dir"; "/boot"]])], "install GRUB", "\ This command installs GRUB (the Grand Unified Bootloader) on -C, with the root directory being C."); +C, with the root directory being C. + +Note: If grub-install reports the error +\"No suitable drive was found in the generated device map.\" +it may be that you need to create a C +file first that contains the mapping between grub device names +and Linux device names. It is usually sufficient to create +a file containing: + + (hd0) /dev/vda + +replacing C with the name of the installation device."); ("cp", (RErr, [Pathname "src"; Pathname "dest"]), 87, [], [InitBasicFS, Always, TestOutput ( @@ -2641,9 +2658,9 @@ is lost."); ("resize2fs", (RErr, [Device "device"]), 106, [], [], (* lvresize tests this *) - "resize an ext2/ext3 filesystem", + "resize an ext2, ext3 or ext4 filesystem", "\ -This resizes an ext2 or ext3 filesystem to match the size of +This resizes an ext2, ext3 or ext4 filesystem to match the size of the underlying device. I It is sometimes required that you run C @@ -4708,7 +4725,7 @@ See also C."); ("resize2fs_size", (RErr, [Device "device"; Int64 "size"]), 248, [], [], - "resize an ext2/ext3 filesystem (with size)", + "resize an ext2, ext3 or ext4 filesystem (with size)", "\ This command is the same as C except that it allows you to specify the new size (in bytes) explicitly."); @@ -6824,6 +6841,19 @@ static void print_table (char const *const *argv) } */ +static int +is_available (const char *group) +{ + const char *groups[] = { group, NULL }; + int r; + + suppress_error = 1; + r = guestfs_available (g, (char **) groups); + suppress_error = 0; + + return r == 0; +} + "; (* Generate a list of commands which are not tested anywhere. *) @@ -6835,7 +6865,7 @@ static void print_table (char const *const *argv) fun (_, _, _, _, tests, _, _) -> let tests = filter_map ( function - | (_, (Always|If _|Unless _), test) -> Some test + | (_, (Always|If _|Unless _|IfAvailable _), test) -> Some test | (_, Disabled, _) -> None ) tests in let seq = List.concat (List.map seq_of_test tests) in @@ -7041,7 +7071,7 @@ static int %s_skip (void) " test_name name (String.uppercase test_name) (String.uppercase name); (match prereq with - | Disabled | Always -> () + | Disabled | Always | IfAvailable _ -> () | If code | Unless code -> pr "static int %s_prereq (void)\n" test_name; pr "{\n"; @@ -7066,16 +7096,9 @@ static int %s (void) List.iter ( function | Optional group -> - pr " {\n"; - pr " const char *groups[] = { \"%s\", NULL };\n" group; - pr " int r;\n"; - pr " suppress_error = 1;\n"; - pr " r = guestfs_available (g, (char **) groups);\n"; - pr " suppress_error = 0;\n"; - pr " if (r == -1) {\n"; - pr " printf (\" %%s skipped (reason: group %%s not available in daemon)\\n\", \"%s\", groups[0]);\n" test_name; - pr " return 0;\n"; - pr " }\n"; + pr " if (!is_available (\"%s\")) {\n" group; + pr " printf (\" %%s skipped (reason: group %%s not available in daemon)\\n\", \"%s\", \"%s\");\n" test_name group; + pr " return 0;\n"; pr " }\n"; | _ -> () ) flags; @@ -7097,6 +7120,13 @@ static int %s (void) pr " }\n"; pr "\n"; generate_one_test_body name i test_name init test; + | IfAvailable group -> + pr " if (!is_available (\"%s\")) {\n" group; + pr " printf (\" %%s skipped (reason: %%s not available)\\n\", \"%s\", \"%s\");\n" test_name group; + pr " return 0;\n"; + pr " }\n"; + pr "\n"; + generate_one_test_body name i test_name init test; | Always -> generate_one_test_body name i test_name init test );