From 3ccf96feb642ca48aa98a116d81c3141e05540ac Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 9 Nov 2011 17:47:23 +0000 Subject: [PATCH] tests: Fix bitmask parameter when testing optional arguments. The bitmask was being constructed backwards(!) As a result, any test which tested optional arguments didn't work. There are very few such tests and they happened not to be affected by this. (cherry picked from commit af2b0378bbb178a4e3db326ac3082d66170fcafc) --- generator/generator_capitests.ml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/generator/generator_capitests.ml b/generator/generator_capitests.ml index 2cad2ae..7bfd87c 100644 --- a/generator/generator_capitests.ml +++ b/generator/generator_capitests.ml @@ -776,8 +776,8 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = if optargs <> [] then ( pr " struct guestfs_%s_argv optargs;\n" name; - let bitmask = List.fold_left ( - fun bitmask optarg -> + let _, bitmask = List.fold_left ( + fun (shift, bitmask) optarg -> let is_set = match optarg with | Bool n, "" -> false @@ -803,10 +803,11 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = | String n, arg -> pr " optargs.%s = \"%s\";\n" n (c_quote arg); true | _ -> assert false in - let bitmask = Int64.shift_left bitmask 1 in - let bitmask = if is_set then Int64.succ bitmask else bitmask in - bitmask - ) 0L optargs in + let bit = if is_set then Int64.shift_left 1L shift else 0L in + let bitmask = Int64.logor bitmask bit in + let shift = shift + 1 in + (shift, bitmask) + ) (0, 0L) optargs in pr " optargs.bitmask = UINT64_C(0x%Lx);\n" bitmask; ); -- 1.8.3.1