X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=generator%2Fgenerator_utils.ml;h=425a57941f8e4668715d4dc876290152da6af9e9;hp=cede5c67349f17410f8735383871d7cf57b80adf;hb=428a45c3e15f03e9861e1b551e1ae8da821dba5f;hpb=04d8209077d2227eb1d42695ba71147f78987050 diff --git a/generator/generator_utils.ml b/generator/generator_utils.ml index cede5c6..425a579 100644 --- a/generator/generator_utils.ml +++ b/generator/generator_utils.ml @@ -28,18 +28,23 @@ open Printf open Generator_types -(* Generate a random UUID (used in tests). *) +(* Generate a uuidgen-compatible UUID (used in tests). However to + * avoid having the UUID change every time we rebuild the tests, + * generate it as a function of the contents of the + * generator_actions.ml file. + * + * Originally I thought uuidgen was using RFC 4122, but it doesn't + * appear to. + * + * Note that the format must be 01234567-0123-0123-0123-0123456789ab + *) let uuidgen () = - let chan = open_process_in "uuidgen" in - let uuid = input_line chan in - (match close_process_in chan with - | WEXITED 0 -> () - | WEXITED _ -> - failwith "uuidgen: process exited with non-zero status" - | WSIGNALED _ | WSTOPPED _ -> - failwith "uuidgen: process signalled or stopped by signal" - ); - uuid + let s = Digest.to_hex (Digest.file "generator/generator_actions.ml") in + String.sub s 0 8 ^ "-" + ^ String.sub s 8 4 ^ "-" + ^ String.sub s 12 4 ^ "-" + ^ String.sub s 16 4 ^ "-" + ^ String.sub s 20 12 type rstructs_used_t = RStructOnly | RStructListOnly | RStructAndList @@ -78,8 +83,8 @@ let rstructs_used_by functions = in List.iter ( - fun (_, style, _, _, _, _, _) -> - match fst style with + fun (_, (ret, _, _), _, _, _, _, _) -> + match ret with | RStruct (_, structname) -> update structname RStructOnly | RStructList (_, structname) -> update structname RStructListOnly | _ -> () @@ -234,6 +239,8 @@ let seq_of_test = function | TestOutputTrue s | TestOutputFalse s | TestOutputLength (s, _) | TestOutputBuffer (s, _) | TestOutputStruct (s, _) + | TestOutputFileMD5 (s, _) + | TestOutputDevice (s, _) | TestLastFail s -> s let c_quote str = @@ -296,3 +303,14 @@ let pod2text ~width name longdesc = pod2text_memo_updated (); lines +(* Compare two actions (for sorting). *) +let action_compare (n1,_,_,_,_,_,_) (n2,_,_,_,_,_,_) = compare n1 n2 + +let chars c n = + let str = String.create n in + for i = 0 to n-1 do + String.unsafe_set str i c + done; + str + +let spaces n = chars ' ' n