X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Fgenerator.ml;h=74ff3a82af8eca066b0baf9ba6c0635f1dad341b;hb=25081d62684eea9e704ecc0a0a15d2421b203356;hp=08817c127920e10a6217037199a1a35de791fc3d;hpb=2d9953097b6d3b71122d444a4550047e97aee009;p=libguestfs.git diff --git a/src/generator.ml b/src/generator.ml index 08817c1..74ff3a8 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -1861,7 +1861,7 @@ Reread the partition table on C. This uses the L command."); - ("upload", (RErr, [FileIn "filename"; String "remotefilename"]), 66, [], + ("upload", (RErr, [FileIn "filename"; Dev_or_Path "remotefilename"]), 66, [], [InitBasicFS, Always, TestOutput ( (* Pick a file from cwd which isn't likely to change. *) [["upload"; "../COPYING.LIB"; "/COPYING.LIB"]; @@ -4105,28 +4105,28 @@ To fill a file with zero bytes (sparsely), it is much more efficient to use C."); ("available", (RErr, [StringList "groups"]), 216, [], - [], + [InitNone, Always, TestRun [["available"; ""]]], "test availability of some parts of the API", "\ This command is used to check the availability of some -groups of libguestfs functions which not all builds of -libguestfs will be able to provide. +groups of functionality in the appliance, which not all builds of +the libguestfs appliance will be able to provide. -The precise libguestfs function groups that may be checked by this -command are listed in L. +The libguestfs groups, and the functions that those +groups correspond to, are listed in L. -The argument C is a list of API group names, eg: +The argument C is a list of group names, eg: C<[\"inotify\", \"augeas\"]> would check for the availability of -the C functions and C -(partition editing) functions. +the Linux inotify functions and Augeas (configuration file +editing) functions. The command returns no error if I requested groups are available. -It returns an error if one or more of the requested -groups is unavailable. +It fails with an error if one or more of the requested +groups is unavailable in the appliance. If an unknown group name is included in the -list of C then an error is always returned. +list of groups then an error is always returned. I @@ -4135,7 +4135,8 @@ I =item * You must call C before calling this function. -The reason is because we don't know what function groups are + +The reason is because we don't know what groups are supported by the appliance/daemon until it is running and can be queried. @@ -4162,6 +4163,22 @@ See also C. =back"); + ("dd", (RErr, [Dev_or_Path "src"; Dev_or_Path "dest"]), 217, [], + [InitBasicFS, Always, TestOutputBuffer ( + [["write_file"; "/src"; "hello, world"; "0"]; + ["dd"; "/src"; "/dest"]; + ["read_file"; "/dest"]], "hello, world")], + "copy from source to destination using dd", + "\ +This command copies from one source device or file C +to another destination device or file C. Normally you +would use this to copy to or from a device or partition, for +example to duplicate a filesystem. + +If the destination is a device, it must be as large or larger +than the source file or device, otherwise the copy will fail. +This command cannot do partial copies."); + ] let all_functions = non_daemon_functions @ daemon_functions @@ -6076,8 +6093,8 @@ static void print_table (char const *const *argv) *) let test_names = List.map ( - fun (name, _, _, _, tests, _, _) -> - mapi (generate_one_test name) tests + fun (name, _, _, flags, tests, _, _) -> + mapi (generate_one_test name flags) tests ) (List.rev all_functions) in let test_names = List.concat test_names in let nr_tests = List.length test_names in @@ -6235,7 +6252,7 @@ int main (int argc, char *argv[]) pr " exit (EXIT_SUCCESS);\n"; pr "}\n" -and generate_one_test name i (init, prereq, test) = +and generate_one_test name flags i (init, prereq, test) = let test_name = sprintf "test_%s_%d" name i in pr "\ @@ -6275,6 +6292,26 @@ static int %s (void) " test_name test_name test_name; + (* Optional functions should only be tested if the relevant + * support is available in the daemon. + *) + 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 " }\n"; + | _ -> () + ) flags; + (match prereq with | Disabled -> pr " printf (\" %%s skipped (reason: test disabled in generator)\\n\", \"%s\");\n" test_name @@ -6608,6 +6645,8 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = | Int64 _, _ | Bool _, _ | FileIn _, _ | FileOut _, _ -> () + | StringList n, "" | DeviceList n, "" -> + pr " const char *const %s[1] = { NULL };\n" n | StringList n, arg | DeviceList n, arg -> let strs = string_split " " arg in iteri (