| FishAction of string (* call this function in guestfish *)
| NotInFish (* do not export via guestfish *)
| NotInDocs (* do not add this function to documentation *)
-
-let protocol_limit_warning =
- "Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP."
-
-let danger_will_robinson =
- "B<This command is dangerous. Without careful use you
-can easily destroy all your data>."
+ | DeprecatedBy of string (* function is deprecated, use .. instead *)
(* You can supply zero or as many tests as you want per API call.
*
* a bad idea.
*)
| InitNone
+
(* Block devices are empty and no filesystems are mounted. *)
| InitEmpty
+
(* /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.
*)
| InitBasicFS
+
(* /dev/sda:
* /dev/sda1 (is a PV):
* /dev/VG/LV (size 8MB):
*)
| InitBasicFSonLVM
+ (* /dev/sdd (the squashfs, see images/ directory in source)
+ * is mounted on /
+ *)
+ | InitSquashFS
+
(* Sequence of commands for testing. *)
and seq = cmd list
and cmd = string list
InitBasicFS, Always, TestOutput (
[["write_file"; "/new"; "test\n"; "0"];
["checksum"; "sha512"; "/new"]], "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123");
- InitBasicFS, Always, TestOutput (
- (* RHEL 5 thinks this is an HFS+ filesystem unless we give
- * the type explicitly.
- *)
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["checksum"; "md5"; "/known-3"]], "46d6ca27ee07cdc6fa99c2e138cc522c")],
+ InitSquashFS, Always, TestOutput (
+ [["checksum"; "md5"; "/known-3"]], "46d6ca27ee07cdc6fa99c2e138cc522c")],
"compute MD5, SHAx or CRC checksum of file",
"\
This call computes the MD5, SHAx or CRC checksum of the
(* Test for RHBZ#501888c2 regression which caused large hexdump
* commands to segfault.
*)
- InitBasicFS, Always, TestRun (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["hexdump"; "/100krandom"]])],
+ InitSquashFS, Always, TestRun (
+ [["hexdump"; "/100krandom"]])],
"dump a file in hexadecimal",
"\
This runs C<hexdump -C> on the given C<path>. The result is
See also: L<mkdtemp(3)>");
("wc_l", (RInt "lines", [String "path"]), 118, [],
- [InitBasicFS, Always, TestOutputInt (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["wc_l"; "/10klines"]], 10000)],
+ [InitSquashFS, Always, TestOutputInt (
+ [["wc_l"; "/10klines"]], 10000)],
"count lines in a file",
"\
This command counts the lines in a file, using the
C<wc -l> external command.");
("wc_w", (RInt "words", [String "path"]), 119, [],
- [InitBasicFS, Always, TestOutputInt (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["wc_w"; "/10klines"]], 10000)],
+ [InitSquashFS, Always, TestOutputInt (
+ [["wc_w"; "/10klines"]], 10000)],
"count words in a file",
"\
This command counts the words in a file, using the
C<wc -w> external command.");
("wc_c", (RInt "chars", [String "path"]), 120, [],
- [InitBasicFS, Always, TestOutputInt (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["wc_c"; "/100kallspaces"]], 102400)],
+ [InitSquashFS, Always, TestOutputInt (
+ [["wc_c"; "/100kallspaces"]], 102400)],
"count characters in a file",
"\
This command counts the characters in a file, using the
C<wc -c> external command.");
("head", (RStringList "lines", [String "path"]), 121, [ProtocolLimitWarning],
- [InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["head"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"])],
+ [InitSquashFS, Always, TestOutputList (
+ [["head"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"])],
"return first 10 lines of a file",
"\
This command returns up to the first 10 lines of a file as
a list of strings.");
("head_n", (RStringList "lines", [Int "nrlines"; String "path"]), 122, [ProtocolLimitWarning],
- [InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["head_n"; "3"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]);
- InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["head_n"; "-9997"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]);
- InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["head_n"; "0"; "/10klines"]], [])],
+ [InitSquashFS, Always, TestOutputList (
+ [["head_n"; "3"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]);
+ InitSquashFS, Always, TestOutputList (
+ [["head_n"; "-9997"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]);
+ InitSquashFS, Always, TestOutputList (
+ [["head_n"; "0"; "/10klines"]], [])],
"return first N lines of a file",
"\
If the parameter C<nrlines> is a positive number, this returns the first
If the parameter C<nrlines> is zero, this returns an empty list.");
("tail", (RStringList "lines", [String "path"]), 123, [ProtocolLimitWarning],
- [InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["tail"; "/10klines"]], ["9990abcdefghijklmnopqrstuvwxyz";"9991abcdefghijklmnopqrstuvwxyz";"9992abcdefghijklmnopqrstuvwxyz";"9993abcdefghijklmnopqrstuvwxyz";"9994abcdefghijklmnopqrstuvwxyz";"9995abcdefghijklmnopqrstuvwxyz";"9996abcdefghijklmnopqrstuvwxyz";"9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"])],
+ [InitSquashFS, Always, TestOutputList (
+ [["tail"; "/10klines"]], ["9990abcdefghijklmnopqrstuvwxyz";"9991abcdefghijklmnopqrstuvwxyz";"9992abcdefghijklmnopqrstuvwxyz";"9993abcdefghijklmnopqrstuvwxyz";"9994abcdefghijklmnopqrstuvwxyz";"9995abcdefghijklmnopqrstuvwxyz";"9996abcdefghijklmnopqrstuvwxyz";"9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"])],
"return last 10 lines of a file",
"\
This command returns up to the last 10 lines of a file as
a list of strings.");
("tail_n", (RStringList "lines", [Int "nrlines"; String "path"]), 124, [ProtocolLimitWarning],
- [InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["tail_n"; "3"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]);
- InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["tail_n"; "-9998"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]);
- InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["tail_n"; "0"; "/10klines"]], [])],
+ [InitSquashFS, Always, TestOutputList (
+ [["tail_n"; "3"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]);
+ InitSquashFS, Always, TestOutputList (
+ [["tail_n"; "-9998"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]);
+ InitSquashFS, Always, TestOutputList (
+ [["tail_n"; "0"; "/10klines"]], [])],
"return last N lines of a file",
"\
If the parameter C<nrlines> is a positive number, this returns the last
(ie. units of 1024 bytes).");
("initrd_list", (RStringList "filenames", [String "path"]), 128, [],
- [InitBasicFS, Always, TestOutputList (
- [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
- ["initrd_list"; "/initrd"]], ["empty";"known-1";"known-2";"known-3"])],
+ [InitSquashFS, Always, TestOutputList (
+ [["initrd_list"; "/initrd"]], ["empty";"known-1";"known-2";"known-3"])],
"list files in an initrd",
"\
This command lists out files contained in an initrd.
| TestOutputLength (s, _) | TestOutputStruct (s, _)
| TestLastFail s -> s
+(* Handling for function flags. *)
+let protocol_limit_warning =
+ "Because of the message protocol, there is a transfer limit
+of somewhere between 2MB and 4MB. To transfer large files you should use
+FTP."
+
+let danger_will_robinson =
+ "B<This command is dangerous. Without careful use you
+can easily destroy all your data>."
+
+let deprecation_notice flags =
+ try
+ let alt =
+ find_map (function DeprecatedBy str -> Some str | _ -> None) flags in
+ let txt =
+ sprintf "This function is deprecated.
+In new code, use the C<%s> call instead.
+
+Deprecated functions will not be removed from the API, but the
+fact that they are deprecated indicates that there are problems
+with correct use of these functions." alt in
+ Some txt
+ with
+ Not_found -> None
+
(* Check function names etc. for consistency. *)
let check_functions () =
let contains_uppercase str =
if List.mem ProtocolLimitWarning flags then
pr "%s\n\n" protocol_limit_warning;
if List.mem DangerWillRobinson flags then
- pr "%s\n\n" danger_will_robinson
+ pr "%s\n\n" danger_will_robinson;
+ match deprecation_notice flags with
+ | None -> ()
+ | Some txt -> pr "%s\n\n" txt
)
) all_functions_sorted
["lvcreate"; "LV"; "VG"; "8"];
["mkfs"; "ext2"; "/dev/VG/LV"];
["mount"; "/dev/VG/LV"; "/"]]
+ | InitSquashFS ->
+ pr " /* InitSquashFS for %s */\n" test_name;
+ List.iter (generate_test_command_call test_name)
+ [["blockdev_setrw"; "/dev/sda"];
+ ["umount_all"];
+ ["lvm_remove_all"];
+ ["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]]
);
let get_seq_last = function
("\n\n" ^ danger_will_robinson)
else "" in
+ let warnings =
+ warnings ^
+ match deprecation_notice flags with
+ | None -> ""
+ | Some txt -> "\n\n" ^ txt in
+
let describe_alias =
if name <> alias then
sprintf "\n\nYou can use '%s' as an alias for this command." alias
pr "%s\n\n" protocol_limit_warning;
if List.mem DangerWillRobinson flags then
- pr "%s\n\n" danger_will_robinson
+ pr "%s\n\n" danger_will_robinson;
+
+ match deprecation_notice flags with
+ | None -> ()
+ | Some txt -> pr "%s\n\n" txt
) all_functions_sorted
(* Generate a C function prototype. *)
if List.mem ProtocolLimitWarning flags then
pr "%s\n\n" protocol_limit_warning;
if List.mem DangerWillRobinson flags then
- pr "%s\n\n" danger_will_robinson
+ pr "%s\n\n" danger_will_robinson;
+ match deprecation_notice flags with
+ | None -> ()
+ | Some txt -> pr "%s\n\n" txt
)
) all_functions_sorted;
if List.mem DangerWillRobinson flags then
doc ^ "\n\n" ^ danger_will_robinson
else doc in
+ let doc =
+ match deprecation_notice flags with
+ | None -> doc
+ | Some txt -> doc ^ "\n\n" ^ txt in
let doc = pod2text ~width:60 name doc in
let doc = List.map (fun line -> replace_str line "\\" "\\\\") doc in
let doc = String.concat "\n " doc in
if List.mem DangerWillRobinson flags then
doc ^ "\n\n" ^ danger_will_robinson
else doc in
+ let doc =
+ match deprecation_notice flags with
+ | None -> doc
+ | Some txt -> doc ^ "\n\n" ^ txt in
let doc = pod2text ~width:60 name doc in
let doc = List.map ( (* RHBZ#501883 *)
function