This source file includes following definitions.
- op_is_not_probe_test
- op_does_not_have_right_values_test
- check_values_test
- main
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <stdarg.h>
13 #include <stddef.h>
14 #include <stdint.h>
15 #include <stdlib.h>
16 #include <setjmp.h>
17 #include <cmocka.h>
18
19 static void
20 op_is_not_probe_test(void **state) {
21 xmlNode *node = NULL;
22
23
24
25
26
27 node = string2xml("<lrm_rsc_op operation=\"start\" interval=\"0\"/>");
28 assert_false(pcmk_xe_mask_probe_failure(node));
29 free_xml(node);
30 }
31
32 static void
33 op_does_not_have_right_values_test(void **state) {
34 xmlNode *node = NULL;
35
36 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\"/>");
37 assert_false(pcmk_xe_mask_probe_failure(node));
38 free_xml(node);
39
40 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"\"/>");
41 assert_false(pcmk_xe_mask_probe_failure(node));
42 free_xml(node);
43 }
44
45 static void
46 check_values_test(void **state) {
47 xmlNode *node = NULL;
48
49
50 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"3\"/>");
51 assert_false(pcmk_xe_mask_probe_failure(node));
52 free_xml(node);
53
54 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"3\"/>");
55 assert_true(pcmk_xe_mask_probe_failure(node));
56 free_xml(node);
57
58
59 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"0\"/>");
60 assert_false(pcmk_xe_mask_probe_failure(node));
61 free_xml(node);
62
63 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"2\" op-status=\"0\"/>");
64 assert_true(pcmk_xe_mask_probe_failure(node));
65 free_xml(node);
66
67 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"0\"/>");
68 assert_true(pcmk_xe_mask_probe_failure(node));
69 free_xml(node);
70
71 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"6\" op-status=\"0\"/>");
72 assert_false(pcmk_xe_mask_probe_failure(node));
73 free_xml(node);
74
75 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"7\" op-status=\"0\"/>");
76 assert_false(pcmk_xe_mask_probe_failure(node));
77 free_xml(node);
78
79
80 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"7\"/>");
81 assert_true(pcmk_xe_mask_probe_failure(node));
82 free_xml(node);
83
84 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"7\"/>");
85 assert_true(pcmk_xe_mask_probe_failure(node));
86 free_xml(node);
87
88
89 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"4\"/>");
90 assert_false(pcmk_xe_mask_probe_failure(node));
91 free_xml(node);
92
93 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"2\" op-status=\"4\"/>");
94 assert_true(pcmk_xe_mask_probe_failure(node));
95 free_xml(node);
96
97 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"4\"/>");
98 assert_true(pcmk_xe_mask_probe_failure(node));
99 free_xml(node);
100
101 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"6\" op-status=\"4\"/>");
102 assert_false(pcmk_xe_mask_probe_failure(node));
103 free_xml(node);
104
105 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"7\" op-status=\"4\"/>");
106 assert_false(pcmk_xe_mask_probe_failure(node));
107 free_xml(node);
108
109
110 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"5\"/>");
111 assert_false(pcmk_xe_mask_probe_failure(node));
112 free_xml(node);
113
114 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"2\" op-status=\"5\"/>");
115 assert_true(pcmk_xe_mask_probe_failure(node));
116 free_xml(node);
117
118 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"5\"/>");
119 assert_true(pcmk_xe_mask_probe_failure(node));
120 free_xml(node);
121
122 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"6\" op-status=\"5\"/>");
123 assert_false(pcmk_xe_mask_probe_failure(node));
124 free_xml(node);
125
126 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"7\" op-status=\"5\"/>");
127 assert_false(pcmk_xe_mask_probe_failure(node));
128 free_xml(node);
129
130
131 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"6\"/>");
132 assert_false(pcmk_xe_mask_probe_failure(node));
133 free_xml(node);
134
135 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"2\" op-status=\"6\"/>");
136 assert_true(pcmk_xe_mask_probe_failure(node));
137 free_xml(node);
138
139 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"6\"/>");
140 assert_true(pcmk_xe_mask_probe_failure(node));
141 free_xml(node);
142
143 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"6\" op-status=\"6\"/>");
144 assert_false(pcmk_xe_mask_probe_failure(node));
145 free_xml(node);
146
147 node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"7\" op-status=\"6\"/>");
148 assert_false(pcmk_xe_mask_probe_failure(node));
149 free_xml(node);
150 }
151
152 int main(int argc, char **argv)
153 {
154 const struct CMUnitTest tests[] = {
155 cmocka_unit_test(op_is_not_probe_test),
156 cmocka_unit_test(op_does_not_have_right_values_test),
157 cmocka_unit_test(check_values_test),
158 };
159
160 cmocka_set_message_output(CM_OUTPUT_TAP);
161 return cmocka_run_group_tests(tests, NULL, NULL);
162 }