Skip to content

Commit 071e644

Browse files
committed
Unit tests for Features.of_assoc_list
Signed-off-by: Rob Hoes <[email protected]>
1 parent a1ada41 commit 071e644

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

ocaml/test/OMakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ OCAML_OBJS = \
6464
test_dbsync_master \
6565
test_xapi_xenops \
6666
test_no_migrate \
67+
test_features \
6768

6869
OCamlProgram(suite, suite $(OCAML_OBJS) )
6970

ocaml/test/suite.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ let base_suite =
3434
Test_map_check.test;
3535
Test_pool_apply_edition.test;
3636
Test_pool_license.test;
37+
Test_features.test;
3738
Test_pool_restore_database.test;
3839
Test_platformdata.test;
3940
Test_sm_features.test;

ocaml/test/test_features.ml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
(*
2+
* Copyright (C) Citrix Systems Inc.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
open OUnit
16+
open Test_highlevel
17+
open Features
18+
19+
module OfAssocList = Generic.Make(struct
20+
module Io = struct
21+
type input_t = (string * string) list
22+
type output_t = Features.feature list
23+
24+
let string_of_input_t = Test_printers.(assoc_list string string)
25+
let string_of_output_t =
26+
Test_printers.(fun features -> String.concat "," (List.map name_of_feature features))
27+
end
28+
29+
let transform = of_assoc_list
30+
31+
(* Xen_motion and AD are enabled unless explicitly disabled. All other features
32+
are disabled unless explitly enabled. *)
33+
let tests = [
34+
[],
35+
[Xen_motion; AD];
36+
37+
["restrict_xen_motion", "true";
38+
"restrict_ad", "true"],
39+
[];
40+
41+
["restrict_xen_motion", "true"],
42+
[AD];
43+
44+
["restrict_xen_motion", "false"],
45+
[Xen_motion; AD];
46+
47+
["restrict_xen_motion", "false";
48+
"restrict_dmc", "false"],
49+
[DMC; Xen_motion; AD];
50+
51+
["restrict_xen_motion", "false";
52+
"restrict_ad", "true";
53+
"restrict_dmc", "false"],
54+
[DMC; Xen_motion];
55+
56+
["enable_xha", "true";
57+
"restrict_xen_motion", "true"],
58+
[HA; AD];
59+
]
60+
end)
61+
62+
63+
let test =
64+
"pool_license" >:::
65+
[
66+
"test_of_assoc_list" >::: OfAssocList.tests;
67+
]

0 commit comments

Comments
 (0)