diff options
author | Richard Jones <rjones@redhat.com> | 2010-09-11 12:05:03 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-09-11 12:44:52 +0100 |
commit | 451a28349b11fe08cb3f7ca84e58b6e69646707b (patch) | |
tree | df13ffa9187372797bbc5b67501fe6ded9046efd | |
parent | 04d8209077d2227eb1d42695ba71147f78987050 (diff) | |
download | libguestfs-451a28349b11fe08cb3f7ca84e58b6e69646707b.tar.gz libguestfs-451a28349b11fe08cb3f7ca84e58b6e69646707b.tar.xz libguestfs-451a28349b11fe08cb3f7ca84e58b6e69646707b.zip |
generator: Don't use real uuidgen for UUIDs.
This was one reason why capitests/tests.c changed every time the
generator was run.
-rw-r--r-- | generator/generator_utils.ml | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/generator/generator_utils.ml b/generator/generator_utils.ml index cede5c67..e3a74e08 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 |