X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_utils.ml;h=aa7fcba3c6888dc4282903c3a7f266b9139cd7d5;hb=a7740cb19a6991d21dc9395dffb87d69ee5986b5;hp=27b543d459cdac3a32222a84bb5a9c00bd4040f6;hpb=b4c853f7d493af1d71f352832fed29eb7e377e8f;p=libguestfs.git diff --git a/generator/generator_utils.ml b/generator/generator_utils.ml index 27b543d..aa7fcba 100644 --- a/generator/generator_utils.ml +++ b/generator/generator_utils.ml @@ -1,5 +1,5 @@ (* libguestfs - * Copyright (C) 2009-2010 Red Hat Inc. + * Copyright (C) 2009-2011 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,21 @@ open Printf open Generator_types +let errcode_of_ret = function + | RConstOptString _ -> + `CannotReturnError + | RErr | RInt _ | RBool _ | RInt64 _ -> + `ErrorIsMinusOne + | RConstString _ + | RString _ | RBufferOut _ + | RStringList _ | RHashtable _ + | RStruct _ | RStructList _ -> + `ErrorIsNULL + +let string_of_errcode = function + | `ErrorIsMinusOne -> "-1" + | `ErrorIsNULL -> "NULL" + (* 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 @@ -40,6 +55,14 @@ open Generator_types *) let uuidgen () = let s = Digest.to_hex (Digest.file "generator/generator_actions.ml") in + + (* In util-linux <= 2.19, mkswap -U cannot handle the first byte of + * the UUID being zero, so we artificially rewrite such UUIDs. + * http://article.gmane.org/gmane.linux.utilities.util-linux-ng/4273 + *) + if s.[0] = '0' && s.[1] = '0' then + s.[0] <- '1'; + String.sub s 0 8 ^ "-" ^ String.sub s 8 4 ^ "-" ^ String.sub s 12 4 ^ "-" @@ -241,6 +264,7 @@ let seq_of_test = function | TestOutputStruct (s, _) | TestOutputFileMD5 (s, _) | TestOutputDevice (s, _) + | TestOutputHashtable (s, _) | TestLastFail s -> s let c_quote str =