Skip to content

Commit

Permalink
fix(xapi)): cannot compare functional values (xapi-project#6034)
Browse files Browse the repository at this point in the history
Fixes: 6635a00 ("CP-49136: Introduce PRNG for generating non-secret
UUIDs")
  • Loading branch information
edwintorok authored Oct 2, 2024
2 parents 802dda6 + a3ab228 commit d23597b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
11 changes: 10 additions & 1 deletion ocaml/tests/test_xapi_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ let filtering_test =
)
strings

let test_xapi_configure () =
Xcp_service.configure
~argv:[|Sys.argv.(0)|]
~options:Xapi_globs.all_options ()

let () =
Suite_init.harness_init () ;
Alcotest.run "Test XAPI Helpers suite" [("Test_xapi_helpers", filtering_test)]
Alcotest.run "Test XAPI Helpers suite"
[
("Test_xapi_helpers", filtering_test)
; ("Test_xapi_configure", [("configure", `Quick, test_xapi_configure)])
]
6 changes: 3 additions & 3 deletions ocaml/xapi-idl/lib/xcp_service.ml
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,15 @@ let configure_common ~options ~resources arg_parse_fn =
resources ;
Sys.set_signal Sys.sigpipe Sys.Signal_ignore

let configure ?(options = []) ?(resources = []) () =
let configure ?(argv = Sys.argv) ?(options = []) ?(resources = []) () =
try
configure_common ~options ~resources (fun config_spec ->
Arg.parse
Arg.parse_argv argv
(Arg.align (arg_spec config_spec))
(fun _ -> failwith "Invalid argument")
(Printf.sprintf "Usage: %s [-config filename]" Sys.argv.(0))
)
with Failure _ -> exit 1
with Failure msg -> prerr_endline msg ; flush stderr ; exit 1

let configure2 ~name ~version ~doc ?(options = []) ?(resources = []) () =
configure_common ~options ~resources @@ fun config_spec ->
Expand Down
3 changes: 2 additions & 1 deletion ocaml/xapi-idl/lib/xcp_service.mli
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ type res = {
; perms: Unix.access_permission list
}

val configure : ?options:opt list -> ?resources:res list -> unit -> unit
val configure :
?argv:string array -> ?options:opt list -> ?resources:res list -> unit -> unit

val configure2 :
name:string
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ let other_options =
; ( "use-prng-uuid-gen"
(* eventually this'll be the default, except for Sessions *)
, Arg.Unit (fun () -> Uuidx.make_default := Uuidx.make_uuid_fast)
, (fun () -> !Uuidx.make_default = Uuidx.make_uuid_fast |> string_of_bool)
, (fun () -> !Uuidx.make_default == Uuidx.make_uuid_fast |> string_of_bool)
, "Use PRNG based UUID generator instead of CSPRNG"
)
; ( "reuse-pool-sessions"
Expand Down
2 changes: 1 addition & 1 deletion quality-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mli-files () {
}

structural-equality () {
N=9
N=10
EQ=$(git grep -r --count ' == ' -- '**/*.ml' ':!ocaml/sdk-gen/**/*.ml' | cut -d ':' -f 2 | paste -sd+ - | bc)
if [ "$EQ" -eq "$N" ]; then
echo "OK counted $EQ usages of ' == '"
Expand Down

0 comments on commit d23597b

Please sign in to comment.